我在这个 FedEx Web 服务集成项目上工作了一段时间。我正在使用 PHP 调用 FedEx 服务器。一切似乎都在正常工作。
但是我遇到了发送到服务器的原始联邦快递请求中出现的 CustomerReferences 字段的问题。我正在使用 ShipService_v7.wsdl。我询问了 FedEx 技术支持,说他们无法提供 PHP 代码。但是我的问题是即使是fedex提供的示例代码也无法在发送到服务器的请求中生成customerreferences字段。
你们会碰巧知道这有什么交易吗?
编辑:生成 XML 文件的代码被发送到 Fedex Web 服务器,
$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('UserCredential' =>
array('Key' => $DEVELOPER_KEY, 'Password' => $DEVELOPER_PASSWORD)); // Replace 'XXX' and 'YYY' with FedEx provided credentials
$request['ClientDetail'] = array('AccountNumber' => $FEDEX_ACCOUNT_NUMBER, 'MeterNumber' => $FEDEX_METER_NUMBER);// Replace 'XXX' with your account and meter number
$request['TransactionDetail'] = array('CustomerTransactionId' => '*** Ground International Shipping Request v7 using PHP ***');
$request['Version'] = array('ServiceId' => 'ship', 'Major' => '7', 'Intermediate' => '0', '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' => array('Contact' => array('PersonName' => 'Sender Name',
'CompanyName' => 'Company Name',
'PhoneNumber' => '0805522713'),
'Address' => array('StreetLines' => array('Address Line 1'),
'City' => 'Memphis',
'StateOrProvinceCode' => 'TN',
'PostalCode' => '38110',
'CountryCode' => 'US')),
'Recipient' => array('Contact' => array('PersonName' => 'Recipient Name',
'CompanyName' => 'Company Name',
'PhoneNumber' => '9012637906'),
'Address' => array('StreetLines' => array('Address Line 1'),
'City' => 'Richmond',
'StateOrProvinceCode' => 'BC',
'PostalCode' => 'V7C4V4',
'CountryCode' => 'CA',
'Residential' => false)),
'ShippingChargesPayment' => array('PaymentType' => 'SENDER', // valid values RECIPIENT, SENDER and THIRD_PARTY
'Payor' => array('AccountNumber' => $FEDEX_ACCOUNT_NUMBER, // Replace 'XXX' with payors account number
'CountryCode' => 'US')),
'InternationalDetail' => array('DutiesPayment' => array('PaymentType' => 'SENDER', // valid values RECIPIENT, SENDER and THIRD_PARTY
'Payor' => array('AccountNumber' => $FEDEX_ACCOUNT_NUMBER, // Replace 'XXX' with payor's account number
'CountryCode' => 'CA')),
'DocumentContent' => 'DOCUMENTS_ONLY',
'CustomsValue' => array('Amount' => 100.0, 'Currency' => 'USD'),
'Commodities' => array('0' => array('NumberOfPieces' => 1,
'Description' => 'Books',
'CountryOfManufacture' => 'US',
'Weight' => array('Value' => 1.0, 'Units' => 'LB'),
'Quantity' => 1,
'QuantityUnits' => 'EA',
'UnitPrice' => array('Amount' => 1.000000, 'Currency' => 'USD'),
'CustomsValue' => array('Amount' => 100.000000, 'Currency' => 'USD'))),
'ExportDetail' => array('B13AFilingOption' => 'FILED_ELECTRONICALLY')),
'LabelSpecification' => array('LabelFormatType' => 'COMMON2D', // valid values COMMON2D, LABEL_DATA_ONLY
'ImageType' => 'PNG', // valid values DPL, EPL2, PDF, ZPLII and PNG
'LabelStockType' => 'PAPER_7X4.75'),
'RateRequestTypes' => array('ACCOUNT'), // valid values ACCOUNT and LIST
'PackageCount' => 1,
'PackageDetail' => 'INDIVIDUAL_PACKAGES',
'RequestedPackageLineItems' => array('SequenceNumber' => 1,
'Weight' => array('Value' => 20.0, 'Units' => 'LB')), // valid values LB and KG
'CustomerReferences' => array('0' => array('CustomerReferenceType' => 'CUSTOMER_REFERENCE', 'Value' => 'TC007_07_PT1_ST01_PK01_SNDUS_RCPCA_POS')));
预期输出:
... XML 的东西 ...
<ns1:RequestedPackageLineItems>
<ns1:SequenceNumber>1</ns1:SequenceNumber>
<ns1:Weight>
<ns1:Units>LB</ns1:Units>
<ns1:Value>20</ns1:Value>
</ns1:Weight>
<ns1:CustomerReferences>
<ns1:CustomerReferenceType>CUSTOMER_REFERENCE</ns1:CustomerReferenceType>
<ns1:Value>I am a customer reference</ns1:Value>
</ns1:CustomerReferences>
</ns1:RequestedPackageLineItems>
... XML 的东西 ...
电流输出
<ns1:RequestedPackageLineItems>
<ns1:SequenceNumber>1</ns1:SequenceNumber>
<ns1:Weight>
<ns1:Units>LB</ns1:Units>
<ns1:Value>20</ns1:Value>
</ns1:Weight>
</ns1:RequestedPackageLineItems>