gpt4 book ai didi

用于打印多个运输标签的 FedEx Web 服务

转载 作者:行者123 更新时间:2023-12-04 14:43:09 24 4
gpt4 key购买 nike

我正在尝试连接到 FedEx 运输网络服务 v8。

当我只设置一个 RequestedPackageLineItems 时,一切正常。当我添加两个项目时,出现以下错误。

“无效的包裹计数或无效的包裹序列号。”

我的代码如下

ProcessShipmentRequest request = CreatePendingShipmentRequest();
ShipService service = new ShipService();
ProcessShipmentReply reply = service.processShipment(request);
...

private static ProcessShipmentRequest CreatePendingShipmentRequest()
{
ProcessShipmentRequest request = new ProcessShipmentRequest();

request.WebAuthenticationDetail = new WebAuthenticationDetail();
request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential();
request.WebAuthenticationDetail.UserCredential.Key = "XXX";
request.WebAuthenticationDetail.UserCredential.Password = "XXX";
request.ClientDetail = new ClientDetail();
request.ClientDetail.AccountNumber = "XXX";
request.ClientDetail.MeterNumber = "XXX";

request.TransactionDetail = new TransactionDetail();
request.TransactionDetail.CustomerTransactionId = "*** Ground Domestic Shipping Request v8 using C# ***";
request.Version = new VersionId();

//Inside this method I set request.RequestedShipment.PackageCount = "2";
SetShipmentDetails(request);
SetPackageLineItems(request);

return request;
}

private static void SetPackageLineItems(ProcessShipmentRequest request)
{
request.RequestedShipment.RequestedPackageLineItems = new RequestedPackageLineItem[2];
request.RequestedShipment.RequestedPackageLineItems[0] = new RequestedPackageLineItem();
request.RequestedShipment.RequestedPackageLineItems[0].SequenceNumber = "1";
request.RequestedShipment.RequestedPackageLineItems[0].Weight = new Weight();
request.RequestedShipment.RequestedPackageLineItems[0].Weight.Value = 50.0M;
request.RequestedShipment.RequestedPackageLineItems[0].Weight.Units = WeightUnits.LB;
request.RequestedShipment.RequestedPackageLineItems[0].ItemDescription = "Item";
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions = new Dimensions();
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions.Length = "108";
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions.Width = "5";
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions.Height = "5";
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions.Units = LinearUnits.IN;

request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences = new CustomerReference[3];
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[0] = new CustomerReference();
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[0].CustomerReferenceType = CustomerReferenceType.CUSTOMER_REFERENCE;
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[0].Value = "[LOT NUMBER]";
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[1] = new CustomerReference();
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[1].CustomerReferenceType = CustomerReferenceType.INVOICE_NUMBER;
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[1].Value = "45646";
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[2] = new CustomerReference();
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[2].CustomerReferenceType = CustomerReferenceType.P_O_NUMBER;
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[2].Value = "456446";

request.RequestedShipment.RequestedPackageLineItems[1] = new RequestedPackageLineItem();
request.RequestedShipment.RequestedPackageLineItems[1].SequenceNumber = "2";
request.RequestedShipment.RequestedPackageLineItems[1].Weight = new Weight();
request.RequestedShipment.RequestedPackageLineItems[1].Weight.Value = 50.0M;
request.RequestedShipment.RequestedPackageLineItems[1].Weight.Units = WeightUnits.LB;
request.RequestedShipment.RequestedPackageLineItems[1].ItemDescription = "Item";
....
}

最佳答案

了解如何执行此操作。

为了将多个运输标签整合到一个 pdf 中,过程如下。

  • 创建请求
  • 填写发货信息
  • 发布并获得回复。
  • 保存重播和字节数组和 MasterShippingID
  • 创建一个新请求并为其分配主运输 ID。
  • 添加了运输重量和尺寸
  • 发帖得到回复
  • 用另一个
  • 保存字节数组
  • 继续直到生成所有货件(每个主装运 ID 最多 200 个)
  • 将从 FedEx 返回的所有 pdf 合并为一个 pdf。
  • 跳一支快乐的舞。
  • 关于用于打印多个运输标签的 FedEx Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2977956/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com