通过 FedEx 的 FedEx 干冰 API
FedEx Dry Ice via FedEx API
是否有人足够熟悉 FedEx API 让干冰工作?
FedEx 干冰文档在此处:https://www.fedex.com/us/developer/WebHelp/ws/2014/dvg/WS_DVG_WebHelp/index.htm#25_2_Dry_Ice_Coding_Details.htm
然而,这似乎与他们的 WSDL 并不匹配。无论我尝试过什么,我总是会收到架构验证错误。
是否有人能够提供包含干冰的样品请求并获得成功响应?
我找不到任何关于放置 RequestedPackages 元素的正确位置的信息。我把它和 RequestedShipment 以及其他几个地方放在同一级别,但一无所获。
如果我只放置 RequestedShipment 字段而不是我得到的包裹信息:
8616 (Dry Ice cannot be entered at the shipment level.)
样品申请
这个示例请求感觉是我得到的最接近的。 FedEx 不喜欢 RequestedPackages
元素的位置。我已经删除了很多不必要的字段,例如下面的地址信息:
<ns:ProcessShipmentRequest xmlns:ns="http://fedex.com/ws/ship/v15" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://fedex.com/ws/ship/v15 ShipService v15.xsd">
<ns:WebAuthenticationDetail>
<ns:UserCredential>
</ns:UserCredential>
</ns:WebAuthenticationDetail>
<ns:ClientDetail>
</ns:ClientDetail>
<ns:TransactionDetail>
<ns:CustomerTransactionId>CreatePendingRequest</ns:CustomerTransactionId>
</ns:TransactionDetail>
<ns:Version>
<ns:ServiceId>ship</ns:ServiceId>
<ns:Major>15</ns:Major>
<ns:Intermediate>0</ns:Intermediate>
<ns:Minor>0</ns:Minor>
</ns:Version>
<ns:RequestedShipment>
<ns:ShipTimestamp>2016-10-21T10:17:09-07:00</ns:ShipTimestamp>
<ns:DropoffType>REGULAR_PICKUP</ns:DropoffType>
<ns:ServiceType>PRIORITY_OVERNIGHT</ns:ServiceType>
<ns:PackagingType>YOUR_PACKAGING</ns:PackagingType>
<ns:SpecialServicesRequested>
<ns:SpecialServiceTypes>DRY_ICE</ns:SpecialServiceTypes>
<ns:ShipmentDryIceDetail>
<ns:PackageCount>1</ns:PackageCount>
<ns:TotalWeight>
<ns:Units>KG</ns:Units>
<ns:Value>2.5</ns:Value>
</ns:TotalWeight>
</ns:ShipmentDryIceDetail>
</ns:SpecialServicesRequested>
<ns:LabelSpecification>
<ns:LabelFormatType>COMMON2D</ns:LabelFormatType>
<ns:ImageType>ZPLII</ns:ImageType>
<ns:LabelStockType>STOCK_4X6</ns:LabelStockType>
<ns:LabelPrintingOrientation>TOP_EDGE_OF_TEXT_FIRST</ns:LabelPrintingOrientation>
</ns:LabelSpecification>
<ns:RateRequestTypes>LIST</ns:RateRequestTypes>
<ns:PackageCount>1</ns:PackageCount>
<ns:RequestedPackageLineItems>
<ns:SequenceNumber>1</ns:SequenceNumber>
<ns:Weight>
<ns:Units>LB</ns:Units>
<ns:Value>8</ns:Value>
</ns:Weight>
<ns:Dimensions>
</ns:Dimensions>
<ns:SpecialServicesRequested>
<ns:SpecialServiceTypes>SIGNATURE_OPTION</ns:SpecialServiceTypes>
<ns:SignatureOptionDetail>
<ns:OptionType>SERVICE_DEFAULT</ns:OptionType>
</ns:SignatureOptionDetail>
</ns:SpecialServicesRequested>
</ns:RequestedPackageLineItems>
</ns:RequestedShipment>
<ns:RequestedPackages>
<ns:SpecialServicesRequested>
<ns:SpecialServiceTypes>DRY_ICE</ns:SpecialServiceTypes>
<ns:DryIceWeight>
<ns:Units>KG</ns:Units>
<ns:Value>2.5</ns:Value>
</ns:DryIceWeight>
</ns:SpecialServicesRequested>
</ns:RequestedPackages>
</ns:ProcessShipmentRequest>
联邦快递回应:
Element not allowed: RequestedPackages@http://fedex.com/ws/ship/v15 in element ProcessShipmentRequest@http://fedex.com/ws/ship/v15
我也试过将包装级别的干冰信息放在 RequestedPackageLineItems/SpecialServicesRequested
部分,但得到以下响应:
Expected elements \'PieceCountVerificationBoxCount@http://fedex.com/ws/ship/v15 PriorityAlertDetail@http://fedex.com/ws/ship/v15 AlcoholDetail@http://fedex.com/ws/ship/v15\' instead of \'DryIceWeight@http://fedex.com/ws/ship/v15\' here in element SpecialServicesRequested@http://fedex.com/ws/ship/v15
这是我从文档开始的示例代码,但它返回的费率没有变化。我想包括 DRY ICE 费用
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array(
'ParentCredential' => array(
'Key' => getProperty('parentkey'),
'Password' => getProperty('parentpassword')
),
'UserCredential' => array(
'Key' => getProperty('key'),
'Password' => getProperty('password')
)
);
$request['ClientDetail'] = array(
'AccountNumber' => getProperty('shipaccount'),
'MeterNumber' => getProperty('meter')
);
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request using PHP ***');
$request['Version'] = array(
'ServiceId' => 'crs',
'Major' => '20',
'Intermediate' => '0',
'Minor' => '0'
);
$request['ReturnTransitAndCommit'] = true;
$request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP'; // valid values REGULAR_PICKUP, REQUEST_COURIER, ...
$request['RequestedShipment']['ShipTimestamp'] = date('c');
$request['RequestedShipment']['SpecialServicesRequested']['ShipmentSpecialServiceType']= "DRY_ICE";
$request['RequestedShipment']['specialServicesRequested']['shipmentDryIceDetail']['packageCount']= 5;
$request['RequestedShipment']['specialServicesRequested']['shipmentDryIceDetail']['totalweight']= 50;
$request['RequestedShipment']['specialServicesRequested']['ShipmentSpecialServiceType'] = 'DRY_ICE';
$request['RequestedShipment']['ServiceType'] = 'INTERNATIONAL_PRIORITY'; // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
$request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
$request['RequestedShipment']['TotalInsuredValue']=array(
'Ammount'=>100,
'Currency'=>'USD'
);
$request['RequestedShipment']['Shipper'] = addShipper();
$request['RequestedShipment']['Recipient'] = addRecipient();
$request['RequestedShipment']['ShippingChargesPayment'] = addShippingChargesPayment();
$request['RequestedShipment']['PackageCount'] = '1';
$request['RequestedShipment']['RequestedPackageLineItems'] = addPackageLineItem1();
下面是一个使用干冰的 FedEx 标签请求示例,它可以正常工作。凭据和地址信息已被删除。
干冰信息进入 RequestedShipment/RequestedPackageLineItems/SpecialServicesRequested
虽然文档也说要把它放在 RequestedShipment/SpecialServicesRequested
中,但我发现这样做总是会导致以下错误
8616 (Dry Ice cannot be entered at the shipment level.)
另请注意,此软件包还启用了 SIGNATURE_OPTION
。这些和任何其他 SpecialServiceTypes
的顺序非常重要。如果您正在使用其他包裹级别的特殊服务并收到 Schema validation failed for request
错误,您可能需要重新排序这些字段或联系 FedEx 支持以获得订购方面的帮助。 DRY_ICE
必须始终是第一个特殊服务类型,并且 DryIceWeight
元素必须位于特殊服务列表之后,但在这些服务所需的任何额外元素之前。
样品干冰装运请求:
<ns:ProcessShipmentRequest xmlns:ns="http://fedex.com/ws/ship/v15" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://fedex.com/ws/ship/v15 ShipService v15.xsd">
<ns:WebAuthenticationDetail>
<ns:UserCredential>
<ns:Key></ns:Key>
<ns:Password></ns:Password>
</ns:UserCredential>
</ns:WebAuthenticationDetail>
<ns:ClientDetail>
<ns:AccountNumber></ns:AccountNumber>
<ns:MeterNumber></ns:MeterNumber>
</ns:ClientDetail>
<ns:TransactionDetail>
<ns:CustomerTransactionId>CreatePendingRequest</ns:CustomerTransactionId>
</ns:TransactionDetail>
<ns:Version>
<ns:ServiceId>ship</ns:ServiceId>
<ns:Major>15</ns:Major>
<ns:Intermediate>0</ns:Intermediate>
<ns:Minor>0</ns:Minor>
</ns:Version>
<ns:RequestedShipment>
<ns:ShipTimestamp>2016-10-25T11:03:40-07:00</ns:ShipTimestamp>
<ns:DropoffType>REGULAR_PICKUP</ns:DropoffType>
<ns:ServiceType>PRIORITY_OVERNIGHT</ns:ServiceType>
<ns:PackagingType>YOUR_PACKAGING</ns:PackagingType>
<ns:Shipper>
<ns:Contact>
<ns:CompanyName>Name</ns:CompanyName>
<ns:PhoneNumber>Phone</ns:PhoneNumber>
</ns:Contact>
<ns:Address>
<ns:StreetLines>Street</ns:StreetLines>
<ns:StreetLines>Street</ns:StreetLines>
<ns:City>City</ns:City>
<ns:StateOrProvinceCode>CA</ns:StateOrProvinceCode>
<ns:PostalCode>ZIP</ns:PostalCode>
<ns:CountryCode>US</ns:CountryCode>
</ns:Address>
</ns:Shipper>
<ns:Recipient>
<ns:Contact>
<ns:PersonName>Name</ns:PersonName>
<ns:PhoneNumber>Phone</ns:PhoneNumber>
</ns:Contact>
<ns:Address>
<ns:StreetLines>123 MAIN STREET</ns:StreetLines>
<ns:StreetLines>MAIL SLOT 45</ns:StreetLines>
<ns:City>City</ns:City>
<ns:StateOrProvinceCode>CA</ns:StateOrProvinceCode>
<ns:PostalCode>Xip</ns:PostalCode>
<ns:CountryCode>US</ns:CountryCode>
</ns:Address>
</ns:Recipient>
<ns:ShippingChargesPayment>
<ns:PaymentType>SENDER</ns:PaymentType>
<ns:Payor>
<ns:ResponsibleParty>
<ns:AccountNumber></ns:AccountNumber>
<ns:Contact>
<ns:CompanyName>Name</ns:CompanyName>
</ns:Contact>
<ns:Address>
<ns:CountryCode>US</ns:CountryCode>
</ns:Address>
</ns:ResponsibleParty>
</ns:Payor>
</ns:ShippingChargesPayment>
<ns:SpecialServicesRequested>
</ns:SpecialServicesRequested>
<ns:LabelSpecification>
<ns:LabelFormatType>COMMON2D</ns:LabelFormatType>
<ns:ImageType>ZPLII</ns:ImageType>
<ns:LabelStockType>STOCK_4X6</ns:LabelStockType>
<ns:LabelPrintingOrientation>TOP_EDGE_OF_TEXT_FIRST</ns:LabelPrintingOrientation>
<ns:PrintedLabelOrigin>
<ns:Contact>
<ns:CompanyName>Company</ns:CompanyName>
<ns:PhoneNumber>Phone</ns:PhoneNumber>
</ns:Contact>
<ns:Address>
<ns:StreetLines>Street</ns:StreetLines>
<ns:City>City</ns:City>
<ns:StateOrProvinceCode>CA</ns:StateOrProvinceCode>
<ns:PostalCode>Zip</ns:PostalCode>
<ns:CountryCode>US</ns:CountryCode>
</ns:Address>
</ns:PrintedLabelOrigin>
</ns:LabelSpecification>
<ns:RateRequestTypes>LIST</ns:RateRequestTypes>
<ns:PackageCount>1</ns:PackageCount>
<ns:RequestedPackageLineItems>
<ns:SequenceNumber>1</ns:SequenceNumber>
<ns:Weight>
<ns:Units>LB</ns:Units>
<ns:Value>8</ns:Value>
</ns:Weight>
<ns:Dimensions>
<ns:Length>5</ns:Length>
<ns:Width>5</ns:Width>
<ns:Height>4</ns:Height>
<ns:Units>IN</ns:Units>
</ns:Dimensions>
<ns:CustomerReferences>
<ns:CustomerReferenceType>CUSTOMER_REFERENCE</ns:CustomerReferenceType>
<ns:Value>CD0000002199</ns:Value>
</ns:CustomerReferences>
<ns:CustomerReferences>
<ns:CustomerReferenceType>P_O_NUMBER</ns:CustomerReferenceType>
<ns:Value>0000497600</ns:Value>
</ns:CustomerReferences>
<ns:SpecialServicesRequested>
<ns:SpecialServiceTypes>DRY_ICE</ns:SpecialServiceTypes>
<ns:SpecialServiceTypes>SIGNATURE_OPTION</ns:SpecialServiceTypes>
<ns:DryIceWeight>
<ns:Units>KG</ns:Units>
<ns:Value>2.5</ns:Value>
</ns:DryIceWeight>
<ns:SignatureOptionDetail>
<ns:OptionType>DIRECT</ns:OptionType>
</ns:SignatureOptionDetail>
</ns:SpecialServicesRequested>
</ns:RequestedPackageLineItems>
</ns:RequestedShipment>
</ns:ProcessShipmentRequest>
我可以通过以下代码添加干冰
$path_to_wsdl = "wsdl/RateService_v20.wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array(
'ParentCredential' => array(
'Key' => getProperty('parentkey'),
'Password' => getProperty('parentpassword')
),
'UserCredential' => array(
'Key' => getProperty('key'),
'Password' => getProperty('password')
)
);
$request['ClientDetail'] = array(
'AccountNumber' => getProperty('shipaccount'),
'MeterNumber' => getProperty('meter')
);
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request using PHP ***');
$request['Version'] = array(
'ServiceId' => 'crs',
'Major' => '20',
'Intermediate' => '0',
'Minor' => '0'
);
$request['ReturnTransitAndCommit'] = true;
$request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP'; // valid values REGULAR_PICKUP, REQUEST_COURIER, ...
$request['RequestedShipment']['ShipTimestamp'] = date('c');
/* * *********Adding Dry Ice * */
$request['RequestedShipment']['SpecialServicesRequested']['SpecialServiceTypes'] = 'DRY_ICE';
$request['RequestedShipment']['SpecialServicesRequested']['DryIceWeight'] = '5';
$request['RequestedShipment']['SpecialServicesRequested']['ShipmentDryIceDetail']['PackageCount'] = '1';
$request['RequestedShipment']['ServiceType'] = 'INTERNATIONAL_PRIORITY'; // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
$request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
$request['RequestedShipment']['TotalInsuredValue'] = array(
'Ammount' => 100,
'Currency' => 'USD'
);
$request['RequestedShipment']['Shipper'] = addShipper();
$request['RequestedShipment']['Recipient'] = addRecipient();
$request['RequestedShipment']['ShippingChargesPayment'] = addShippingChargesPayment();
$request['RequestedShipment']['PackageCount'] = '1';
$request['RequestedShipment']['RequestedPackageLineItems'] = addPackageLineItem1();
try {
if (setEndpoint('changeEndpoint')) {
$newLocation = $client->__setLocation(setEndpoint('endpoint'));
}
$response = $client->getRates($request);
if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') {
$rateReply = $response->RateReplyDetails;
echo '<table border="1">';
echo '<tr><td>Service Type</td><td>Amount</td><td>Delivery Date</td></tr><tr>';
$serviceType = '<td>' . $rateReply->ServiceType . '</td>';
if ($rateReply->RatedShipmentDetails && is_array($rateReply->RatedShipmentDetails)) {
$amount = '<td>$' . number_format($rateReply->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount, 2, ".", ",") . '</td>';
} elseif ($rateReply->RatedShipmentDetails && !is_array($rateReply->RatedShipmentDetails)) {
$amount = '<td>$' . number_format($rateReply->RatedShipmentDetails->ShipmentRateDetail->TotalNetCharge->Amount, 2, ".", ",") . '</td>';
}
if (array_key_exists('DeliveryTimestamp', $rateReply)) {
$deliveryDate = '<td>' . $rateReply->DeliveryTimestamp . '</td>';
} else if (array_key_exists('TransitTime', $rateReply)) {
$deliveryDate = '<td>' . $rateReply->TransitTime . '</td>';
} else {
$deliveryDate = '<td> </td>';
}
echo $serviceType . $amount . $deliveryDate;
echo '</tr>';
echo '</table>';
printSuccess($client, $response);
} else {
printError($client, $response);
}
writeToLog($client); // Write to log file
} catch (SoapFault $exception) {
printFault($exception, $client);
}
是否有人足够熟悉 FedEx API 让干冰工作?
FedEx 干冰文档在此处:https://www.fedex.com/us/developer/WebHelp/ws/2014/dvg/WS_DVG_WebHelp/index.htm#25_2_Dry_Ice_Coding_Details.htm
然而,这似乎与他们的 WSDL 并不匹配。无论我尝试过什么,我总是会收到架构验证错误。
是否有人能够提供包含干冰的样品请求并获得成功响应?
我找不到任何关于放置 RequestedPackages 元素的正确位置的信息。我把它和 RequestedShipment 以及其他几个地方放在同一级别,但一无所获。
如果我只放置 RequestedShipment 字段而不是我得到的包裹信息:
8616 (Dry Ice cannot be entered at the shipment level.)
样品申请
这个示例请求感觉是我得到的最接近的。 FedEx 不喜欢 RequestedPackages
元素的位置。我已经删除了很多不必要的字段,例如下面的地址信息:
<ns:ProcessShipmentRequest xmlns:ns="http://fedex.com/ws/ship/v15" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://fedex.com/ws/ship/v15 ShipService v15.xsd">
<ns:WebAuthenticationDetail>
<ns:UserCredential>
</ns:UserCredential>
</ns:WebAuthenticationDetail>
<ns:ClientDetail>
</ns:ClientDetail>
<ns:TransactionDetail>
<ns:CustomerTransactionId>CreatePendingRequest</ns:CustomerTransactionId>
</ns:TransactionDetail>
<ns:Version>
<ns:ServiceId>ship</ns:ServiceId>
<ns:Major>15</ns:Major>
<ns:Intermediate>0</ns:Intermediate>
<ns:Minor>0</ns:Minor>
</ns:Version>
<ns:RequestedShipment>
<ns:ShipTimestamp>2016-10-21T10:17:09-07:00</ns:ShipTimestamp>
<ns:DropoffType>REGULAR_PICKUP</ns:DropoffType>
<ns:ServiceType>PRIORITY_OVERNIGHT</ns:ServiceType>
<ns:PackagingType>YOUR_PACKAGING</ns:PackagingType>
<ns:SpecialServicesRequested>
<ns:SpecialServiceTypes>DRY_ICE</ns:SpecialServiceTypes>
<ns:ShipmentDryIceDetail>
<ns:PackageCount>1</ns:PackageCount>
<ns:TotalWeight>
<ns:Units>KG</ns:Units>
<ns:Value>2.5</ns:Value>
</ns:TotalWeight>
</ns:ShipmentDryIceDetail>
</ns:SpecialServicesRequested>
<ns:LabelSpecification>
<ns:LabelFormatType>COMMON2D</ns:LabelFormatType>
<ns:ImageType>ZPLII</ns:ImageType>
<ns:LabelStockType>STOCK_4X6</ns:LabelStockType>
<ns:LabelPrintingOrientation>TOP_EDGE_OF_TEXT_FIRST</ns:LabelPrintingOrientation>
</ns:LabelSpecification>
<ns:RateRequestTypes>LIST</ns:RateRequestTypes>
<ns:PackageCount>1</ns:PackageCount>
<ns:RequestedPackageLineItems>
<ns:SequenceNumber>1</ns:SequenceNumber>
<ns:Weight>
<ns:Units>LB</ns:Units>
<ns:Value>8</ns:Value>
</ns:Weight>
<ns:Dimensions>
</ns:Dimensions>
<ns:SpecialServicesRequested>
<ns:SpecialServiceTypes>SIGNATURE_OPTION</ns:SpecialServiceTypes>
<ns:SignatureOptionDetail>
<ns:OptionType>SERVICE_DEFAULT</ns:OptionType>
</ns:SignatureOptionDetail>
</ns:SpecialServicesRequested>
</ns:RequestedPackageLineItems>
</ns:RequestedShipment>
<ns:RequestedPackages>
<ns:SpecialServicesRequested>
<ns:SpecialServiceTypes>DRY_ICE</ns:SpecialServiceTypes>
<ns:DryIceWeight>
<ns:Units>KG</ns:Units>
<ns:Value>2.5</ns:Value>
</ns:DryIceWeight>
</ns:SpecialServicesRequested>
</ns:RequestedPackages>
</ns:ProcessShipmentRequest>
联邦快递回应:
Element not allowed: RequestedPackages@http://fedex.com/ws/ship/v15 in element ProcessShipmentRequest@http://fedex.com/ws/ship/v15
我也试过将包装级别的干冰信息放在 RequestedPackageLineItems/SpecialServicesRequested
部分,但得到以下响应:
Expected elements \'PieceCountVerificationBoxCount@http://fedex.com/ws/ship/v15 PriorityAlertDetail@http://fedex.com/ws/ship/v15 AlcoholDetail@http://fedex.com/ws/ship/v15\' instead of \'DryIceWeight@http://fedex.com/ws/ship/v15\' here in element SpecialServicesRequested@http://fedex.com/ws/ship/v15
这是我从文档开始的示例代码,但它返回的费率没有变化。我想包括 DRY ICE 费用
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array(
'ParentCredential' => array(
'Key' => getProperty('parentkey'),
'Password' => getProperty('parentpassword')
),
'UserCredential' => array(
'Key' => getProperty('key'),
'Password' => getProperty('password')
)
);
$request['ClientDetail'] = array(
'AccountNumber' => getProperty('shipaccount'),
'MeterNumber' => getProperty('meter')
);
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request using PHP ***');
$request['Version'] = array(
'ServiceId' => 'crs',
'Major' => '20',
'Intermediate' => '0',
'Minor' => '0'
);
$request['ReturnTransitAndCommit'] = true;
$request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP'; // valid values REGULAR_PICKUP, REQUEST_COURIER, ...
$request['RequestedShipment']['ShipTimestamp'] = date('c');
$request['RequestedShipment']['SpecialServicesRequested']['ShipmentSpecialServiceType']= "DRY_ICE";
$request['RequestedShipment']['specialServicesRequested']['shipmentDryIceDetail']['packageCount']= 5;
$request['RequestedShipment']['specialServicesRequested']['shipmentDryIceDetail']['totalweight']= 50;
$request['RequestedShipment']['specialServicesRequested']['ShipmentSpecialServiceType'] = 'DRY_ICE';
$request['RequestedShipment']['ServiceType'] = 'INTERNATIONAL_PRIORITY'; // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
$request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
$request['RequestedShipment']['TotalInsuredValue']=array(
'Ammount'=>100,
'Currency'=>'USD'
);
$request['RequestedShipment']['Shipper'] = addShipper();
$request['RequestedShipment']['Recipient'] = addRecipient();
$request['RequestedShipment']['ShippingChargesPayment'] = addShippingChargesPayment();
$request['RequestedShipment']['PackageCount'] = '1';
$request['RequestedShipment']['RequestedPackageLineItems'] = addPackageLineItem1();
下面是一个使用干冰的 FedEx 标签请求示例,它可以正常工作。凭据和地址信息已被删除。
干冰信息进入 RequestedShipment/RequestedPackageLineItems/SpecialServicesRequested
虽然文档也说要把它放在 RequestedShipment/SpecialServicesRequested
中,但我发现这样做总是会导致以下错误
8616 (Dry Ice cannot be entered at the shipment level.)
另请注意,此软件包还启用了 SIGNATURE_OPTION
。这些和任何其他 SpecialServiceTypes
的顺序非常重要。如果您正在使用其他包裹级别的特殊服务并收到 Schema validation failed for request
错误,您可能需要重新排序这些字段或联系 FedEx 支持以获得订购方面的帮助。 DRY_ICE
必须始终是第一个特殊服务类型,并且 DryIceWeight
元素必须位于特殊服务列表之后,但在这些服务所需的任何额外元素之前。
样品干冰装运请求:
<ns:ProcessShipmentRequest xmlns:ns="http://fedex.com/ws/ship/v15" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://fedex.com/ws/ship/v15 ShipService v15.xsd">
<ns:WebAuthenticationDetail>
<ns:UserCredential>
<ns:Key></ns:Key>
<ns:Password></ns:Password>
</ns:UserCredential>
</ns:WebAuthenticationDetail>
<ns:ClientDetail>
<ns:AccountNumber></ns:AccountNumber>
<ns:MeterNumber></ns:MeterNumber>
</ns:ClientDetail>
<ns:TransactionDetail>
<ns:CustomerTransactionId>CreatePendingRequest</ns:CustomerTransactionId>
</ns:TransactionDetail>
<ns:Version>
<ns:ServiceId>ship</ns:ServiceId>
<ns:Major>15</ns:Major>
<ns:Intermediate>0</ns:Intermediate>
<ns:Minor>0</ns:Minor>
</ns:Version>
<ns:RequestedShipment>
<ns:ShipTimestamp>2016-10-25T11:03:40-07:00</ns:ShipTimestamp>
<ns:DropoffType>REGULAR_PICKUP</ns:DropoffType>
<ns:ServiceType>PRIORITY_OVERNIGHT</ns:ServiceType>
<ns:PackagingType>YOUR_PACKAGING</ns:PackagingType>
<ns:Shipper>
<ns:Contact>
<ns:CompanyName>Name</ns:CompanyName>
<ns:PhoneNumber>Phone</ns:PhoneNumber>
</ns:Contact>
<ns:Address>
<ns:StreetLines>Street</ns:StreetLines>
<ns:StreetLines>Street</ns:StreetLines>
<ns:City>City</ns:City>
<ns:StateOrProvinceCode>CA</ns:StateOrProvinceCode>
<ns:PostalCode>ZIP</ns:PostalCode>
<ns:CountryCode>US</ns:CountryCode>
</ns:Address>
</ns:Shipper>
<ns:Recipient>
<ns:Contact>
<ns:PersonName>Name</ns:PersonName>
<ns:PhoneNumber>Phone</ns:PhoneNumber>
</ns:Contact>
<ns:Address>
<ns:StreetLines>123 MAIN STREET</ns:StreetLines>
<ns:StreetLines>MAIL SLOT 45</ns:StreetLines>
<ns:City>City</ns:City>
<ns:StateOrProvinceCode>CA</ns:StateOrProvinceCode>
<ns:PostalCode>Xip</ns:PostalCode>
<ns:CountryCode>US</ns:CountryCode>
</ns:Address>
</ns:Recipient>
<ns:ShippingChargesPayment>
<ns:PaymentType>SENDER</ns:PaymentType>
<ns:Payor>
<ns:ResponsibleParty>
<ns:AccountNumber></ns:AccountNumber>
<ns:Contact>
<ns:CompanyName>Name</ns:CompanyName>
</ns:Contact>
<ns:Address>
<ns:CountryCode>US</ns:CountryCode>
</ns:Address>
</ns:ResponsibleParty>
</ns:Payor>
</ns:ShippingChargesPayment>
<ns:SpecialServicesRequested>
</ns:SpecialServicesRequested>
<ns:LabelSpecification>
<ns:LabelFormatType>COMMON2D</ns:LabelFormatType>
<ns:ImageType>ZPLII</ns:ImageType>
<ns:LabelStockType>STOCK_4X6</ns:LabelStockType>
<ns:LabelPrintingOrientation>TOP_EDGE_OF_TEXT_FIRST</ns:LabelPrintingOrientation>
<ns:PrintedLabelOrigin>
<ns:Contact>
<ns:CompanyName>Company</ns:CompanyName>
<ns:PhoneNumber>Phone</ns:PhoneNumber>
</ns:Contact>
<ns:Address>
<ns:StreetLines>Street</ns:StreetLines>
<ns:City>City</ns:City>
<ns:StateOrProvinceCode>CA</ns:StateOrProvinceCode>
<ns:PostalCode>Zip</ns:PostalCode>
<ns:CountryCode>US</ns:CountryCode>
</ns:Address>
</ns:PrintedLabelOrigin>
</ns:LabelSpecification>
<ns:RateRequestTypes>LIST</ns:RateRequestTypes>
<ns:PackageCount>1</ns:PackageCount>
<ns:RequestedPackageLineItems>
<ns:SequenceNumber>1</ns:SequenceNumber>
<ns:Weight>
<ns:Units>LB</ns:Units>
<ns:Value>8</ns:Value>
</ns:Weight>
<ns:Dimensions>
<ns:Length>5</ns:Length>
<ns:Width>5</ns:Width>
<ns:Height>4</ns:Height>
<ns:Units>IN</ns:Units>
</ns:Dimensions>
<ns:CustomerReferences>
<ns:CustomerReferenceType>CUSTOMER_REFERENCE</ns:CustomerReferenceType>
<ns:Value>CD0000002199</ns:Value>
</ns:CustomerReferences>
<ns:CustomerReferences>
<ns:CustomerReferenceType>P_O_NUMBER</ns:CustomerReferenceType>
<ns:Value>0000497600</ns:Value>
</ns:CustomerReferences>
<ns:SpecialServicesRequested>
<ns:SpecialServiceTypes>DRY_ICE</ns:SpecialServiceTypes>
<ns:SpecialServiceTypes>SIGNATURE_OPTION</ns:SpecialServiceTypes>
<ns:DryIceWeight>
<ns:Units>KG</ns:Units>
<ns:Value>2.5</ns:Value>
</ns:DryIceWeight>
<ns:SignatureOptionDetail>
<ns:OptionType>DIRECT</ns:OptionType>
</ns:SignatureOptionDetail>
</ns:SpecialServicesRequested>
</ns:RequestedPackageLineItems>
</ns:RequestedShipment>
</ns:ProcessShipmentRequest>
我可以通过以下代码添加干冰
$path_to_wsdl = "wsdl/RateService_v20.wsdl";
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1)); // Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array(
'ParentCredential' => array(
'Key' => getProperty('parentkey'),
'Password' => getProperty('parentpassword')
),
'UserCredential' => array(
'Key' => getProperty('key'),
'Password' => getProperty('password')
)
);
$request['ClientDetail'] = array(
'AccountNumber' => getProperty('shipaccount'),
'MeterNumber' => getProperty('meter')
);
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Request using PHP ***');
$request['Version'] = array(
'ServiceId' => 'crs',
'Major' => '20',
'Intermediate' => '0',
'Minor' => '0'
);
$request['ReturnTransitAndCommit'] = true;
$request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP'; // valid values REGULAR_PICKUP, REQUEST_COURIER, ...
$request['RequestedShipment']['ShipTimestamp'] = date('c');
/* * *********Adding Dry Ice * */
$request['RequestedShipment']['SpecialServicesRequested']['SpecialServiceTypes'] = 'DRY_ICE';
$request['RequestedShipment']['SpecialServicesRequested']['DryIceWeight'] = '5';
$request['RequestedShipment']['SpecialServicesRequested']['ShipmentDryIceDetail']['PackageCount'] = '1';
$request['RequestedShipment']['ServiceType'] = 'INTERNATIONAL_PRIORITY'; // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
$request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
$request['RequestedShipment']['TotalInsuredValue'] = array(
'Ammount' => 100,
'Currency' => 'USD'
);
$request['RequestedShipment']['Shipper'] = addShipper();
$request['RequestedShipment']['Recipient'] = addRecipient();
$request['RequestedShipment']['ShippingChargesPayment'] = addShippingChargesPayment();
$request['RequestedShipment']['PackageCount'] = '1';
$request['RequestedShipment']['RequestedPackageLineItems'] = addPackageLineItem1();
try {
if (setEndpoint('changeEndpoint')) {
$newLocation = $client->__setLocation(setEndpoint('endpoint'));
}
$response = $client->getRates($request);
if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') {
$rateReply = $response->RateReplyDetails;
echo '<table border="1">';
echo '<tr><td>Service Type</td><td>Amount</td><td>Delivery Date</td></tr><tr>';
$serviceType = '<td>' . $rateReply->ServiceType . '</td>';
if ($rateReply->RatedShipmentDetails && is_array($rateReply->RatedShipmentDetails)) {
$amount = '<td>$' . number_format($rateReply->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount, 2, ".", ",") . '</td>';
} elseif ($rateReply->RatedShipmentDetails && !is_array($rateReply->RatedShipmentDetails)) {
$amount = '<td>$' . number_format($rateReply->RatedShipmentDetails->ShipmentRateDetail->TotalNetCharge->Amount, 2, ".", ",") . '</td>';
}
if (array_key_exists('DeliveryTimestamp', $rateReply)) {
$deliveryDate = '<td>' . $rateReply->DeliveryTimestamp . '</td>';
} else if (array_key_exists('TransitTime', $rateReply)) {
$deliveryDate = '<td>' . $rateReply->TransitTime . '</td>';
} else {
$deliveryDate = '<td> </td>';
}
echo $serviceType . $amount . $deliveryDate;
echo '</tr>';
echo '</table>';
printSuccess($client, $response);
} else {
printError($client, $response);
}
writeToLog($client); // Write to log file
} catch (SoapFault $exception) {
printFault($exception, $client);
}