Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FedEx XML Api Tracking Request Issues

Tags:

php

xml

fedex

I'm attempting to implement FedEx Package Tracking in a project using the XML api. The following is my tracking request:

'<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>';

All values are being swapped in correctly, and I am getting a success response back from FedEx. The issue is the response only has one tracking event. The event appears to be the last tracking update from FedEx (in this case, delivery time, date, and address) but is not showing any tracking events along the way.

Here is the response I get: Pastebin

As you can see, the package status is delivered, and the delivery address is listed in , but the origin and the steps along the way are not. Any suggestions on how to get all the tracking info and not just the most recent step? Help appreciated.

like image 479
carbide20 Avatar asked Apr 07 '26 20:04

carbide20


2 Answers

You were missing to set to true the IncludeDetailedScans element. Here is an example of a 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>

Note that the previous request is only valid if you belong to the FedEx CSP program, if you don't, the code below is the right one for your:

<?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>

Best!

like image 174
Ozzy Garcia Avatar answered Apr 09 '26 11:04

Ozzy Garcia


For Version 8, you need to add the following tag, almost at the very bottom of the XML request, right above the closing "TrackRequest" tag:

<ProcessingOptions>INCLUDE_DETAILED_SCANS</ProcessingOptions>
like image 36
Nikita 웃 Avatar answered Apr 09 '26 12:04

Nikita 웃



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!