This made my day a lot shorter, thanks for the hard work.
<!--- 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
--->
This made my day a lot shorter, thanks for the hard work.
I myself am trying to intergrate ups into a web cart that I am creating for my own site. I was easily able to create and manage the above turtorial (which by the way I thank you for),but now I am trying to use the tracking part of the UPS tools and It looks like it wants to pull the data, but is coming up with an error on XML from UPS. I am not totally sure on this and would like some help. Here is my error message:
Expected "" to terminate element starting on line 8.
Expected "
" to terminate element starting on line 8.
The error occurred in C:\CFusionMX\wwwroot\www.clearcg.com\testing XML\Untitled-5.cfm: line 24
22 :
tag there unless it is on the UPS server side. I would just like to know if the error is mine or their's. I am using the "https://wwwcie.ups.com/ups.app/xml/Track" url which is the testing server for them.
Thank you so much for saving me a couple hours of going through the 150 page developer document for such a simple application. Why does UPS make it so hard? Its works great, thanks again! Ryan Jones ryan@other-world.com