0
我正在嘗試集成fedex服務可用性以基於所使用的服務類型返回估計的交付時間。fedex serviceavailabilityrequest失敗
我使用xml通過http post使用curl,但它給我一個錯誤。
<SOAP-ENV:Fault xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring xml:lang="en">Fault</faultstring>
<detail>
<cause>Transient</cause>
<code>unknownCode</code>
<desc>java.lang.NullPointerException</desc>
</detail>
</SOAP-ENV:Fault
我的代碼如下:
$request = "<?xml version=\"1.0\"?>
<ns:ServiceAvailabilityRequest xmlns:ns=\"http://fedex.com/ws/vacs/v4\">
<ns:WebAuthenticationDetail>
<ns:UserCredential>
<ns:Key>{$this->apikey}</ns:Key>
<ns:Password>{$this->password}</ns:Password>
</ns:UserCredential>
</ns:WebAuthenticationDetail>
<ns:ClientDetail>
<ns:AccountNumber>{$this->account}</ns:AccountNumber>
<ns:MeterNumber>{$this->meter}</ns:MeterNumber>
</ns:ClientDetail>
<ns:TransactionDetail>
<ns:CustomerTransactionId>ServiceAvailabilityRequest</ns:CustomerTransactionId>
</ns:TransactionDetail>
<ns:Version>
<ns:ServiceId>trck</ns:ServiceId>
<ns:Major>4</ns:Major>
<ns:Intermediate>0</ns:Intermediate>
<ns:Minor>0</ns:Minor>
</ns:Version>
<ns:Origin>
<ns:PostalCode>07075</ns:PostalCode>
<ns:CountryCode>US</ns:CountryCode>
</ns:Origin>
<ns:Destination>
<ns:PostalCode>11216</ns:PostalCode>
<ns:CountryCode>US</ns:CountryCode>
</ns:Destination>
<ns:ShipDate>2017-07-08</ns:ShipDate>
<ns:CarrierCode>FDXE</ns:CarrierCode>
</ns:ServiceAvailabilityRequest>";
$ch = curl_init('http://gateway.fedex.com:443/xml');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
任何幫助表示讚賞。
謝謝
裏克
謝謝你sanbornm。我將serviceId更正爲「vacs」,並且像魅力一樣工作。 – Rick