------------------------------------------------------------------------------------- <!--This code will run fine on ColdFusion MX, but not on CF5 --> <!--- Declare Constants ---> <cfset conwayXMLURL = "http://www.Con-way.com/XMLj/X-Rate" /> <cfset rateRequestFormName = "RateRequest" /> <cfset lookForTag = "/RateQuote/NetCharge" /> <cfset errorTag = "/RateQuote/Error" /> <!-- replace the "userId" & "passWd" String values with your Con-way username and password ---> <cfset userId = "userId" /> <cfset passWd = "passWd" /> <cfset today = DateFormat(now(), "mm/dd/yy")> <!-- Rate Request XML. In actual use, you would probably populate the Rating Request parameters (Weights, Classes, Zip Codes, etc.) from data submitted via an on-line order form or database. For this sample we will just hard code some dummy data. ---> <cfset rateRequest = "<RateRequest>" & "<OriginZip country=""us"">97006</OriginZip>" & "<DestinationZip country=""us"">33179</DestinationZip>" & "<ChargeCode>P</ChargeCode>" & "<DiscountRate>100</DiscountRate>" & "<EffectiveDate>#today#</EffectiveDate>" & "<Item>" & "<CmdtyClass>775</CmdtyClass>" & "<Weight unit=""lbs"">667</Weight>" & "</Item>" & "<Item>" & "<CmdtyClass>100</CmdtyClass>" & "<Weight unit=""lbs"">555</Weight>" & "</Item>" & "<Accessorial>SSC</Accessorial>" & "<Accessorial>DNC</Accessorial>" & "<Accessorial>GUR</Accessorial>" & "</RateRequest>" /> <!-- Call the Con-way XML Rating Servlet ---> <cfhttp method="post" url="#conwayXMLURL#" username="#userId#" password="#passwd#"> <cfhttpparam name="#rateRequestFormName#" value="#rateRequest#" type="formfield" /> </cfhttp> <!-- Parse the XML Response and create a DOM Document ---> <cfset rateResponse = xmlParse(cfhttp.fileContent) /> <!-- Look for the desired tag(s) in the DOM Document ---> <!--- If RateQuote was not successful, get the Error message instead ---> <cfscript> rateQuotes = XmlSearch(rateResponse,lookForTag); if (ArrayLen(rateQuotes) EQ 0) rateQuotes = XmlSearch(bolResponse,errorTag); rateQuote = rateQuotes [1].XmlText; </cfscript> <!-- The END !!! Now we can just display the result of this test ---> <HTML> <HEAD> <TITLE>Sample ColdFusion MX for Con-way XML Rating</TITLE> </HEAD> <BODY> <CENTER> <B><FONT face="arial" size=+1><I>Sample ColdFusion MX Con-way Rate Getter</I></FONT></B> </CENTER> <br> <b><font face="Arial, Helvetica, sans-serif">Here is the RateQuote XML output:</font></b> <br> <!-- XML dump of the response from the Con-way XML Servlet ---> <cfdump var="#rateResponse#"> <br> <!-- Print the Tag value we extracted ---> <b><font face="Arial, Helvetica, sans-serif"> Here is the data extracted from an XML tag: <cfoutput> Shipping Charges : #rateQuote#</font></B> </cfoutput> </BODY> </HTML> -------------------------------------------------------------------------------------