-->

Fedex Web Services: ERROR 9040 - Can't pull up

2019-02-23 09:34发布

问题:

I'm having issues attempting to pull up tracking info using Fedex's Web Services. I am using a valid tracking number and I'm able to view the details on Fedex's site. However, I get an error 9040 "No information for the following shipments has been received by our system yet. Please try again or contact Customer Service at 1.800.Go.FedEx(R) 800.463.3339." Am I leaving something out?

My code:

<?php

$path_to_wsdl = "URL_TO_WSDL";
ini_set("soap.wsdl_cache_enabled", "0");

$client = new SoapClient($path_to_wsdl, array('trace' => 1));

$request['WebAuthenticationDetail'] = array(
    'UserCredential' =>array(
        'Key' => 'MY_KEY', 
        'Password' => 'MY_PASSWORD'
    )
);
$request['ClientDetail'] = array(
    'AccountNumber' => 'MY_ACCT', 
    'MeterNumber' => 'MY_METER'
);
$request['TransactionDetail'] = array('CustomerTransactionId' => 'ActiveShipping');
$request['Version'] = array(
    'ServiceId' => 'trck', 
    'Major' => '5', 
    'Intermediate' => '0', 
    'Minor' => '0'
);
$request['PackageIdentifier'] = array(
    'Value' => 'TRACKING#',
    'Type' => 'TRACKING_NUMBER_OR_DOORTAG');

$response = $client->track($request);
var_dump($response);


?>

回答1:

Got it!

Call the web services departement and they told me to remove 'beta' from the wsdl file. This appears to be a different address than what I found in responses to this problem before. On line 1507 of the wsdl file, make the following change:

From:

<s1:address location="https://wsbeta.fedex.com:443/web-services/track"/>

To

<s1:address location="https://ws.fedex.com:443/web-services/track"/>

I changed the rest of my code slightly, but that shouldn't have made the difference. To be on the safe side, here it is:

<?php
$path_to_wsdl = "PATH_TO_WSDL_FILE";

$client = new SoapClient($path_to_wsdl, array('trace' => 1));

$trackRequest = array(
    'WebAuthenticationDetail' => array(
        'UserCredential' => array(
            'Key'      => 'MY_KEY',
            'Password' => 'MY_PASSWORD'
        )
    ),
    'ClientDetail' => array(
        'AccountNumber' => 'MY_ACCT_#',
        'MeterNumber'   => 'MY_METER_#'
    ),
    'Version' => array(
        'ServiceId'    => 'trck',
        'Major'        => '5',
        'Intermediate' => '0',
        'Minor'        => '0'
    ),
    'PackageIdentifier' => array(
        'Type'  => 'TRACKING_NUMBER_OR_DOORTAG',
        'Value' => 'THE_TRACKING_#',
    ),
    'CustomerTrasactionId',
    'IncludeDetailedScans' => 1
);
$response = $client->track($trackRequest);
var_dump($response);

?>


回答2:

I'm also working on this same problem. I'm trying several things and you can see if anything works for you. Try including ShipDateRangeBegin and End elements, your test account/payer numbers or destination info. I've found here that switching to xml and ssl post requests supposedly solve the problem, but it's not an option for me. Maybe it will help you?



回答3:

I have same problem when use xml-request. I solved the problem this way:

$endpointurl = "https://gatewaybeta.fedex.com:443/xml"; // remove word "beta"
$endpointurl = "https://gateway.fedex.com:443/xml";

...
$request = stream_context_create($form);
$browser = fopen($endpointurl , 'rb' , false , $request);
$response = stream_get_contents($browser);
...


标签: php soap fedex