我正在尝试使用freightquote.com 的API。为此,我使用了一个扩展 SOAP 的类,您可以在此处看到<--cudos 给作者。我用来拨打电话的代码可以在下面找到
$this->load->library('QuoteService');
try
{
$client = new QuoteService();
$user = new UserCredential();
$user->Name = 'example@example.com';
$user->Password = 'password';
$add = new PostalAddress();
$add->AddressName = 'home';
$add->City = 'Fond du Lac';
$add->PostalCode = '54922';
$add->StateCode = 'WI';
$add->StreetAddress = 'W4709 Main St.';
$add->CountryCode = 'US';
$loc = new Location();
$loc->HasLoadingDock = 1;
$loc2->LocationType = LocationTypeList::Origin;
$loc->HasDeliveryAppointment = 1;
$loc->LocationAddress = $add;
$add2 = new PostalAddress();
$add2->AddressName = 'dropoff';
$add2->City = 'Oshkosh';
$add2->PostalCode = '54901';
$add2->StateCode = 'WI';
$add2->StreetAddress = '424 Washington Ave.';
$add2->CountryCode = 'US';
$loc2 = new Location();
$loc2->LocationType = LocationTypeList::Destination;
$loc2->HasDeliveryAppointment = 1;
$loc2->LocationAddress = $add2;
// comment
$prod = new Product();
$prod->IsHazardousMaterial = 0;
$prod->Length = 50;
$prod->Width = 50;
$prod->Height = 50;
$prod->PieceCount = 10;
$prod->ProductDescription = "Stones";
$prod->PackageType = 'unknown';
$ship = new Shipment();
$ship->PickupDate = '2010-09-13T00:00:00';
$ship->ShipmentLocations = array($add,$add2);
$ship->IsBlind = 0;
$ship->ShipmentProducts = array($prod);
$quote_request = new QuoteRequest();
$quote_request->QuoteType = QuoteTypeList::B2B;
$quote_request->ServiceType = ServiceTypeList::Truckload;
$quote_request->QuoteShipment = $ship;
$quote_request->CustomerId = 0;
$request = new GetRatingEngineQuote();
$request->request = $quote_request;
$request->user = $user;
$response = $client->GetRatingEngineQuote($request);
当我尝试运行此代码时,出现以下错误
Soap 故障 System.Web.Services.Protocols.SoapException:服务器无法读取请求。>---> System.InvalidOperationException: XML 文档中存在错误 (2, 458)。---> >System.FormatException:字符串 '' 不是有效的布尔值。在 >System.Xml.XmlConvert.ToBoolean(String s) 在 >Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read15_Shipment(Bool>ean isNullable, Boolean checkType) 在 >Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read17_QuoteRequest(> Boolean isNullable, Boolean checkType) at >Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read42_GetRatingEngi>neQuote() at >Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Deserialize(XmlSeria>lizationReader reader) at System.Xml.Serialization。
我很难确切地确定错误是否意味着它缺少必需的参数或只是接收到错误的数据类型。任何有关故障排除方法的帮助,错误的确切含义,甚至解决方案都将不胜感激。