Is there a way in NUSOAP to set a node's namespace?
Using normal PHP soap, it can be done with SoapVar.
What is the equivalent in NuSoap?
I have:
<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">
<SOAP-ENV:Body>
<AuthenticateMember xmlns="www.ownyourliferewards.co.za">
<request>
<SecurityToken>9415CD31-0C7E-40AB-A45F-D3538B98B96B</own1:SecurityToken>
<MembershipNumber>200803407801</own2:MembershipNumber>
</request>
</AuthenticateMember>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
and I want:
<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">
<SOAP-ENV:Body>
<AuthenticateMember xmlns="www.ownyourliferewards.co.za">
<request>
<own1:SecurityToken>9415CD31-0C7E-40AB-A45F-D3538B98B96B</own1:SecurityToken>
<own2:MembershipNumber>200803407801</own2:MembershipNumber>
</request>
</AuthenticateMember>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
(note the own1: and own2: namespaces on the nodes)
Thanks
Jacques
Related
I am creating a SoapServer side in php. Someone makes a request and the server responds with an xml.
I've been asked to change the response envelope from SOAP-ENV to soapenv.
This is how it's looking now:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://testing.bonusfarma.com.ar/api/serverSideSoap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
...
</SOAP-ENV:Envelope>
This is how it has to be:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://testing.bonusfarma.com.ar/api/serverSideSoap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
...
</soap:Envelope>
I've been trying to change the soap version because I read that it is what defines the envelope but it doesn't seem to work. The change is supposed to be just a parameter:
$server = new SoapServer(null, array(
'location' => 'xxxxx'
'uri' => 'xxxxx'
'soap_version' => SOAP_1_2 // not working
)
);
Have any idea about what's generating the SOAP-ENV and what can I do to change it?
I have a webservice in PHP, using SOAP and one of sending parameters is 'fileContent' with is a string with xml content like this:
$string='<?xml version="1.0" encoding="UTF-8"?><rootTag><a>tag</a></rootTag>';
The request is
<!--Optional:-->
<ws:fileContent>'<?xml version="1.0" encoding="UTF-8"?><rootTag><a>tag</a> </rootTag>'</ws:fileContent>
</ws:ReservationDetailsRQ>
The response is
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Bad Request</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Can you tell how can i do this?
thanks for reading. I am having a big problem using the SOAPServer class from php.
when we make the test we have this respons, that works well:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WSDL" 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>
<ns1:NotificacionClienteResponse>
<NotificacionClienteReturn xsi:type="xsd:string"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<NotificacionCliente>
<RESULTADO>
<CODIGORETORNO>8</CODIGORETORNO>
<DESCRIPCIONRETORNO>Xml incorrecto</DESCRIPCIONRETORNO>
</RESULTADO>
</NotificacionCliente>]]>
</NotificacionClienteReturn>
</ns1:NotificacionClienteResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
but when we do the same, but in other server, we have this response:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WSDL" 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:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:NotificacionClienteResponse>
<NotificacionClienteReturn xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?>
<NotificacionCliente>
<RESULTADO>
<CODIGORETORNO>8</CODIGORETORNO>
<DESCRIPCIONRETORNO>Xml incorrecto</DESCRIPCIONRETORNO>
</RESULTADO>
</NotificacionCliente>
</NotificacionClienteReturn>
</ns1:NotificacionClienteResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope
as you can see in the second respons there are 3 different problems:
it appers < and > in place of < and >
at the end of the xml its missing de >
and the xml its not formated (i did it for you :) )
Information about the server:
same wsdl, web server, php_soap.dll, php.ini
we use iis v6 and php v5.2.9-2
the php is calling the SOAPServer this way, in both servers:
new SOAPServer($Path, array('encoding'=>'ISO-8859-1'))
well, any information you can tell us or any clue you might think its worth tring just tell it...
of course, the same if you need more information.
thanks you all in advance!
I am trying to create a SOAP request in PHP using NUSOAP,
require_once('lib/nusoap.php');
$client = new nusoap_client('wsdl_link', true);
The structure of the request i want to generate is:
<rootlevel att1="abc" att2="def" >
<Start>
</Start>
</rootlevel >
The parameters are as follows:
$params=array('att1'=>'abc',
'att2'=>'def',
'start'=>array(/*array defined here*/));
$result = $client->call('function_name', array('rootlevel' => $params));
But with the request generated is as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<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/" xmlns:ns4439="http://tempuri.org">
<SOAP-ENV:Body>
<rootlevel xmlns="http://site/01">
<start>
</start>
</rootlevel>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Kindly tel me why my attributes are getting replaced by xmlns..
Edit:
I was going through my wsdl:
In the wsdl, the tag rootlevel is defined as ref="tns:rootlevel" and attributes are defined under name=rootlevel which is somewhere else in the wsdl.
For some of the attributes the request is coming proper(here the tag is defined as name and the attributes are under this tag.). but some are being replaced by xmlns.. Please let me know where im going wrong.
I solved my problem using the "send" function of NUSOAP.. Here u dont have to create an array and all.. The request can be sent in the XML format itself as follows:
$params="<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/" xmlns:ns4439="http://tempuri.org">
<SOAP-ENV:Body>
<rootlevel xmlns="http://site/01">
<start>
</start>
</rootlevel>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>";
$result = $client->send($params, 'wsdl_url/function',0,$timeout);
Hope this Helps You.. :)
I am trying to send a test to UPS tracking API, but i keep getting the following error
SoapFault: Wrong Version in...
Below is my Request Document I send
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0"
xmlns:ns2="http://www.ups.com/XMLSchema/XOLTWS/Track/v2.0"
xmlns:ns3="http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0">
<SOAP-ENV:Header>
<ns3:UPSSecurity>
<ns3:UsernameToken>
<ns3:Username>username</ns3:Username>
<ns3:Password>password</ns3:Password>
</ns3:UsernameToken>
<ns3:ServiceAccessToken>
<ns3:AccessLicenseNumber>855566598C34</ns3:AccessLicenseNumber>
</ns3:ServiceAccessToken>
</ns3:UPSSecurity>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns2:TrackRequest>
<ns1:Request>
<ns1:RequestOption>15</ns1:RequestOption>
<ns1:TransactionReference>
<ns1:CustomerContext>Add description here</ns1:CustomerContext>
</ns1:TransactionReference>
</ns1:Request>
<ns2:InquiryNumber></ns2:InquiryNumber>
<ns2:TrackingOption>02</ns2:TrackingOption>
</ns2:TrackRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Below is my xml response
<?xml version="1.0"?>
<TrackResponse>
<Response>
<ResponseStatusCode>0</ResponseStatusCode>
<ResponseStatusDescription>Failure</ResponseStatusDescription>
<Error>
<ErrorSeverity>Hard</ErrorSeverity>
<ErrorCode>10002</ErrorCode>
<ErrorDescription>The XML document is well formed but the document is not valid</ErrorDescription>
</Error>
</Response>
</TrackResponse>
Its giving me a invalid tracking number now so I think I figured it out. The problem was a invalid endpoint. I am using the tracking API so the endpoint should be
https://wwwcie.ups.com/webservices/Track