联邦快递服务可用性请求失败

fedex serviceavailabilityrequest is failing

我正在尝试将联邦快递服务可用性集成到 return 基于所用服务类型的预计交货时间。

我正在使用 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);

感谢任何帮助。

谢谢

瑞克

您收到的错误似乎是暂时的,这意味着它可能是 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 标记可能与此错误有关。