'Physical packaging type is missing or invalid
I am able to receive rates from FedEx API with my PHP library. But its only regular request. When I try to have Freight LTL Rate API request it shows me error one by one. I almost fixed most of them but still having problem with Physical packaging type is missing or invalid.
I tried to figure out where is the problem with WSDL file but no luck. There is nothing in there.
If you have any working example for Freight LTL please answer me. 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> </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
Solution 1:[1]
You can use Match()
Sub Tester()
Dim my_sheet1 As Worksheet, my_sheet2 As Worksheet
Dim last_row1 As Long, last_row2 As Long, x As Long
Dim DataRange As Range, colHeader As String, m, res
Set my_sheet1 = ThisWorkbook.Worksheets("Sheet1")
Set my_sheet2 = ThisWorkbook.Worksheets("Sheet2")
last_row1 = my_sheet1.Range("A" & Rows.Count).End(xlUp).Row
last_row2 = my_sheet2.Range("A" & Rows.Count).End(xlUp).Row
Set DataRange = my_sheet2.Range("A2:BA" & last_row2)
colHeader = "Worker_Name" 'column to return results from
'find the column position
m = Application.Match(colHeader, DataRange.Rows(1), 0)
If Not IsError(m) Then 'got a match?
For x = 2 To last_row1
'use the found column
res = Application.VLookup(my_sheet1.Range("A" & x).Value, DataRange, m, False)
my_sheet1.Range("D" & x).Value = IIf(IsError(res), "", res) 'check for no match
Next x
Else
MsgBox "Column header '" & colHeader & "' not found", vbExclamation
End If
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tim Williams |
