2012-01-05 24 views
5

FedEx ile bir web sitesini PHP kullanarak entegre etmem istendi. Nereden başlayacağım ile ilgili hiç bir fikrim yok. Bir test hesabı için kaydoldum ve tek örnek kodu indirdim. Bu, .wsdl dosyasına başvuruda bulunur, ancak örnek kod aslında dosyayı içermez. Bu dosyayı nereden alacağınızı belgede hiçbir yerde bulamıyorum. Biri yardım edebilir mi? Bu hafta API ile bir bağlantı kurabildiysem mutlu olurum.FEDEX Web Hizmetleri wsdl dosyası

// 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); 
} 

?> 

cevap

2

Bu wsdl çekebilir: https://github.com/timborden/fedex/blob/master/wsdl/LocatorService_v2.wsdl

Ama Fedex Belgeler üzerinde daha resmi indirme bağlantısını olmalıdır.

Kod örneği, iyi bir btw, ini_set ("soap.wsdl_cache_enabled", "0") değil; kaldırılmalıdır (performans sorunları) ama en azından bir PHP istemcisi (fedex-common) var! Oranı satırda https://www.fedex.com/wpor/web/jsp/drclinks.jsp?links=wss/getstarted.html

Seç PHP ve belgeleri Dahil Et'i: FedEx

+3

FYI: github repo silindi. WSDL'leri şu adreste bulabilirsiniz: http://www.fedex.com/us/developer/ ve yeni Kohana modülü şu adreste bulunabilir: https://github.com/timborden/kohana-fedex (WSDL'ler olmadan) – timborden

1

Girişi sonra buraya gidin. Biri WSDL olan 2 zip dosyasını kaydetmeniz istenecektir.

+0

Dahil Et "Tümünü indir" seçeneğinin yanındaki dokümantasyon, gerçek WSDL'leri bulmanın tek yoluydu –