SOAP send xml string - php

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?

Related

Soap error: "looks like we got no XML document"

I check the difference bettwen a call who work simulating soap with curl request which work here is the xml that work:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.test.com/">
<soapenv:Header/>
<soapenv:Body>
<ser:DoItdoItRequest1>
<version>1.0</version>
</ser:DoItdoItRequest1>
</soapenv:Body>
</soapenv:Envelope>
I change my code using SoapClient to be more clean than emulating a curl request, but my server return me:
looks like we got no XML document
When debugging I get from client->__getLastRequest()
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://service.test.com/">
<SOAP-ENV:Body>
<ns1:DoItdoItRequest1>
<version>1.0</version>
</ns1:DoItdoItRequest1>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The only difference seems to be:
<ser:DoItdoItRequest1>
against
<ns1:DoItdoItRequest1>
Do you know how to change this ns1: to a ser: with SoapClient ? an option maybe ?
I can't find helpful help about that...
Regards.

How do you set the NODE namespace with NuSoap?

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

SOAPServer+php+iis v6 (not correct closing tag)

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 &lt and &gt 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!

Forming DoubleClick for Publishers Soap Requests without a library in PHP

I'm stuck developing in an environment where I cannot use the PHP DFP library. I'm using PHP's SoapClient and I'm having trouble forming the headers correctly for SOAP requests. Here's the example:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:RequestHeader
soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
soapenv:mustUnderstand="0"
xmlns:ns1="https://www.google.com/apis/ads/publisher/v201308">
<ns1:authentication xsi:type="ns1:ClientLogin" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ns1:token>SuchALongToken</ns1:token>
</ns1:authentication>
<ns1:networkCode>123456</ns1:networkCode>
<ns1:applicationName>DfpApi-Java-2.1.0-dfp_test</ns1:applicationName>
</ns1:RequestHeader>
</soapenv:Header>
<soapenv:Body>
<getAdUnitsByStatement xmlns="https://www.google.com/apis/ads/publisher/v201308">
<filterStatement>
<query>WHERE parentId IS NULL LIMIT 500</query>
</filterStatement>
</getAdUnitsByStatement>
</soapenv:Body>
</soapenv:Envelope>
It's the Authentication section that's getting me. Not sure how to set the internal params (type and xsd) and create the 'token' child.
$header_params = new stdClass();
$header_params->networkCode = self::$network_code;
$header_params->applicationName = $app_name;
$header_params->authentication = array('token' => $this->auth_token);
$headers = new SoapHeader(self::getNamespace(), 'RequestHeader', $header_params);
This gets me the following:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://www.google.com/apis/ads/publisher/v201308">
<SOAP-ENV:Header>
<ns1:RequestHeader>
<ns1:networkCode>########</ns1:networkCode>
<ns1:applicationName>Get Companies By Filter</ns1:applicationName>
<ns1:authentication />
</ns1:RequestHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:getCompaniesByStatement>
<ns1:filterStatement />
</ns1:getCompaniesByStatement>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Looks like wsdl is rejecting my authentication as well as my filterStatement. I'd be happy to get the authentication working at the moment. This request give me an 'Unmarshalling' error.
Any help would be much appreciated!

UPS Soap Tracking API But getting error ... faultcode VersionMismatch

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

Categories