通过 PHP 生成的 FedEx Web 服务请求中未包含 CustomerReferences 条目

发布于 2024-08-04 09:46:52 字数 8585 浏览 5 评论 0原文

我正在致力于 FedEx Web 服务集成项目一段时间。我正在使用 PHP 来调用 FedEx 服务器。一切似乎都运转正常。

但我在发送到服务器的原始 FedEx 请求中出现的 CustomerReferences 字段时遇到问题。我正在使用 ShipService_v7.wsdl。我询问 FedEx 技术支持,他们说无法帮助处理 PHP 代码。但我的问题是,即使联邦快递提供的示例代码也无法在发送到服务器的请求中生成 customerreferences 字段。

你们碰巧知道这有什么关系吗?

编辑: 生成发送到 fedex Web 服务器的 XML 文件的代码,

$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>

I am working on this FedEx web service integration project for some time. I am using PHP to make calls to the FedEx server. Everything seems to be working properly.

But I am having problems with CustomerReferences fields appearing in the original fedex request that is sent to the server. I am using the ShipService_v7.wsdl. I asked FedEx tech support saying that would not be able to help with PHP code. But my problem is even the sample code provided by fedex is not able to generate the customerreferences fields in the request sent to the server.

Would you guys happen to know whats the deals with this?

EDIT:
Code that is generating the XML file being sent to the fedex web server,

$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')));

Expected Output :

... XML Stuff ...

            <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 Stuff ...

Current Output

            <ns1:RequestedPackageLineItems>
                <ns1:SequenceNumber>1</ns1:SequenceNumber>
                <ns1:Weight>
                    <ns1:Units>LB</ns1:Units>
                    <ns1:Value>20</ns1:Value>
                </ns1:Weight>       
            </ns1:RequestedPackageLineItems>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不甘平庸 2024-08-11 09:46:52

在 addPackageLineItem1 下添加客户引用,

如下所示:

'Dimensions' => array(
        'Length' => 20,
        'Width' => 20,
        'Height' => 10,
        'Units' => 'IN'),
        'CustomerReferences' => array(
                                        '0' => array(
                                            'CustomerReferenceType' => 'CUSTOMER_REFERENCE', 
                                            'Value' => '123456'
                                    ))

add customer reference under addPackageLineItem1

like this:

'Dimensions' => array(
        'Length' => 20,
        'Width' => 20,
        'Height' => 10,
        'Units' => 'IN'),
        'CustomerReferences' => array(
                                        '0' => array(
                                            'CustomerReferenceType' => 'CUSTOMER_REFERENCE', 
                                            'Value' => '123456'
                                    ))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文