我尝试使用XML api在项目中实施FedEx Package Tracking。以下是我的跟踪请求:
'<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
如您所见,包裹状态已交付,并且列出了送货地址,但原点和步骤不是。有关如何获取所有跟踪信息而不仅仅是最新步骤的任何建议?帮助赞赏。
答案 0 :(得分:2)
对于版本8,您需要添加以下标记,几乎位于XML请求的最底部,正好在结束&#34; TrackRequest&#34;标记:
<ProcessingOptions>INCLUDE_DETAILED_SCANS</ProcessingOptions>
答案 1 :(得分:1)
您缺少设置 true IncludeDetailedScans 元素。以下是SOAP Envelope的示例:
<?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>
最佳!
答案 2 :(得分:0)
我发现隐藏在FedEx文档中的解决方案。它提供1来获得完整的历史。此值默认为false,并省略所有重要的跟踪信息。
答案 3 :(得分:0)
我知道这个问题不是针对.NET的,但是如果有人(像我一样)来到这里寻找针对该问题的.NET特定答案,那就是:
Dim request As New TrackRequest()
Dim options(0) As TrackRequestProcessingOptionType
options(0) = TrackRequestProcessingOptionType.INCLUDE_DETAILED_SCANS
request.ProcessingOptions = options