我有一个工作请求,需要使用标准 Fedex 费率获取我的货件费率,但我想使用特殊的 Fedex One Rate 选项,以便我可以获得他们的统一费率报价。
不幸的是,他们的代码示例没有显示如何指定速率请求应该使用 Fedex One Rate,而且我完全无法通过 WSDL 的 xml 呕吐物进行解析。我尝试了几种不同的数组结构来传递(我假设的)是正确的变量,但没有任何效果。
我使用 3rd 方生成器生成了 WSDL 的两个 html 版本(两者都非常有用,但也许您可以比我更好地阅读它们)。
第一个直接包括 wsdl,数据类型链接到它们的定义:http : //inadaydevelopment.com/stackoverflow/fedex/RateService_v16.html
第二个更基本,它只是以更线性的方式提供层次结构,每个级别的有效值:http : //inadaydevelopment.com/stackoverflow/fedex/RateService_v16_other.html
据我所知,有两种方式/地方我可以声明我希望我的费率报价使用一种费率:
1) $request['VariableOptions'] = 'FEDEX_ONE_RATE';
Run Code Online (Sandbox Code Playgroud)
和
2) $request['RequestedShipment']['SpecialServicesRequested'] = array(
'SpecialServiceTypes' => array('FEDEX_ONE_RATE')
);
Run Code Online (Sandbox Code Playgroud)
当我使用 (1) 时,我得到一个包含价格列表的成功响应,但它们不是 One Rate 价格。它们是标准价格。
当我使用 (2) 时,我收到失败响应:
stdClass Object
(
[HighestSeverity] => WARNING
[Notifications] => stdClass Object
(
[Severity] => WARNING
[Source] => crs
[Code] => 556
[Message] => There are no valid services available.
[LocalizedMessage] => There are no valid services available.
)
[TransactionDetail] => stdClass Object
(
[CustomerTransactionId] => *** Service Availability Request v5.1 using PHP ***
)
[Version] => stdClass Object
(
[ServiceId] => crs
[Major] => 16
[Intermediate] => 0
[Minor] => 0
)
)
Run Code Online (Sandbox Code Playgroud)
如果我同时使用 (1) 和 (2),那么我会收到 (2) 错误消息以及附加警告,指出我以两种不同的方式指定了一种速率,并且 (2) 将覆盖 (1)。
这是我的完整请求数组:
array (
'WebAuthenticationDetail' =>
array (
'UserCredential' =>
array (
'Key' => 'xxx',
'Password' => 'xxx',
),
),
'ClientDetail' =>
array (
'AccountNumber' => 'xxx',
'MeterNumber' => 'xxx',
),
'TransactionDetail' =>
array (
'CustomerTransactionId' => ' *** Service Availability Request v5.1 using PHP ***',
),
'Version' =>
array (
'ServiceId' => 'crs',
'Major' => '16',
'Intermediate' => '0',
'Minor' => '0',
),
'ReturnTransitAndCommit' => true,
'RequestedShipment' =>
array (
'DropoffType' => 'STATION',
'ShipTimestamp' => '2015-06-14T14:13:46-07:00',
'Shipper' =>
array (
'Contact' =>
array (
'PersonName' => 'Kenny Wyland',
'CompanyName' => 'K2 Cashflow',
'PhoneNumber' => 'xxxxxxxxxx',
),
'Address' =>
array (
'StreetLines' =>
array (
0 => 'xxxx E xxxxx St',
),
'City' => 'Long Beach',
'StateOrProvinceCode' => 'CA',
'PostalCode' => '90805',
'CountryCode' => 'US',
),
),
'Recipient' =>
array (
'Contact' =>
array (
'PersonName' => 'Bob Smith',
'PhoneNumber' => 'xxx-xxx-xxxx',
),
'Address' =>
array (
'StreetLines' =>
array (
0 => 'xxxxx xxxxxxx Rd',
),
'City' => 'Corona',
'StateOrProvinceCode' => 'CA',
'PostalCode' => '92883',
'CountryCode' => 'US',
'Residential' => true,
),
),
'ShippingChargesPayment' =>
array (
'PaymentType' => 'SENDER',
'Payor' =>
array (
'ResponsibleParty' =>
array (
'AccountNumber' => 'xxxx',
'Contact' => NULL,
'Address' =>
array (
'CountryCode' => 'US',
),
),
),
),
'PackageCount' => '1',
'RequestedPackageLineItems' =>
array (
0 =>
array (
'SequenceNumber' => 1,
'GroupPackageCount' => 1,
'Weight' =>
array (
'Value' => 0.01,
'Units' => 'LB',
),
),
),
'SpecialServicesRequested' =>
array (
'SpecialServiceTypes' =>
array (
0 => 'FEDEX_ONE_RATE',
),
),
),
)
Run Code Online (Sandbox Code Playgroud)
文档https://www.fedex.com/templates/components/apps/wpor/secure/downloads/pdf/201408/RateServicesWSDLGuide_v2014.pdf的第 2.4.4 点指出,获得单一费率定价有几个要求:
- 指定“FEDEX_ONE_RATE”ShipmentSpecialService。
您已经拥有的(您使用的那个在 FedEx Freight Priority 和 FedEx Freight Economy 第 2.2.4.1 点中指定)。
下一个要求:
- 指定以下包装类型之一:
FEDEX_SMALL_BOX
....
在代码中应该是:
$request['RequestedShipment']['PackagingType'] = 'FEDEX_SMALL_BOX';
Run Code Online (Sandbox Code Playgroud)
接下来是第三个要求:
- 指定美国始发地和美国目的地。
您的代码中已经有了。
第四个要求:
- 指定以下 FedEx Express 服务之一:
第一夜
...
代码如下:
$request['RequestedShipment']['ServiceType'] = 'FIRST_OVERNIGHT';
Run Code Online (Sandbox Code Playgroud)
另外,请注意最后的注释:
*注:Web 服务客户端可以通过在 RateRequest.variableOptions 中将“FEDEX_ONE_RATE”指定为 ServiceOptionType,在单个 RateRequest 中请求单一费率和基于重量(非单一费率)的费率。