3

我正在尝试使用 XML api 在项目中实现 FedEx 包裹跟踪。以下是我的跟踪请求:

'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v6="http://fedex.com/ws/track/v6">
                <soapenv    '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v6="http://fedex.com/ws/track/v6">
                <soapenv:Header/>
                <soapenv:Body>
                <v6:TrackRequest>
                    <v6:WebAuthenticationDetail>
                        <v6:UserCredential>
                            <v6:Key>'.fedex_accesskey.'</v6:Key>
                            <v6:Password>'.fedex_password.'</v6:Password>
                        </v6:UserCredential>
                    </v6:WebAuthenticationDetail>
                    <v6:ClientDetail>
                        <v6:AccountNumber>'.fedex_account.'</v6:AccountNumber>
                        <v6:MeterNumber>'.fedex_meter.'</v6:MeterNumber>
                        <v6:IntegratorId></v6:IntegratorId>
                        <v6:Localization>
                            <v6:LanguageCode>EN</v6:LanguageCode>
                            <v6:LocaleCode>US</v6:LocaleCode>
                        </v6:Localization>
                    </v6:ClientDetail>
                    <v6:TransactionDetail>
                        <v6:CustomerTransactionId>Track By Number</v6:CustomerTransactionId>
                        <v6:Localization>
                        <v6:LanguageCode>EN</v6:LanguageCode>
                        <v6:LocaleCode>US</v6:LocaleCode>
                        </v6:Localization>
                    </v6:TransactionDetail>
                    <v6:Version>
                        <v6:ServiceId>trck</v6:ServiceId>
                        <v6:Major>6</v6:Major>
                        <v6:Intermediate>0</v6:Intermediate>
                        <v6:Minor>0</v6:Minor>
                    </v6:Version>
                    <v6:PackageIdentifier>
                        <v6:Value>'.$tracking_number.'</v6:Value>
                        <v6:Type>TRACKING_NUMBER_OR_DOORTAG</v6:Type>
                    </v6:PackageIdentifier>
                </v6:TrackRequest>
                </soapenv:Body>
                </soapenv:Envelope>';:Header/>
                <soapenv:Body>
                <v6:TrackRequest>
                    <v6:WebAuthenticationDetail>
                        <v6:UserCredential>
                            <v6:Key>'.fedex_accesskey.'</v6:Key>
                            <v6:Password>'.fedex_password.'</v6:Password>
                        </v6:UserCredential>
                    </v6:WebAuthenticationDetail>
                    <v6:ClientDetail>
                        <v6:AccountNumber>'.fedex_account.'</v6:AccountNumber>
                        <v6:MeterNumber>'.fedex_meter.'</v6:MeterNumber>
                        <v6:IntegratorId></v6:IntegratorId>
                        <v6:Localization>
                            <v6:LanguageCode>EN</v6:LanguageCode>
                            <v6:LocaleCode>US</v6:LocaleCode>
                        </v6:Localization>
                    </v6:ClientDetail>
                    <v6:TransactionDetail>
                        <v6:CustomerTransactionId>Track By Number</v6:CustomerTransactionId>
                        <v6:Localization>
                        <v6:LanguageCode>EN</v6:LanguageCode>
                        <v6:LocaleCode>US</v6:LocaleCode>
                        </v6:Localization>
                    </v6:TransactionDetail>
                    <v6:Version>
                        <v6:ServiceId>trck</v6:ServiceId>
                        <v6:Major>6</v6:Major>
                        <v6:Intermediate>0</v6:Intermediate>
                        <v6:Minor>0</v6:Minor>
                    </v6:Version>
                    <v6:PackageIdentifier>
                        <v6:Value>'.$tracking_number.'</v6:Value>
                        <v6:Type>TRACKING_NUMBER_OR_DOORTAG</v6:Type>
                    </v6:PackageIdentifier>
                </v6:TrackRequest>
                </soapenv:Body>
                </soapenv:Envelope>';

所有值都被正确交换,我收到了 FedEx 的成功回复。问题是响应只有一个跟踪事件。该事件似乎是 FedEx 的最后一次跟踪更新(在本例中为交货时间、日期和地址),但在此过程中未显示任何跟踪事件。

这是我得到的回复:Pastebin

可以看到,包裹状态是投递,投递地址列在,但产地和沿途步骤都没有。有关如何获取所有跟踪信息而不仅仅是最新步骤的任何建议?帮助表示赞赏。

4

4 回答 4

2

您缺少将IncludeDetailedScans元素设置为true 。下面是一个 SOAP 信封的示例:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <TrackRequest xmlns="http://fedex.com/ws/track/v6">
      <WebAuthenticationDetail>
        <CspCredential>
          <Key>CSP_KEY</Key>
          <Password>CSP_PASSWORD</Password>
        </CspCredential>
        <UserCredential>
          <Key>DEVELOPER_KEY</Key>
          <Password>DEVELOPER_PASSWORD</Password>
        </UserCredential>
      </WebAuthenticationDetail>
      <ClientDetail>
        <AccountNumber>ACCOUNT_NUMBER</AccountNumber>
        <MeterNumber>METER_NUMBER</MeterNumber>
        <ClientProductId>CLIENT_PRODUCT_ID</ClientProductId>
        <ClientProductVersion>CLIENT_PRODUCT_VERSION</ClientProductVersion>
      </ClientDetail>
      <Version>
        <ServiceId>trck</ServiceId>
        <Major>6</Major>
        <Intermediate>0</Intermediate>
        <Minor>0</Minor>
      </Version>
      <PackageIdentifier>
        <Value>TRACKING_NUMBER</Value>
        <Type>TRACKING_NUMBER_OR_DOORTAG</Type>
      </PackageIdentifier>
      <IncludeDetailedScans>true</IncludeDetailedScans>
    </TrackRequest>
  </soap:Body>
</soap:Envelope>

请注意,上一个请求仅在您属于 FedEx CSP 计划时才有效,如果您不属于,则下面的代码适合您:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <TrackRequest xmlns="http://fedex.com/ws/track/v6">
      <WebAuthenticationDetail>
        <UserCredential>
          <Key>DEVELOPER_KEY</Key>
          <Password>DEVELOPER_PASSWORD</Password>
        </UserCredential>
      </WebAuthenticationDetail>
      <ClientDetail>
        <AccountNumber>ACCOUNT_NUMBER</AccountNumber>
        <MeterNumber>METER_NUMBER</MeterNumber>
      </ClientDetail>
      <Version>
        <ServiceId>trck</ServiceId>
        <Major>6</Major>
        <Intermediate>0</Intermediate>
        <Minor>0</Minor>
      </Version>
      <PackageIdentifier>
        <Value>TRACKING_NUMBER</Value>
        <Type>TRACKING_NUMBER_OR_DOORTAG</Type>
      </PackageIdentifier>
      <IncludeDetailedScans>true</IncludeDetailedScans>
    </TrackRequest>
  </soap:Body>
</soap:Envelope>

最好的!

于 2013-07-16T13:24:01.417 回答
2

对于版本 8,您需要添加以下标签,几乎在 XML 请求的最底部,就在关闭“TrackRequest”标签的正上方:

<ProcessingOptions>INCLUDE_DETAILED_SCANS</ProcessingOptions>
于 2014-04-15T20:30:18.647 回答
0

我在 FedEx 文档中找到了隐藏的解决方案。提供 1 以获得完整的历史记录。此值默认为 false 并省略所有重要的跟踪信息。

于 2013-07-15T15:23:01.527 回答
0

我知道这个问题不是针对 .NET 的,但如果有人来到这里(像我一样)寻找这个问题的 .NET 特定答案,这里是:

Dim request As New TrackRequest()
Dim options(0) As TrackRequestProcessingOptionType

options(0) = TrackRequestProcessingOptionType.INCLUDE_DETAILED_SCANS
request.ProcessingOptions = options
于 2018-07-17T16:08:03.563 回答