通过 WSDL/SOAP 使用 Fedex Web 服务时出现的问题
我下载了示例代码以从联邦快递网站请求费率...我将 WSDL 文件放在正确的位置,我有我的帐号、密码、电表号码和密钥。当我运行脚本时,我收到此错误:
处理交易时出错。
错误
教授
1000
身份验证失败
他们提供的脚本如下,是的,我确实替换了它所说的所有地方的 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,
'Units' => 'LB'),
'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 类型的东西吗?
I downloaded the sample code to request a rate from fedex's website... i placed the WSDL file in the proper location, I have my acct number, password, meter number, and key. When I run the script I get this error:
Error in processing transaction.
ERROR
prof
1000
Authentication Failed
The script they give is as follows, and yes i do actually replace the XXX and YYY everywhere it says.:
<?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,
'Units' => 'LB'),
'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);
}
?>
I am not quite sure why it isn't working, i've read about using a proxy, but I am not quite sure how i would use it in this case? Isn't the point of using SOAP and WSDL to avoid using CURL, Direct Connect type stuff?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
同意阿迪亚·库马尔的观点,
或者检查底部的 wsdl 文件。有一个代码
将其更改为
Agree with Aditya Kumar,
or check in your wsdl file at bottom. there is a code
change it to
我也遇到了同样的问题,我输入了用于登录的密码,但我们需要输入密码,该密码将在通过联邦快递注册测试帐户信息后发送到您的电子邮件地址:
请确保您输入的值以下输入正确的是:
I Was also having the Same issue, i was entering the password which i was using to login, but we need to enter the password which will be sent your email address after registering for the test account information with FEDEX:
Please make sure the values you have entered below are correct:
如果您使用 SoapUI ( http://www.soapui.org/ ) 联系 WSDL,那么什么是你得到什么回应?
(SoapUI 使您无需编程即可测试 SOAP/Wsdl,因此您可以检查调用是否正确,如果正确,则问题出在您的代码中。)
If you use SoapUI ( http://www.soapui.org/ ) to contact the WSDL, what is the response you get?
(SoapUI enables you to test SOAP/Wsdl's without programming, so you can check if the calls are correct, if they are, then the problem is in your code.)
编辑 fedex-common.php5 文件,将以下参数中的“XXX”替换为您的信息
希望这对某人有帮助。
Edit fedex-common.php5 file replace 'XXX' with your info in the following params
Hope this helps someone.
在库文件 fedex-common.php5 中将以下字段更改为提供的凭据:
在 wsdlfile ShipService_v*.wsdl 中更改以下内容:
希望它对您有用。
in library file fedex-common.php5 change following fields to provided credentials:
in wsdlfile ShipService_v*.wsdl change following thing:
Hope it'll work for you.
我之前就遇到过这个问题,在与联邦快递技术人员讨论后终于找到了解决方案。看看为什么我们会遇到这样的错误,都是因为我们从开发者网站生成的开发者测试帐户。我们应该记住的一件事是,测试帐号以“6”是生产和制造以“5”开头的密钥是正确的测试密钥。因此,当您遇到错误代码 1000 的身份验证问题时,请检查您的测试密钥。
除此之外的另一个原因可能是您的 Fedex Web 服务端点与 ex“https://wsbeta.fedex.com/web-services/track",这是沙盒模式网址,在生产环境 url 应类似于“https://ws.fedex.com/web-services/track ”。生产 URL 中没有“测试版”模式,因此请检查端点。
I faced this issue from earlier and found solution finally after a discussion with FedEx Technical Person.See why we are facing such error all because of Developer Test Account we generated from developer website.One thing we should keep in mind that Test Account Number start with "6" is of Production & Key Start with "5" is Correct Test Key.So Please check your Test Key when you get Authentication problem with Error Code 1000.
Another Reason apart from this is might be your Fedex Webservice endpoint is different like for ex "https://wsbeta.fedex.com/web-services/track", this is Sandbox mode url and in production environment url should be like this "https://ws.fedex.com/web-services/track". There is no "beta" mode in URL for Production,So please check endpoint.