繁体   English   中英

联邦快递 API。 运输标签。 多件包裹运输

[英]Fedex API. Shipping Label. Multiple-Package Shipments

我正在使用 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
                                                 )
 );

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

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

第一包装(封装在第一请求中),将包含主跟踪号的母版 获得此主跟踪号后,您必须将其附加到剩余包的运送请求中。 请参阅最新的FedEx开发者指南 ,了解有关MPS货件的更多信息,并下载从FedEx开发人员门户网站执行Express国内MPS货件的示例。

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

最好!

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

我有一个 MPS 在测试服务器上工作。 我正在使用 python 和这个可爱的包装器,所以它不是一个完整的 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列表。 我认为只使用“联邦快递”就可以了。 货件重量和包裹数量将与普通货件一样——包裹重量和 1。包裹行项目的编号将增加,直到您达到PackageCount

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

暂无
暂无

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

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