I was tired of this problem for a long time and could not find a solution after many hours of searching.
I am using Fedex web service which returns delivery speed. Next is my php code
try {
$client = new SoapClient($path_to_wsdl, array(
'uri' => 'http://fedex.com/ws/rate/v14',
'location' => 'https://ws.fedex.com:443/web-services/rate',
'soap_version' => 'SOAP_1_1',
'login' => 'myusername',
'password' => 'password',
'proxy_host' => 'proxy-host-name',
'proxy_port' => 443,
'proxy_login' => '',
'proxy_password' => '',
'trace' => 1,
'exceptions' => 1));
$data = array(
'Action' => "http://fedex.com/ws/rate/v14/getRates"
);
$header = new SoapHeader('http://fedex.com/ws/rate/v14', 'FedexHeader', $data, false);
$client->__setSoapHeaders($header);
if(setEndpoint('changeEndpoint')){
$newLocation = $client->__setLocation(setEndpoint('endpoint'));
}
$response = $client -> getRates($request);
} catch (SoapFault $exception) {
echo '<h2>exception</h2>';
print_r($exception);
echo '<br/><h2>exception trace</h2>';
var_dump($exception->getTraceAsString());
echo '<br/>Request headers : <br/><xmp>',
$client->__getLastRequestHeaders(),
'</xmp><br/>';
echo 'Request : <br/><xmp>',
$client->__getLastRequest(),
'</xmp><br/>';
echo 'Response headers: <br/><xmp>',
$client->__getLastResponseHeaders(),
'</xmp><br/>';
echo 'Response : <br/><xmp>',
$client->__getLastResponse(),
'</xmp><br/>';
printFault($exception, $client);
}
This is an example of Fedex code - the only parts I changed are the path to the wsdl file, adding more debugging information, and installing SoapHeader.
The following is the request header:
POST /web-services/rate HTTP/1.1 Host: ws.fedex.com
Connection: Keep-Alive User-Agent: PHP-SOAP/5.3.27
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://fedex.com/ws/rate/v14/getRates"
Content-Length: 2974
and response header:
HTTP/1.1 400 Bad Request
Date: Mon, 17 Feb 2014 16:25:56
GMT Server: Apache/2.2
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1
Here is the part of the SOAP request itself that is generated:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://fedex.com/ws/rate/v14" xmlns:ns2="http://www.w3.org/2005/08/addressing">
<SOAP-ENV:Header>
<ns2:Action>http://fedex.com/ws/rate/v14/getRates</ns2:Action>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:RateRequest>
<ns1:WebAuthenticationDetail>
<ns1:UserCredential>
//user credentials
</ns1:UserCredential>
</ns1:WebAuthenticationDetail>
<ns1:ClientDetail>
//client details
</ns1:ClientDetail>
<ns1:RequestedShipment>
//shipping details ..
</ns1:RequestedShipment>
</ns1:RateRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The thing is, when I insert this request into the SOAP interface, it returns the correct answer. Also, the Fedex support team has confirmed that it is true.
, PHP. ( " ", - , -, ops , , , )
SoapHeader , , , . , soapAction Action, wsdl soapAction? wsdl:
<operation name="getRates">
<s1:operation soapAction="http://fedex.com/ws/rate/v14/getRates" style="document"/>
</operation>
, . SoapUI .
: , SSL. Fedex, , SSL.
, SoapUI, , - .
, , , , .