2012-01-05 79 views
5

我被要求将一个网站与使用PHP的FedEx集成。我不知道从哪里开始。我已经注册了一个测试帐户,并且下载了唯一的示例代码。这引用了一个.wsdl文件,但示例代码实际上并不包含该文件。我无法在文档的任何地方找到获取此文件的位置。谁能帮忙?如果我可以在本周的某个时候获得API的连接,我会很高兴。FEDEX网络服务wsdl文件

// Copyright 2009, FedEx Corporation. All rights reserved. 
// Version 2.0.0 

require_once('../library/fedex-common.php5'); 


//The WSDL is not included with the sample code. 
//Please include and reference in $path_to_wsdl variable. 
$path_to_wsdl = "../wsdl/LocatorService_v2.wsdl"; 

ini_set("soap.wsdl_cache_enabled", "0"); 

$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information 

$request['WebAuthenticationDetail'] = array('UserCredential' => 
                 array('Key' => getProperty('key'), 'Password' => getProperty('password'))); 
$request['ClientDetail'] = array('AccountNumber' => getProperty('shipaccount'), 'MeterNumber' => getProperty('meter')); 
$request['TransactionDetail'] = array('CustomerTransactionId' => '*** Locator Request v2 using PHP ***'); 
$request['Version'] = array('ServiceId' => 'dloc', 'Major' => '2', 'Intermediate' => '0', 'Minor' => '0'); 

$bNearToPhoneNumber = false; 
if ($bNearToPhoneNumber) 
{ 
    $request['NearToPhoneNumber'] = getProperty('phonenumber'); // Replace 'XXX' with phone number 
} 
else 
{ 
    $request['NearToAddress'] = getProperty('locatoraddress'); 
} 

$request['DropoffServicesDesired'] = array('Express' => 1, // Location desired services 
                    'FedExStaffed' => 1, 
                    'FedExSelfService' => 1, 
                    'FedExAuthorizedShippingCenter' => 1, 
                    'HoldAtLocation' => 1); 

try 
{ 
    if(setEndpoint('changeEndpoint')) 
    { 
     $newLocation = $client->__setLocation(setEndpoint('endpoint')); 
    } 

    $response = $client ->fedExLocator($request); 

    if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR') 
    { 
     echo 'Dropoff Locations<br>'; 
     echo '<table border="1"><tr><td>Streetline</td><td>City</td><td>State</td><td>Postal Code</td><td>Distance</td></tr>'; 
     foreach ($response -> DropoffLocations as $location) 
     { 
      if(is_array($response -> DropoffLocations)) 
      {    
       echo '<tr>'; 
       echo '<td>'.$location -> BusinessAddress -> StreetLines. '</td>'; 
       echo '<td>'.$location -> BusinessAddress -> City. '</td>'; 
       echo '<td>'.$location -> BusinessAddress -> StateOrProvinceCode. '</td>'; 
       echo '<td>'.$location -> BusinessAddress -> PostalCode. '</td>'; 
       echo '<td>('.$location -> Distance -> Value . ' '; 
       echo $location -> Distance -> Units . ')'. '</td>'; 
       echo '</tr>'; 
      } 
      else 
      { 
       //echo $location . Newline; 
      } 
     } 
     echo '</table>'; 
     printSuccess($client, $response); 
    } 
    else 
    { 
     printError($client, $response); 
    } 

    writeToLog($client); // Write to log file 

} catch (SoapFault $exception) { 
    printFault($exception, $client); 
} 

?> 

回答

2

这可能是您的WSDL:https://github.com/timborden/fedex/blob/master/wsdl/LocatorService_v2.wsdl

但是,你应该对联邦快递的文档更官方下载链接。代码示例不是那么好btw,ini_set(“soap.wsdl_cache_enabled”,“0”);代码示例不是那么好btw,ini_set(“soap.wsdl_cache_enabled”,“0”);代码示例不是那么好btw,ini_set(“soap.wsdl_cache_enabled”,“0”);应该是删除(性能问题),但至少有一个PHP客户端(fedex-common)!

+3

仅供参考:github回购已被删除。 WSDLs可以在这里找到:http://www.fedex.com/us/developer/和新的Kohana模块可以在这里找到:https://github.com/timborden/kohana-fedex(没有WSDLs) – timborden 2012-01-31 15:59:39