简体   繁体   English

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

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

I've got a working request to get rates for my shipment using standard Fedex rates, but I want to use the special Fedex One Rate option so that I can get their flat rate quotes. 我有一个工作要求,使用标准的Fedex费率来获取我的货件的费率,但我想使用特殊的Fedex One Rate选项,以便我可以获得他们的统一费率报价。

Unfortunately, their code example doesn't show how to specify the Rate Request should use Fedex One Rate and I've been completely unable to mentally parse through the xml vomit that is WSDL. 不幸的是,他们的代码示例没有显示如何指定Rate Request应该使用Fedex One Rate,而且我已经完全无法在心理上解析WSDL的xml呕吐。 I've tried several different array structures to pass (what I assume) are the right variables, but nothing works. 我尝试了几种不同的数组结构(我假设)是正确的变量,但没有任何作用。

I generated two html versions of the WSDL using 3rd party generators (neither is incredibly helpful, but maybe you can read them better than I). 我使用第三方生成器生成了两个html版本的WSDL(两者都不是非常有用,但也许你可以比我更好地阅读它们)。

The first includes the wsdl directly with data types linked to their definitions: http://inadaydevelopment.com/stackoverflow/fedex/RateService_v16.html 第一个包含wsdl直接链接到其定义的数据类型: http//inadaydevelopment.com/stackoverflow/fedex/RateService_v16.html

The second is more basic, it just provides the hierarchy in a more linear fashion with the valid values at each level: http://inadaydevelopment.com/stackoverflow/fedex/RateService_v16_other.html 第二个是更基本的,它只是以更线性的方式提供层次结构,每个级别都有有效值: http//inadaydevelopment.com/stackoverflow/fedex/RateService_v16_other.html

As far as I can tell, there are two ways/places I can declare that I want my rate quote to use One Rate: 据我所知,我可以通过两种方式/地方声明我希望我的报价使用单一费率:

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

and

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

When I use (1), I get a success response that includes a list of prices, but they aren't the One Rate prices. 当我使用(1)时,我得到一个包含价格清单的成功回复,但它们不是One Rate价格。 They are the standard prices. 它们是标准价格。

When I use (2), I get a fail response: 当我使用(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
        )

)

If I use both (1) and (2), then I get the (2) error message as well as an additional warning saying that I specified One Rate in two different ways and that (2) was going to override (1). 如果我同时使用(1)和(2),那么我得到(2)错误消息以及另外一个警告,说我以两种不同的方式指定了One Rate,而(2)将覆盖(1)。

Here is my full request array: 这是我的完整请求数组:

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',
      ),
    ),
  ),
)

The document https://www.fedex.com/templates/components/apps/wpor/secure/downloads/pdf/201408/RateServicesWSDLGuide_v2014.pdf , point 2.4.4 states that there are several requirements to get One Rate pricing: 文件https://www.fedex.com/templates/components/apps/wpor/secure/downloads/pdf/201408/RateServicesWSDLGuide_v2014.pdf ,第2.4.4点指出,要获得单一费率定价有几个要求:

  1. Specify the "FEDEX_ONE_RATE" ShipmentSpecialService. 指定“FEDEX_ONE_RATE”ShipmentSpecialService。

Which you already have (the one that you use is specified in FedEx Freight Priority and FedEx Freight Economy, point 2.2.4.1). 您已经拥有的(您使用的那个在FedEx Freight Priority和FedEx Freight Economy中指定,点2.2.4.1)。

The next requirement: 下一个要求:

  1. Specify one of the following Packaging Types: 指定以下包装类型之一:

FEDEX_SMALL_BOX FEDEX_SMALL_BOX

.... ....

In code it should be: 在代码中它应该是:

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

After that comes the 3rd requirement: 之后是第3个要求:

  1. Specify a US origin and a US destination. 指定美国原产地和美国目的地。

Which you already have in your code. 您已在代码中使用的内容。

And the 4th requirement: 第四个要求:

  1. Specify one of the following FedEx Express services: 指定以下FedEx Express服务之一:

FIRST_OVERNIGHT FIRST_OVERNIGHT

... ...

Which is in code: 代码中包含哪些内容:

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

Also, pay attention to the note at the end: 另外,请注意最后的注释:

*Note: Web Services clients can request both One Rate and weight-based (non-One Rate) rates in a single RateRequest by specifying "FEDEX_ONE_RATE" as a ServiceOptionType in the RateRequest.variableOptions. *注意:通过在RateRequest.variableOptions中将“FEDEX_ONE_RATE”指定为ServiceOptionType,Web服务客户端可以在单个RateRequest中请求单速率和基于权重(非单速率)速率。

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

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