6

我正在使用 FeDex API 打印运输标签。1 个包裹的标签打印成功,但是当我尝试打印多个包裹时出现错误:

stdClass Object
(
[Severity] => ERROR
[Source] => ship
[Code] => 2463
[Message] => The number of RequestedPackages in the RequestedShipment must be equal to 1
[LocalizedMessage] => The number of RequestedPackages in the RequestedShipment must be    equal to 1
)

在请求中,我包括了 TotalWeight、PackageCount,但它没有帮助

$request['WebAuthenticationDetail'] = array('UserCredential' =>array('Key' => $auth['key'], 'Password' => $auth['password']));
$request['ClientDetail'] = array('AccountNumber' => $auth['accountNumber'], 'MeterNumber' => $auth['meterNumber']);
$request['TransactionDetail'] = array('CustomerTransactionId' => '*** Ground Domestic Shipping Request v12 using PHP ***');
$request['Version'] = array('ServiceId' => 'ship', 'Major' => '12', 'Intermediate' => '1', 'Minor' => '0');
$request['RequestedShipment'] = array('ShipTimestamp' => date('c'),
                                      'DropoffType' => 'REGULAR_PICKUP', // valid values REGULAR_PICKUP, REQUEST_COURIER, DROP_BOX, BUSINESS_SERVICE_CENTER and STATION
                                      'ServiceType' => 'FEDEX_GROUND', // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
                                      'PackagingType' => 'YOUR_PACKAGING', // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
                                      'Shipper' => $this->addShipper(),
                                      'Recipient' => $this->recipient,
                                      'ShippingChargesPayment' => $this->addShippingChargesPayment(),
                                      'LabelSpecification' => $this->addLabelSpecification(), 
                                      'RateRequestTypes' => array('LIST'), // valid values ACCOUNT and LIST
                                      'PackageCount' => count($this->packages),
                                      'TotalWeight' => array('Value' => array_sum($this->packages), 'Units' => 'LB'),
                                      'TotalShipmentWeight' => array('Value' => array_sum($this->packages), 'Units' => 'LB'),
                                      'PackageDetail' => 'INDIVIDUAL_PACKAGES',                                        
                                      'RequestedPackageLineItems' => $this->packageLineItem//array('0' => $this->packageLineItem)
);      


$this->packageLineItem[] = array('SequenceNumber'=>$i,
              'GroupPackageCount' => count($this->packages),
              'MasterTrackingID' => '123123123123',
              'TotalShipmentWeight' => array('Value' => array_sum($this->packages), 'Units' => 'LB'),
              'Weight' => array('Value' => $this->packages[$i-1], //weight!!!!!!!!!!!!!
                                'Units' => 'LB'),
              'CustomerReferences' => array('0' => array('CustomerReferenceType' => 'CUSTOMER_REFERENCE', 
                                                         'Value' => 'GR4567892'), // valid values CUSTOMER_REFERENCE, INVOICE_NUMBER, P_O_NUMBER and SHIPMENT_INTEGRITY
                                            '1' => array('CustomerReferenceType' => 'INVOICE_NUMBER', 
                                                         'Value' => 'INV4567892'),
                                            '2' => array('CustomerReferenceType' => 'P_O_NUMBER', 
                                                         'Value' => 'PO4567892')),
              'SpecialServicesRequested' => array('SpecialServiceTypes' => array('COD'),
                                                  'CodDetail' => array('CodCollectionAmount' => array('Currency' => 'USD', 'Amount' => 150),
                                                                       'CollectionType' => 'ANY')// ANY, GUARANTEED_FUNDS
                                                 )
 );

有谁知道如何成为一个有效的请求?

4

3 回答 3

19

FedEx Rate APIFedEx Shipping API之间存在差异。您可以使用一个 SOAP 请求对多个包进行评级;但是,要运送多件货件 (MPS),您必须为每个包裹执行运送请求。

第一个包裹(第一个请求中的包裹)将是您的Master,其中包含主跟踪号。获得此主跟踪号后,您必须将其附加到剩余包裹的运输请求中。请参阅最新的FedEx 开发人员指南,了解有关 MPS 货件的更多信息,并从 FedEx 开发人员门户下载执行快递国内 MPS 货件的示例。

需要注意的是,运输过程不会作为交易发生,所以如果您尝试运输 3 个包裹,并且包裹 1 和 2 都提交成功,但包裹 3 未知原因失败,您有责任取消包裹1 和 2 或重新提交包裹 3。我建议任何人在创建实际货件之前验证货件(使用相同的运输 API)。

最好的!

于 2013-05-09T04:59:20.777 回答
1

FeDex 手册有错误:“MasterTrackingID”错误。“MasterTrackingId”是对的。

于 2013-03-22T08:24:14.643 回答
0

我已经在测试服务器上安装了 MPS。我正在使用 python 和这个可爱的 wrapper,所以它不是一个完整的 SOAP 编写,但是......发货基本上是:

SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP- ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:m0="http://fedex.com/ws/ship/v25">
<SOAP-ENV:Body>
<ProcessShipmentRequest xmlns="http://fedex.com/ws/ship/v25">
<WebAuthenticationDetail> <ParentCredential>
<Key>Hb1TfWMygUh7bbHP</Key>
<Password>u0mnYl8d6FRQK5Ot8SyxMXVqq</Password> </ParentCredential>
<UserCredential>
<Key>INPUT YOUR INFORMATION</Key>
<Password> INPUT YOUR INFORMATION </Password> </UserCredential>
</WebAuthenticationDetail> <ClientDetail>
<AccountNumber>XXXXXXXXX</AccountNumber>
<MeterNumber>XXXXXX</MeterNumber> </ClientDetail>
<TransactionDetail>
<CustomerTransactionId>ProcessShipmentRequest_2264</CustomerTransactionId> </TransactionDetail>
<Version>
<ServiceId>ship</ServiceId> <Major>25</Major> <Intermediate>0</Intermediate>
<Minor>0</Minor> </Version> <RequestedShipment>

无论需要什么关闭,我们都有基本的装运废话,然后......

shipment.RequestedShipment.TotalWeight.Value
shipment.RequestedShipment.TotalWeight.Units
shipment.RequestedShipment.PackageCount

在您的第一批货物中。在该装运请求中包含您的第一个包裹,但包括SequenceNumber = 1

<RequestedPackageLineItems>
<SequenceNumber>1</SequenceNumber> 
<Weight>
<Units>LB</Units>
<Value>20.0</Value> 
</Weight> 
<Dimensions>
<Length>12</Length> 
<Width>12</Width> 
<Height>12</Height> 
<Units>IN</Units>
</Dimensions> 
</RequestedPackageLineItems>

提交带有包裹请求的货件。在该货件的回复中,您将收到CompletedShipmentDetail.MasterTrackingId. 在随后的发货中,您只需像往常一样形成它们,除了,您将包括一个

RequestedShipment.MasterTrackingId.TrackingIdType

RequestedShipment.MasterTrackingId.MasterTrackingId

哪里MasterTrackingId是从第一批货物中取出的;WDSL 将具有TrackingIdType. 我认为只使用“FEDEX”就可以了。货件重量和包裹计数将与普通货件一样——包裹重量和 1。包裹行项目的编号将递增,直到您达到PackageCount.

我希望这会增加@Ozzy Garcia 的答案!他们肯定比 FedEx 的文档更清楚地说明了这一点!

于 2021-11-10T17:49:56.113 回答