2012-01-05 12 views
5

मुझे PHP का उपयोग करके FedEx के साथ एक वेबसाइट को एकीकृत करने के लिए कहा गया है। मैं कहाँ से शुरू करू मुझे पता नहीं है। मैंने एक परीक्षण खाते के लिए साइन अप किया है और मैंने एकमात्र उदाहरण कोड डाउनलोड किया है। यह एक .wsdl फ़ाइल का संदर्भ देता है लेकिन नमूना कोड में वास्तव में फ़ाइल शामिल नहीं होती है। दस्तावेज़ में कहीं भी मुझे यह फ़ाइल नहीं मिल सकती है। क्या कोई मदद कर सकता है? अगर मैं इस सप्ताह कुछ समय में एपीआई से कनेक्शन प्राप्त कर सकता हूं तो मैं खुश रहूंगा।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

लेकिन तुम Fedex प्रलेखन पर एक अधिक आधिकारिक डाउनलोड लिंक होना चाहिए।

कोड उदाहरण अच्छा बीटीडब्ल्यू, ini_set ("soap.wsdl_cache_enabled", "0") नहीं है; हटाया जाना चाहिए (प्रदर्शन समस्याएं) लेकिन कम से कम एक PHP क्लाइंट (फेडेक्स-आम) है! दर पंक्ति में https://www.fedex.com/wpor/web/jsp/drclinks.jsp?links=wss/getstarted.html

करें पीएचपी और चुनें प्रलेखन को शामिल करें:

+3

एफवाईआई: जिथब रेपो हटा दिया गया है। डब्ल्यूएसडीएल यहां पाए जा सकते हैं: http://www.fedex.com/us/developer/ और नया कोहाना मॉड्यूल यहां पाया जा सकता है: https://github.com/timborden/kohana-fedex (WSDLs के बिना) – timborden

1

FedEx को लॉग इन तो यहाँ जाओ। आपको 2 ज़िप फ़ाइलों को सहेजने के लिए कहा जाएगा, जिनमें से एक डब्लूएसडीएल है।

+0

चेकिंग शामिल करना "सभी डाउनलोड करें" विकल्प के बगल में प्रलेखन एकमात्र तरीका था जिसे मैंने वास्तविक डब्लूएसडीएल पाया –