php – 通过WSDL / SOAP使用Fedex Webservice的问题

前端之家收集整理的这篇文章主要介绍了php – 通过WSDL / SOAP使用Fedex Webservice的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我下载了示例代码以从fedex的网站请求一个费率…我把WSDL文件放在正确的位置,我有我的acct号码,密码,米数和密钥.当我运行脚本我得到这个错误

Error in processing transaction.
ERROR
prof
1000
Authentication Failed

他们给出的脚本如下,是的,我实际上替换了XXX和YYY:

<?PHP

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

require_once('fedex-common.PHP5');

$newline = "<br />";
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "RateService_v7.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' => 'XXX','Password' => 'YYY')); // Replace 'XXX' and 'YYY' with FedEx provided credentials 
$request['ClientDetail'] = array('AccountNumber' => 'XXX','MeterNumber' => 'YYY');// Replace 'XXX' with your account and meter number
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request v7 using PHP ***');
$request['Version'] = array('ServiceId' => 'crs','Major' => '7','Intermediate' => '0','Minor' => '0');
$request['ReturnTransitAndCommit'] = true;
$request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP'; // valid values REGULAR_PICKUP,REQUEST_COURIER,...
$request['RequestedShipment']['ShipTimestamp'] = date('c');
$request['RequestedShipment']['ServiceType'] = 'FEDEX_GROUND'; // valid values STANDARD_OVERNIGHT,PRIORITY_OVERNIGHT,FEDEX_GROUND,...
$request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_Box,FEDEX_PAK,FEDEX_TUBE,YOUR_PACKAGING,...
$request['RequestedShipment']['Shipper'] = array('Address' => array(
                                          'StreetLines' => array('10 Fed Ex Pkwy'),// Origin details
                                          'City' => 'Memphis','StateOrProvinceCode' => 'TN','PostalCode' => '38115','CountryCode' => 'US'));
$request['RequestedShipment']['Recipient'] = array('Address' => array (
                                               'StreetLines' => array('13450 Farmcrest Ct'),// Destination details
                                               'City' => 'Herndon','StateOrProvinceCode' => 'VA','PostalCode' => '20171','CountryCode' => 'US'));
$request['RequestedShipment']['ShippingChargesPayment'] = array('PaymentType' => 'SENDER','Payor' => array('AccountNumber' => 'XXX',// Replace 'XXX' with payor's account number
                                                                     'CountryCode' => 'US'));
$request['RequestedShipment']['RateRequestTypes'] = 'ACCOUNT'; 
$request['RequestedShipment']['RateRequestTypes'] = 'LIST'; 
$request['RequestedShipment']['PackageCount'] = '2';
$request['RequestedShipment']['PackageDetailSpecified'] = true;
$request['RequestedShipment']['PackageDetail'] = 'INDIVIDUAL_PACKAGES';  //  Or PACKAGE_SUMMARY
$request['RequestedShipment']['RequestedPackageLineItems'] = array('0' => array('Weight' => array('Value' => 2.0,'Units' => 'LB'),'Dimensions' => array('Length' => 10,'Width' => 10,'Height' => 3,'Units' => 'IN')),'1' => array('Weight' => array('Value' => 5.0,'Dimensions' => array('Length' => 20,'Width' => 20,'Height' => 10,'Units' => 'IN')));
try 
{
    $response = $client ->getRates($request);

    if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR')
    {
        printRequestResponse($client);
    }
    else
    {
        echo 'Error in processing transaction.'. $newline. $newline; 
        foreach ($response -> Notifications as $notification)
        {           
            if(is_array($response -> Notifications))
            {              
               echo $notification -> Severity;
               echo ': ';           
               echo $notification -> Message . $newline;
            }
            else
            {
                echo $notification . $newline;
            }
        } 
    } 

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

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

?>

我不太清楚为什么它不工作,我已经阅读了关于使用代理,但我不太确定我将如何使用它在这种情况下?不是使用SOAP和WSDL避免使用CURL,Direct Connect类型的东西?

如果您使用SoapUI( http://www.soapui.org/)联系WSDL,您将获得什么响应?

(SoapUI可以让您无需编程就可以测试SOAP / Wsdl,因此您可以检查调用是否正确,如果是,则代码中出现问题.)

猜你在找的PHP相关文章