Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
EnergyFed #1
XML Intergration, help needed!
I am trying to intergrate the UPS Online Tools on my site. I am stuck and
don't know what I can do. I keep getting this error message:
Document root element is missing.
Type org.xml.sax.SAXParseException
Tag Context CFSET: Line=75; Column=1
Source 72:
73: </CFHTTP>
74: <cfhttpparam name="name" type="url" value="#XMLPacket#">
75: <cfset xmlfile = XmlParse(cfhttp.filecontent)>
76: <cfif
xmlfile.RatingServiceSelectionResponse.Response.Re sponseStatusCode.xmlText eq 1>
Here is my Code:
<cfsavecontent variable="XMLPacket">
<cfoutput>
<?xml version="1.0" encoding="utf-8"?>
<AccessRequest xml:lang="en-US">
<AccessLicenseNumber>Number</AccessLicenseNumber>
<UserId>Name</UserId>
<Password>Something</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>Rate</RequestOption>
</Request>
<PickupType>
<Code>01</Code>
</PickupType>
<Shipment>
<Shipper>
<Address>
<PostalCode>01581</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</Shipper>
<ShipTo>
<Address>
<PostalCode>44129</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</ShipTo>
<ShipFrom>
<Address>
<PostalCode>01581</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 ="GET">
</CFHTTP>
<cfhttpparam name="name" type="url" value="#XMLPacket#">
<cfset xmlfile = XmlParse(cfhttp.filecontent)>
<cfif
xmlfile.RatingServiceSelectionResponse.Response.Re sponseStatusCode.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.xm lchildren)
- 1;
xmlqry = QueryNew("code,money");
QueryAddRow(xmlqry,xmlsize);
for(a=1;a lte xmlsize; a=a+1){
QuerySetCell(xmlqry,"code",xmlfile.RatingServiceSe lectionResponse.RatedShipment[
a].Service.Code.xmlText,a);
QuerySetCell(xmlqry,"money",xmlfile.RatingServiceS electionResponse.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>
So what am I doing wrong? Should the XML be saved as an XML page or should I
leave that as a CFM page?
EnergyFed Guest
-
Help needed
Iam runnung a school server connection and need help to remove the infomation that has been put on -
PHP/Flash Intergration
Hello, I've been struggling with this for ages now, so it's time I asked for help. I'm setting up a shopping cart in Flash, using PHP to process the... -
ASP Help Needed
Hi I need some help with the ASP . I need to know how to make Grand total based on Dates . I have the sub total for the dates and like to make... -
ASP.NET and Windows Office intergration
has anyone ever intergrated Office products (word, excel, powerpoint, etc.) into an ASP.NET web application (run in ie). This is a major... -
help needed...
Check what is starting up at machine boot with msconfig "Farid Babadi" <f_babadi@yahoo.com> wrote in message...



Reply With Quote

