简体   繁体   English

物理包装类型缺失或无效

[英]Physical packaging type is missing or invalid

I am able to receive rates from FedEx API with my PHP library.我可以使用我的 PHP 库从 FedEx API 接收费率。 But its only regular request.但它唯一的常规要求。 When I try to have Freight LTL Rate API request it shows me error one by one.当我尝试发出货运 LTL 费率 API 请求时,它会一一显示错误。 I almost fixed most of them but still having problem with Physical packaging type is missing or invalid .我几乎修复了其中的大部分,但仍然遇到Physical packaging type is missing or invalid的问题。

I tried to figure out where is the problem with WSDL file but no luck.我试图找出 WSDL 文件的问题在哪里,但没有运气。 There is nothing in there.里面什么都没有。

If you have any working example for Freight LTL please answer me.如果您有任何货运 LTL 的工作示例,请回答我。 Thank you谢谢

Here is my code:这是我的代码:

<?php
// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 12.0.0

require_once('../../fedex-common.php5');

$newline = "<br />";
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "../wsdl/RateService_v31.wsdl";

ini_set("soap.wsdl_cache_enabled", "1");

$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' => '31',
    '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']['ServiceType'] = 'FEDEX_FREIGHT_ECONOMY'; // 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']['Shipper'] = getProperty('shipper');
$request['RequestedShipment']['Recipient'] = addRecipient();
$request['RequestedShipment']['ShippingChargesPayment'] = addShippingChargesPayment();
$request['RequestedShipment']['FreightShipmentDetail'] = array(
    'FedExFreightAccountNumber' => getProperty('freightaccount'),
    'FedExFreightBillingContactAndAddress' => getProperty('freightbilling'),
    'PrintedReferences' => array(
        'Type' => 'SHIPPER_ID_NUMBER',
        'Value' => 'RBB1057'
    ),
    'Role' => 'SHIPPER',
    'PaymentType' => 'PREPAID',
    'CollectTermsType' => 'STANDARD',
    'DeclaredValuePerUnit' => array(
        'Currency' => 'USD',
        'Amount' => 50
    ),
    'LiabilityCoverageDetail' => array(
        'CoverageType' => 'NEW',
        'CoverageAmount' => array(
            'Currency' => 'USD',
            'Amount' => '50'
        )
    ),
    'TotalHandlingUnits' => 15,
    'ClientDiscountPercent' => 0,
    'PalletWeight' => array(
        'Units' => 'LB',
        'Value' => 20
    ),
    'ShipmentDimensions' => array(
        'Length' => 90,
        'Width' => 30,
        'Height' => 50,
        'Units' => 'IN'
    ),
    'LineItems' => array(
        'Id' => '111',
        'FreightClass' => 'CLASS_085',
        'ClassProvidedByCustomer' => false,
        'HandlingUnits' => 15,
        'Packaging' => 'PALLET',
        'BillOfLaddingNumber' => 'BOL_12345',
        'PurchaseOrderNumber' => 'PO_12345',
        'Description' => 'Heavy Stuff',
        'Weight' => array(
            'Value' => 50.0,
            'Units' => 'LB'
        ),
        'Dimensions' => array(
            'Length' => 90,
            'Width' => 30,
            'Height' => 50,
            'Units' => 'IN'
        ),
        'Volume' => array(
            'Units' => 'CUBIC_FT',
            'Value' => 30
        )
    )
);


$request['RequestedShipment']['RateRequestTypes'] = 'ACCOUNT';
$request['RequestedShipment']['RateRequestTypes'] = 'LIST';
$request['RequestedShipment']['PackageCount'] = '1';
$request['RequestedShipment']['CarrierCodes'] = 'FXFR';
$request['RequestedShipment']['RequestedPackageLineItems'] = addPackageLineItem1();


try {
    error_log('i am at try');
    if (setEndpoint('changeEndpoint')) {
        $newLocation = $client->__setLocation(setEndpoint('endpoint'));
        error_log('i am at changeEndpoint');
    }

    $response = $client->getRates($request);
    error_log('i am at response okay');
    if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') {
        $rateReply = $response->RateReplyDetails;
        echo '<table border="1">';
        echo '<tr><th>Rate Details</th><th>&nbsp;</th></tr>';
        trackDetails($rateReply, '');
        echo '</table>';

        printSuccess($client, $response);
    } else {
        printError($client, $response);
    }

    writeToLog($client);    // Write to log file   
} catch (SoapFault $exception) {
    printFault($exception, $client);
}


function addRecipient()
{
    $recipient = array(
        'Contact' => array(
            'PersonName' => 'Sender Name',
            'CompanyName' => 'Sender Company Name',
            'PhoneNumber' => '1234567890'
        ),
        'Address' => array(
            'StreetLines' => array('12148 Jollyville Rd'),
            'City' => 'Austin',
            'StateOrProvinceCode' => 'TX',
            'PostalCode' => '78759',
            'CountryCode' => 'US'
        )
    );
    return $recipient;
}

function addShippingChargesPayment()
{
    $shippingChargesPayment = array(
        'PaymentType' => 'SENDER', // valid values RECIPIENT, SENDER and THIRD_PARTY
        'Payor' => array(
            'ResponsibleParty' => array(
                'AccountNumber' => getProperty('freightaccount'),
                'CountryCode' => 'US')
        )
    );
    return $shippingChargesPayment;
}

function addShipper()
{
    $shipper = array
    (
        'Contact' => array
        (
            'PersonName' => 'Rubaiet M',
            'CompanyName' => 'ELS',
            'PhoneNumber' => '019130191355'
        ),
        'Address' => array(
            'StreetLines' => array('1100 E Howard Ln'),
            'City' => 'Austin',
            'StateOrProvinceCode' => 'TX',
            'PostalCode' => '78753',
            'CountryCode' => 'US'
        )
    );
    return $shipper;
} // end of function addShipper

function addPackageLineItem1()
{
    error_log('i am in 152');

    $packageLineItem = array(
        'SequenceNumber' => 1,
        'GroupNumber'       => 1,
        'GroupPackageCount' => 1,
        'Weight' => array(
            'Value' => 450.0,
            'Units' => 'LB'
        ),
        'InsuredValue' => array(
            'Amount' => 695.0,
            'Currency' => "USD"
        ),
        'setGroupPackageCount' => 1
    );
    return $packageLineItem;
}


?>

The FedEx response is :联邦快递的回应是:

The transaction returned an Error.
Severity: ERROR
Source: crs
Code: 2101
Message: Package 1 - Physical packaging type is missing or invalid
LocalizedMessage: Package 1 - Physical packaging type is missing or invalid
Id: PACKAGE_INDEX
Value: 1

I was using RateService_v31.wsdl and still having problem.我正在使用 RateService_v31.wsdl 并且仍然有问题。 But when I swap to RateService_v16.wsdl BOOOM my code is working fine.但是当我切换到 RateService_v16.wsdl BOOOM 时,我的代码运行良好。

Here is the my LTL Freight request code.这是我的 LTL 货运请求代码。 I hope someone having same problem and it can solve the issue.我希望有人有同样的问题,它可以解决问题。

<?php
// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 12.0.0

require_once('../../fedex-common.php5');

$newline = "<br />";
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "../wsdl/RateService_v16.wsdl";

ini_set("soap.wsdl_cache_enabled", "1");

$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' => '16',
    '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']['ServiceType'] = 'FEDEX_FREIGHT_ECONOMY'; // 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']['Shipper'] = getProperty('shipper');
$request['RequestedShipment']['Recipient'] = addRecipient();
$request['RequestedShipment']['ShippingChargesPayment'] = addShippingChargesPayment();
$request['RequestedShipment']['FreightShipmentDetail'] = array(
    'FedExFreightAccountNumber' => getProperty('freightaccount'),
    'FedExFreightBillingContactAndAddress' => getProperty('freightbilling'),
    'PrintedReferences' => array(
        'Type' => 'SHIPPER_ID_NUMBER',
        'Value' => 'RBB1057'
    ),
    'Role' => 'SHIPPER',
    'PaymentType' => 'PREPAID',
    'CollectTermsType' => 'STANDARD',
    'DeclaredValuePerUnit' => array(
        'Currency' => 'USD',
        'Amount' => 50
    ),
    'LiabilityCoverageDetail' => array(
        'CoverageType' => 'NEW',
        'CoverageAmount' => array(
            'Currency' => 'USD',
            'Amount' => '50'
        )
    ),
    'TotalHandlingUnits' => 1,
    'ClientDiscountPercent' => 0,
    'PalletWeight' => array(
        'Units' => 'LB',
        'Value' => 20
    ),
    'ShipmentDimensions' => array(
        'Length' => 90,
        'Width' => 30,
        'Height' => 50,
        'Units' => 'IN'
    ),
    'LineItems' => array(
        'FreightClass' => 'CLASS_085',
        'Packaging' => 'SKID',
        'Weight' => array(
            'Value' => 50.0,
            'Units' => 'LB'
        )
    )
);


$request['RequestedShipment']['RateRequestTypes'] = 'NONE';
$request['RequestedShipment']['PackageCount'] = '1';
$request['RequestedShipment']['CarrierCodes'] = 'FXFR';
$request['RequestedShipment']['RequestedPackageLineItems'] = addPackageLineItem1();


try {
    error_log('i am at try');
    if (setEndpoint('changeEndpoint')) {
        $newLocation = $client->__setLocation(setEndpoint('endpoint'));
        error_log('i am at changeEndpoint');
    }

    $response = $client->getRates($request);
    error_log('i am at response okay');
    if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') {
        $rateReply = $response->RateReplyDetails;
        echo '<table border="1">';
        echo '<tr><th>Rate Details</th><th>&nbsp;</th></tr>';
        trackDetails($rateReply, '');
        echo '</table>';

        printSuccess($client, $response);
    } else {
        printError($client, $response);
    }

    writeToLog($client);    // Write to log file   
} catch (SoapFault $exception) {
    printFault($exception, $client);
}


function addRecipient()
{
    $recipient = array(
        'Contact' => array(
            'PersonName' => 'Sender Name',
            'CompanyName' => 'Sender Company Name',
            'PhoneNumber' => '1234567890'
        ),
        'Address' => array(
            'StreetLines' => array('12148 Jollyville Rd'),
            'City' => 'Austin',
            'StateOrProvinceCode' => 'TX',
            'PostalCode' => '78759',
            'CountryCode' => 'US'
        )
    );
    return $recipient;
}

function addShippingChargesPayment()
{
    $shippingChargesPayment = array(
        'PaymentType' => 'SENDER', // valid values RECIPIENT, SENDER and THIRD_PARTY
        'Payor' => array(
            'ResponsibleParty' => array(
                'AccountNumber' => getProperty('freightaccount'),
                'CountryCode' => 'US')
        )
    );
    return $shippingChargesPayment;
}

function addShipper()
{
    $shipper = array
    (
        'Contact' => array
        (
            'PersonName' => 'Rubaiet M',
            'CompanyName' => 'ELS',
            'PhoneNumber' => '019130191355'
        ),
        'Address' => array(
            'StreetLines' => array('12148 Jollyville Rd'),
            'City' => 'Austin',
            'StateOrProvinceCode' => 'TX',
            'PostalCode' => '78759',
            'CountryCode' => 'US'
        )
    );
    return $shipper;
} // end of function addShipper

function addPackageLineItem1()
{
    $packageLineItem = array(
        'SequenceNumber' => 1,
        'GroupNumber'       => 1,
        'GroupPackageCount' => 1,
        'Weight' => array(
            'Value' => 55.0,
            'Units' => 'LB'
        ),
        'InsuredValue' => array(
            'Amount' => 695.0,
            'Currency' => "USD"
        ),
        'setGroupPackageCount' => 1
    );
    return $packageLineItem;
}


?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM