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

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

Related

PHP SOAP request fails

I have to send a request to a remote SOAP endpoint. This is the SOAP request that PHP generates, and it fails:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org">
<SOAP-ENV:Body>
<ns1:GetParameterList>
<param>TKERES</param>
</ns1:GetParameterList>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
If I write the request XML manually this way and send it via cURL, it works perfectly:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<GetParameterList xmlns="http://tempuri.org">
<param>TKERES</param>
</GetParameterList>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Why do the first fail while the second one works correctly?
What is obvious here is that your first snippet (the one that doesn't work) is different from the one that works.
Specifically the property below looks to be in totally different places.
xmlns="http://tempuri.org"
I know from experience with SOAP that sometimes a change like this can cause it to fail. So, try if you can to adjust the way that PHP generates the request in order to match it with your XML hand written one.

PHP soapClient xml soap envelope format error

I call a method with php soapClient class, like this:
$client->ResetAppPassword($request);
and my envelope is send like this
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://xmlns.xxxx.com/PATH/TO/V1/schema"
xmlns:ns2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<SOAP-ENV:Body>
<ns1:ResetAppPasswordRequest>
<ns1:username>TEST</ns1:username>
<ns1:app>TEST</ns1:app>
</ns1:ResetAppPasswordRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But the server response:
The message must be an instance of: {http://www.w3.org/2003/05/soap-envelope}Envelope
and this is because the service is specting other format:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:sch="http://xmlns.xxxx.com/PATH/TO/V1/schema">
<soap:Body>
<sch:ResetAppPasswordRequest>
<sch:username>TEST</sch:username>
<sch:app>DMS</sch:app>
</sch:ResetAppPasswordRequest>
</soap:Body>
</soap:Envelope>
So the i already tried to send it via php-CURL but with this solution I need to parse the XML response, so this make the process really hard, because I want to manage the response as an object.
Can someone help me... PLEASSSE..

Converting from XML to PHP

I am writing PHP soap client.
I used wsdlbrowser to format the soap request correctly.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.iws.iaeste.net/">
<SOAP-ENV:Body>
<ns1:fetchOffers>
<token>
<token>..your token..</token>
</token>
<request>
<exchangeYear>2015</exchangeYear>
<fetchType>SHARED</fetchType></request>
</ns1:fetchOffers>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This would be correctly formatted soap request. Or to be specific, the code beetwen first token tag and last request tag is in the point of interest.
How would I transfer this request to PHP for sending it over SOAP?
THis question is connceted to: PHP Soap client, Java SOAP server

SOAP send xml string

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?

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!

Categories