Please assist with a namespace issue
Jacques Grove <[email protected]>
| Newsgroups | gmane.comp.php.nusoap.general |
|---|---|
| Message-ID | <CAJ_hK0QK98JicvJmg_NysBF78v-LRxZnNQ_YX9QR2orFmnpwtw@mail.gmail.com> |
Hi there
For easy reading, this question can also be found at:
http://stackoverflow.com/questions/31270318/please-help-me-with-this-nusoap-issue
I am having a huge headache. I am doing this in SoapUI:
DESIRED CALL / REQUEST
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:own="www.ownyourliferewards.co.za"
xmlns:own1="http://schemas.datacontract.org/2004/07/OwnYourLife.WebServices.WebServicesBase"
xmlns:own2="http://schemas.datacontract.org/2004/07/OwnYourLife.WebServices.Generic.DataObjects">
<soapenv:Header/>
<soapenv:Body>
<own:AuthenticateMember>
<!--Optional:-->
<own:request>
<!--Optional:-->
<own1:SecurityToken>9415CD31-0C7E-40AB-A45F-D3538B98B96B</own1:SecurityToken>
<!--Optional:-->
<own2:MembershipNumber>200803407801</own2:MembershipNumber>
</own:request>
</own:AuthenticateMember>
</soapenv:Body>
</soapenv:Envelope>
I am doing the following in PHP and Nusoap:
<?php
require_once('nusoap.php');
$client = new
nusoap_client('https://integrationqa.ownyourliferewards.co.za/RTService.svc?wsdl',
'wsdl');
$client->soap_defencoding='utf-8';
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
$param = array('request'=> array('MembershipNumber' =>
'200803407801', 'SecurityToken' =>
'9415CD31-0C7E-40AB-A45F-D3538B98B96B' ));
$result = $client->call('AuthenticateMember', $param);
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
} else {
// Display the result
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
}
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
WHAT I AM GETTING WITH THE ABOVE CODE:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<AuthenticateMember xmlns="www.ownyourliferewards.co.za">
<request>
<MembershipNumber>200803407801</MembershipNumber>
<SecurityToken>9415CD31-0C7E-40AB-A45F-D3538B98B96B</SecurityToken>
</request>
</AuthenticateMember>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
As you can see, there are some important bits missing.
1) The `own:`, `own1:`, and `own2:` "namespaces" (if that is what they
are) are missing.
2) There is no header as per the desired example.
Any kind of fix or workaround will be sincerely appreciated.
UPDATE:
I have now been able to get the request to look like this:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:own="www.ownyourliferewards.co.za"
xmlns:own1="http://schemas.datacontract.org/2004/07/OwnYourLife.WebServices.WebServicesBase"
xmlns:own2="http://schemas.datacontract.org/2004/07/OwnYourLife.WebServices.Generic.DataObjects"
xmlns:ns5813="http://tempuri.org">
<SOAP-ENV:Body>
<AuthenticateMember xmlns="www.ownyourliferewards.co.za">
<request>
<MembershipNumber>200803407801</MembershipNumber>
<SecurityToken>9415CD31-0C7E-40AB-A45F-D3538B98B96B</SecurityToken>
</request>
</AuthenticateMember>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
by adding
$client->namespaces =
array('SOAP-ENV'=>"http://schemas.xmlsoap.org/soap/envelope/",
'own'=>"www.ownyourliferewards.co.za",
'own1'=>'http://schemas.datacontract.org/2004/07/OwnYourLife.WebServices.WebServicesBase',
'own2'=>'http://schemas.datacontract.org/2004/07/OwnYourLife.WebServices.Generic.DataObjects');
The final remaining issue I have is this:
How do I "inject" those namespaces so that the xml looks like this:
<own:AuthenticateMember xmlns="www.ownyourliferewards.co.za">
<own:request>
<own1:SecurityToken>9415CD31-0C7E-40AB-A45F-D3538B98B96B</own1:SecurityToken>
<own2:MembershipNumber>200803407801</own2:MembershipNumber>
</own:request>
</own:AuthenticateMember>
Please, can anyone assist?
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/