ИБП рейтинг API C# .Net

Я пытаюсь заставить работать API рейтинга UPS, который теперь поддерживает время в пути. У меня последняя версия WSDL (UPS API). Я получаю сообщение об ошибке исключения: "Возникло исключение в результате данных клиента". и я не могу понять, в чем проблема. Примечание. Опция request "Rate" работает без проблем - когда закомментированы данные TimeinTransit и DeliveryInformation.

Что может быть не так? Любая помощь будет оценена, спасибо.

Вот мой код C#:

UPSRateWS.RequestType request = new UPSRateWS.RequestType();
String[] requestOption = { "ratetimeintransit" };
request.RequestOption = requestOption;
request.SubVersion = "1601";

rateRequest.Request = request;

UPSRateWS.ShipmentType shipment = new UPSRateWS.ShipmentType();
UPSRateWS.ShipperType shipper = new UPSRateWS.ShipperType();

UPSRateWS.ShipmentRatingOptionsType shipmentRatingOptions = new 
     UPSRateWS.ShipmentRatingOptionsType();
shipmentRatingOptions.NegotiatedRatesIndicator = "";
shipmentRatingOptions.RateChartIndicator = "";

shipment.ShipmentRatingOptions = shipmentRatingOptions;

UPSRateWS.TimeInTransitRequestType timeInTransit = new 
     UPSRateWS.TimeInTransitRequestType();
UPSRateWS.PickupType pickupInTransitType = new UPSRateWS.PickupType();

pickupInTransitType.Date = "20170414";
pickupInTransitType.Time = "1630";

timeInTransit.Pickup = pickupInTransitType;
timeInTransit.PackageBillType = "02";

shipment.NumOfPieces = "1";

shipment.DeliveryTimeInformation = timeInTransit;

UPSRateWS.ShipmentWeightType shipWeightType = new 
     UPSRateWS.ShipmentWeightType();
shipWeightType.Weight = "10.80";

UPSRateWS.CodeDescriptionType shipWeightUOM = new 
     UPSRateWS.CodeDescriptionType();
shipWeightUOM.Code = "LBS";
shipWeightUOM.Description = "pounds";
shipWeightType.UnitOfMeasurement = shipWeightUOM;
shipment.ShipmentTotalWeight = shipWeightType;

shipper.ShipperNumber = "XXXXXX";

UPSRateWS.AddressType shipperAddress = new UPSRateWS.AddressType();
string testAddr = "7650 Tyler Blvd";
String[] addressLine = { testAddr };
shipperAddress.AddressLine = addressLine;
shipperAddress.City = "Mentor";
shipperAddress.PostalCode = "44060";
shipperAddress.StateProvinceCode = "OH";
shipperAddress.CountryCode = "US";
shipperAddress.AddressLine = addressLine;
shipper.Address = shipperAddress;

shipment.Shipper = shipper;

UPSRateWS.ShipFromType shipFrom = new UPSRateWS.ShipFromType();
UPSRateWS.ShipAddressType shipFromAddress = new UPSRateWS.ShipAddressType();

string testAddr2 = "";
String[] addressLine1 = { testAddr2 };
shipFromAddress.AddressLine = addressLine1;
shipFromAddress.City = "";
shipFromAddress.PostalCode = "45069";
shipFromAddress.StateProvinceCode = "OH";
shipFromAddress.CountryCode = "US";
shipFrom.Address = shipFromAddress;

shipment.ShipFrom = shipFrom;

UPSRateWS.ShipToType shipTo = new UPSRateWS.ShipToType();
UPSRateWS.ShipToAddressType shipToAddress = new UPSRateWS.ShipToAddressType();

string testAddr3 = "7650 Tyler Blvd";
String[] addressLine2 = { testAddr3 };
shipToAddress.AddressLine = addressLine2;
shipToAddress.City = "Mentor";
shipToAddress.PostalCode = "44060";
shipToAddress.StateProvinceCode = "OH";
shipToAddress.CountryCode = "US";
shipToAddress.ResidentialAddressIndicator = "1";
shipTo.Address = shipToAddress;

shipment.ShipTo = shipTo;

UPSRateWS.CodeDescriptionType service = new UPSRateWS.CodeDescriptionType();
service.Code = "03";    
shipment.Service = service;

UPSRateWS.PackageType package = new UPSRateWS.PackageType();
UPSRateWS.PackageWeightType packageWeight = new UPSRateWS.PackageWeightType();
packageWeight.Weight = "10.80";

UPSRateWS.CodeDescriptionType uom = new UPSRateWS.CodeDescriptionType();
uom.Code = "LBS";
uom.Description = "pounds";
packageWeight.UnitOfMeasurement = uom;
package.PackageWeight = packageWeight;

UPSRateWS.CodeDescriptionType packType = new UPSRateWS.CodeDescriptionType();
packType.Code = "02";
package.PackagingType = packType;

UPSRateWS.PackageServiceOptionsType packServType = new 
     UPSRateWS.PackageServiceOptionsType();
UPSRateWS.InsuredValueType insuredValueType = new UPSRateWS.InsuredValueType();
insuredValueType.CurrencyCode = "USD";
insuredValueType.MonetaryValue = "65.75";
packServType.DeclaredValue = insuredValueType;

UPSRateWS.ShipperDeclaredValueType shipperDeclaredValueType = new 
     UPSRateWS.ShipperDeclaredValueType();
shipperDeclaredValueType.CurrencyCode = "USD";
shipperDeclaredValueType.MonetaryValue = "65.75";
packServType.ShipperDeclaredValue = shipperDeclaredValueType;
package.PackageServiceOptions = packServType;

UPSRateWS.PackageType[] pkgArray = { package };
shipment.Package = pkgArray;
rateRequest.Shipment = shipment;

UPSRateWS.CodeDescriptionType pickupType = new UPSRateWS.CodeDescriptionType();
pickupType.Code = "01";
pickupType.Description = "Daily Pickup";
rateRequest.PickupType = pickupType;

UPSRateWS.RateResponse rateResponse = myRatePortTypeClient.ProcessRate(upss, 
     rateRequest);

0 ответов

Вам необходимо включить как параметр "rate", так и параметры "ratetimeintransit":

String[] requestOption = { "rate","ratetimeintransit" };
Другие вопросы по тегам