我正在尝试集成fedex serviceavailabilty以根据使用的服务类型返回估计的交付时间。
我使用curl通过http post使用xml,但它给了我一个错误。
<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);
感谢任何帮助。
谢谢
瑞克
答案 0 :(得分:0)
看起来您收到的错误是短暂的,这意味着它可能是FedEx方面的一个问题,并且可能会自行解决。
您的请求XML对我来说没问题。我能看到的唯一区别是packaging
标记。
这是我刚刚通过RocketShipIt(我是作者)的一个有效的XML请求:
<ServiceAvailabilityRequest>
<WebAuthenticationDetail>
<UserCredential>
<Key>...</Key>
<Password>...</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>...</AccountNumber>
<MeterNumber>...</MeterNumber>
</ClientDetail>
<Version>
<ServiceId>vacs</ServiceId>
<Major>4</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<Origin>
<PostalCode>94608</PostalCode>
<CountryCode>US</CountryCode>
</Origin>
<Destination>
<PostalCode>90210</PostalCode>
<CountryCode>US</CountryCode>
</Destination>
<ShipDate>2017-07-08</ShipDate>
<CarrierCode>FDXE</CarrierCode>
<Packaging>YOUR_PACKAGING</Packaging>
</ServiceAvailabilityRequest>
响应:
<ServiceAvailabilityReply>
<HighestSeverity>SUCCESS</HighestSeverity>
<Notifications>
<Severity>SUCCESS</Severity>
<Source>vacs</Source>
<Code>000</Code>
<Message>SUCCESS</Message>
<LocalizedMessage>SUCCESS</LocalizedMessage>
</Notifications>
<Version>
<ServiceId>vacs</ServiceId>
<Major>4</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<Options>
<Service>FIRST_OVERNIGHT</Service>
<DeliveryDate>2017-07-10</DeliveryDate>
<DeliveryDay>MON</DeliveryDay>
<DestinationStationId>SMOA </DestinationStationId>
<DestinationAirportId>LAX</DestinationAirportId>
</Options>
<Options>
<Service>PRIORITY_OVERNIGHT</Service>
<DeliveryDate>2017-07-10</DeliveryDate>
<DeliveryDay>MON</DeliveryDay>
<DestinationStationId>SMOA </DestinationStationId>
<DestinationAirportId>LAX</DestinationAirportId>
</Options>
<Options>
<Service>STANDARD_OVERNIGHT</Service>
<DeliveryDate>2017-07-10</DeliveryDate>
<DeliveryDay>MON</DeliveryDay>
<DestinationStationId>SMOA </DestinationStationId>
<DestinationAirportId>LAX</DestinationAirportId>
</Options>
<Options>
<Service>FEDEX_2_DAY_AM</Service>
<DeliveryDate>2017-07-11</DeliveryDate>
<DeliveryDay>TUE</DeliveryDay>
<DestinationStationId>SMOA </DestinationStationId>
<DestinationAirportId>LAX</DestinationAirportId>
</Options>
<Options>
<Service>FEDEX_2_DAY</Service>
<DeliveryDate>2017-07-11</DeliveryDate>
<DeliveryDay>TUE</DeliveryDay>
<DestinationStationId>SMOA </DestinationStationId>
<DestinationAirportId>LAX</DestinationAirportId>
</Options>
<Options>
<Service>FEDEX_EXPRESS_SAVER</Service>
<DeliveryDate>2017-07-12</DeliveryDate>
<DeliveryDay>WED</DeliveryDay>
<DestinationStationId>SMOA </DestinationStationId>
<DestinationAirportId>LAX</DestinationAirportId>
</Options>
<Options>
<Service>FEDEX_FIRST_FREIGHT</Service>
<DeliveryDate>2017-07-10</DeliveryDate>
<DeliveryDay>MON</DeliveryDay>
<DestinationStationId>LAXRT</DestinationStationId>
<DestinationAirportId>LAX</DestinationAirportId>
</Options>
<Options>
<Service>FEDEX_1_DAY_FREIGHT</Service>
<DeliveryDate>2017-07-10</DeliveryDate>
<DeliveryDay>MON</DeliveryDay>
<DestinationStationId>LAXRT</DestinationStationId>
<DestinationAirportId>LAX</DestinationAirportId>
</Options>
<Options>
<Service>FEDEX_2_DAY_FREIGHT</Service>
<DeliveryDate>2017-07-11</DeliveryDate>
<DeliveryDay>TUE</DeliveryDay>
<DestinationStationId>LAXRT</DestinationStationId>
<DestinationAirportId>LAX</DestinationAirportId>
</Options>
<Options>
<Service>FEDEX_3_DAY_FREIGHT</Service>
<DeliveryDate>2017-07-12</DeliveryDate>
<DeliveryDay>WED</DeliveryDay>
<DestinationStationId>LAXRT</DestinationStationId>
<DestinationAirportId>LAX</DestinationAirportId>
</Options>
</ServiceAvailabilityReply>
编辑:您的ServiceId标记可能与此错误有关。