繁体   English   中英

使用Fedex API RateService指定Fedex One Rate的数组结构

[英]Array structure to specify Fedex One Rate using Fedex API RateService

我有一个工作要求,使用标准的Fedex费率来获取我的货件的费率,但我想使用特殊的Fedex One Rate选项,以便我可以获得他们的统一费率报价。

不幸的是,他们的代码示例没有显示如何指定Rate Request应该使用Fedex One Rate,而且我已经完全无法在心理上解析WSDL的xml呕吐。 我尝试了几种不同的数组结构(我假设)是正确的变量,但没有任何作用。

我使用第三方生成器生成了两个html版本的WSDL(两者都不是非常有用,但也许你可以比我更好地阅读它们)。

第一个包含wsdl直接链接到其定义的数据类型: http//inadaydevelopment.com/stackoverflow/fedex/RateService_v16.html

第二个是更基本的,它只是以更线性的方式提供层次结构,每个级别都有有效值: http//inadaydevelopment.com/stackoverflow/fedex/RateService_v16_other.html

据我所知,我可以通过两种方式/地方声明我希望我的报价使用单一费率:

1) $request['VariableOptions'] = 'FEDEX_ONE_RATE';

2) $request['RequestedShipment']['SpecialServicesRequested'] = array(
    'SpecialServiceTypes' => array('FEDEX_ONE_RATE')
);

当我使用(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
        )

)

如果我同时使用(1)和(2),那么我得到(2)错误消息以及另外一个警告,说我以两种不同的方式指定了One Rate,而(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',
      ),
    ),
  ),
)

文件https://www.fedex.com/templates/components/apps/wpor/secure/downloads/pdf/201408/RateServicesWSDLGuide_v2014.pdf ,第2.4.4点指出,要获得单一费率定价有几个要求:

  1. 指定“FEDEX_ONE_RATE”ShipmentSpecialService。

您已经拥有的(您使用的那个在FedEx Freight Priority和FedEx Freight Economy中指定,点2.2.4.1)。

下一个要求:

  1. 指定以下包装类型之一:

FEDEX_SMALL_BOX

....

在代码中它应该是:

$request['RequestedShipment']['PackagingType'] = 'FEDEX_SMALL_BOX';

之后是第3个要求:

  1. 指定美国原产地和美国目的地。

您已在代码中使用的内容。

第四个要求:

  1. 指定以下FedEx Express服务之一:

FIRST_OVERNIGHT

...

代码中包含哪些内容:

$request['RequestedShipment']['ServiceType'] = 'FIRST_OVERNIGHT';

另外,请注意最后的注释:

*注意:通过在RateRequest.variableOptions中将“FEDEX_ONE_RATE”指定为ServiceOptionType,Web服务客户端可以在单个RateRequest中请求单速率和基于权重(非单速率)速率。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM