2017-07-07 14 views
0

私は、使用されたサービスタイプに基づいて、予想される配送時間を返すために、fedex serviceavailabiltyを統合しようとしています。fedex serviceavailabilityrequestが失敗しています

私はcurlを使用してHTTPポスト経由で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

ありがとうございます。

あなたのリクエスト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> 

編集:あなたのサービスIDタグは、このエラーに関連している可能性があります。

+0

ありがとうsanbornm。私はserviceIdを '​​vacs'に修正しました。それは魅力的に機能しました。 – Rick

関連する問題