------------------------------------------------------------------------------------- <!--This code will run fine on ColdFusion MX, but not on CF5 --> <!--- Declare Constants ---> <cfset conwayXMLURL = "http://www.Con-way.com/XMLj/X-BOL" /> <cfset bolRequestFormName = "BOLrequest" /> <cfset statusTag = "/BOLresponse/Status" /> <cfset errorTag = "/BOLresponse/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")> <!--- Build Bill of Lading Request XML In actual use, you would probably populate the BOL 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 bolRequest = "<BOLrequest testmode=""Y"">" & "<RequesterUserId shipcode=""S"">#userId#</RequesterUserId>" & "<ChargeCode>P</ChargeCode>" & "<PRONmbr></PRONmbr>" & "<CustRefNmbrs>" & "<PurchaseOrderNmbr>3338889</PurchaseOrderNmbr>" & "<PurchaseOrderNmbr>3338890</PurchaseOrderNmbr>" & "<OtherRefNmbr refcode=""SKU"" refdesc=""SKU Number"">3213A</OtherRefNmbr>" & "<OtherRefNmbr refcode=""UPC"" refdesc=""UPC number"">789283</OtherRefNmbr>" & "</CustRefNmbrs>" & "<Shipper>" & "<ShipperName>Alan Shipley</ShipperName>" & "<ShipperAddr>1234 NE Main</ShipperAddr>" & "<ShipperCity>Portland</ShipperCity>" & "<ShipperState>OR</ShipperState>" & "<ShipperZip country=""US"">97202</ShipperZip>" & "<ShipperPhone extension=""6055"">800-555-1212</ShipperPhone>" & "<ShipperEmail>youremail@yourcompany.com</ShipperEmail>" & "</Shipper>" & "<COD>" & "<CODremitTo>" & "<CODremitToName>Albert Cod</CODremitToName>" & "<CODremitToAddr>1234 NE Main</CODremitToAddr>" & "<CODremitToCity>Portland</CODremitToCity>" & "<CODremitToState>OR</CODremitToState>" & "<CODremitToZip country=""US"">97202</CODremitToZip>" & "</CODremitTo>" & "<CODamount pmttype=""CustomerCheck"" chargecode=""P"">4444.44</CODamount>" & "</COD>" & "<Consignee>" & "<ConsigneeCustNmbr>883885</ConsigneeCustNmbr>" & "<ConsigneePhone extension=""6666"">503.450.6436</ConsigneePhone>" & "<ConsigneeEmail>web.support@Con-way.com</ConsigneeEmail>" & "</Consignee>" & "<Item>" & "<Quantity pkgtype=""PLT"">44</Quantity>" & "<Weight unit=""lbs"">667</Weight>" & "<Description>widget-arms</Description>" & "<CmdtyClass>775</CmdtyClass>" & "<NMFClass></NMFClass>" & "<HazMat>N</HazMat>" & "</Item>" & "<Item>" & "<Quantity pkgtype=""PCS"">11</Quantity>" & "<Weight unit=""lbs"">789</Weight>" & "<Description>cam-shafts</Description>" & "<CmdtyClass>100</CmdtyClass>" & "<NMFClass></NMFClass>" & "<HazMat>N</HazMat>" & "</Item>" & "<Accessorial chargecode=""P"">GUR</Accessorial>" & "<Accessorial chargecode=""C"">DID</Accessorial>" & "<Accessorial chargecode=""C"">DST</Accessorial>" & "<ShippingRemarks>TEST TEST TEST</ShippingRemarks>" & "<EmergencyContact></EmergencyContact>" & "<PickupRequest>" & "<PickupDate>#today#</PickupDate>" & "<PickupReadyTime>11:00 am</PickupReadyTime>" & "<DockCloseTime>7:00 pm</DockCloseTime>" & "<ContactName>Frank</ContactName>" & "<ContactCompany>Franklin Arms</ContactCompany>" & "<ContactPhone>(333)444-4321</ContactPhone>" & "</PickupRequest>" & "<SendBOLemail/>" & "</BOLrequest>" /> <!-- Call the Con-way XML Bill of Lading Servlet ---> <cfhttp method="post" url="#conwayXMLURL#" username="#userId#" password="#passwd#"> <cfhttpparam name="#bolRequestFormName#" value="#bolRequest#" type="formfield" /> </cfhttp> <!-- Parse the XML Response and create a DOM Document ---> <cfset bolResponse = xmlParse(cfhttp.fileContent) /> <!-- Look for the desired tag(s) in the DOM Document ---> <!--- If BOL was not successful, get the Error message instead ---> <cfscript> bolStati = XmlSearch(bolResponse,statusTag); if (ArrayLen(bolStati) EQ 0) bolStati = XmlSearch(bolResponse,errorTag); bolStatus = bolStati [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 Bill of Lading</I></FONT></B> </CENTER> <br> <b><font face="Arial, Helvetica, sans-serif">Here is the Bill of Lading Response XML output:</font></b> <br> <!-- XML dump of the response from the Con-way XML Servlet ---> <cfdump var="#bolResponse#"> <br> <br> <!-- Print the Tag value we extracted ---> <b><font face="Arial, Helvetica, sans-serif"> <cfoutput>Here is the data extracted from an XML tag: BOL Request Status: #bolStatus#</font></B> </cfoutput> </BODY> </HTML> -------------------------------------------------------------------------------------