<!--- Before you start reading this tutorial,
I suggest you read the ups documentation
first and apply the xml developer access key--->
<!--- Please visite www.ec.ups.com to have your access key --->
<!--- You can add the special servcie by change the xml code below, for example saturday pick up service--->
<!--- Build UPS XML Packet --->
<cfsavecontent variable="XMLPacket"><cfoutput>
<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
<AccessLicenseNumber>#accessLicenseNumber#</AccessLicenseNumber>
<UserId>#userid#</UserId>
<Password>#password#</Password>
</AccessRequest>
<?xml version="1.0"?>
<RatingServiceSelectionRequest xml:lang="en-US">
<Request>
<TransactionReference>
<CustomerContext>Bare Bones Rate Request</CustomerContext>
<XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<RequestAction>Rate</RequestAction>
<RequestOption>Shop</RequestOption>
</Request>
<PickupType>
<Code>01</Code>
</PickupType>
<Shipment>
<Shipper>
<Address>
<PostalCode>11214</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</Shipper>
<ShipTo>
<Address>
<PostalCode>07083</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</ShipTo>
<ShipFrom>
<Address>
<PostalCode>11213</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</ShipFrom>
<Service>
<Code>01</Code>
</Service>
<Package>
<PackagingType>
<Code>02</Code>
</PackagingType>
<Dimensions>
<UnitOfMeasurement>
<Code>IN</Code>
</UnitOfMeasurement>
<Length>20</Length>
<Width>20</Width>
<Height>20</Height>
</Dimensions>
<PackageWeight>
<UnitOfMeasurement>
<Code>LBS</Code>
</UnitOfMeasurement>
<Weight>23</Weight>
</PackageWeight>
</Package>
</Shipment>
</RatingServiceSelectionRequest></cfoutput></cfsavecontent>
<cfhttp url="https://www.ups.com/ups.app/xml/Rate"
port="443" method
="POST"
throwonerror="yes">
<cfhttpparam name="name"
type="XML" value="#XMLPacket#">
</cfhttp>
<cfset xmlfile = XmlParse(CFHTTP.FileContent)>
<cfif xmlfile.RatingServiceSelectionResponse.Response.ResponseStatusCode.xmlText eq 1>
<!--- the code below you may think familiar, yes. I grab it from tutorial195.easycfm.com --->
<!--- If you don't understand the code below, i suggest you go to original author's tutorial --->
<cfscript>
xmlsize = arrayLen(xmlfile.RatingServiceSelectionResponse.xmlchildren) - 1;
xmlqry = QueryNew("code,money");
QueryAddRow(xmlqry,xmlsize);
for(a=1;a lte xmlsize; a=a+1){
QuerySetCell(xmlqry,"code",xmlfile.RatingServiceSelectionResponse.RatedShipment[a].Service.Code.xmlText,a);
QuerySetCell(xmlqry,"money",xmlfile.RatingServiceSelectionResponse.RatedShipment[a].TotalCharges.MonetaryValue.xmlText,a);
}
</cfscript>
<cfquery
name="ups"
dbtype="query">
select *
from xmlqry
</cfquery>
<!--- the code below show the method of shipping and the price --->
<cfoutput query="ups">
UPS(<cfswitch
expression="#code#">
<cfcase
value="01">Next Day Air</cfcase>
<cfcase value="02">2nd Day Air</cfcase>
<cfcase value="03">Ground</cfcase>
<cfcase value="07">Worldwide Express</cfcase>
<cfcase value="08">Worldwide Expedited</cfcase>
<cfcase value="11">Standard</cfcase>
<cfcase value="12">3 Day Select</cfcase>
<cfcase value="13">Next Day Air Saver</cfcase>
<cfcase value="14">Next Day Air Early A.M.</cfcase>
<cfcase value="54">Worldwide Express Plus</cfcase>
<cfcase value="59">UPS 2nd Day Air A.M.</cfcase>
<cfcase value="64">n/a</cfcase>
<cfcase value="65">UPS Express Saver</cfcase>
</cfswitch>) #money#
</cfoutput>
</cfif>
<!--- If you like to see the live demo of the code , please
visit my site --->
<!--- http://www.anawholesale.com/product.cfm
--->