Quote Request | Sample Code
   
Notes:

 
The following code should be used on a server running Microsoft IIS 5.0 or higher.

 ----

 

Create two files; one named "client.asp" and another named "inputdata.htm". Next copy and paste each of the following code snippets into the specified file. Finally launch the "inputdata.htm" file, fill in it's form fields, hit "Send" and watch the magic! NOTE: Both files should be in the same directory.  
 


Copy and paste the following code into a file named client.asp

<%
'#------------------------------------------------------------------------
'#
'# File: client.asp
'#
'# Purpose: Send and Receive XML quote requests.
'#
'# Description: This is a sample function used to handle XML
'# quote requests.
'#
'# Author: Jason Barbata
'#
'# Created: December 12, 2004
'#
'#-------------------------------------------------------------------------
'#==== Begin Script ====
'#
'# Collect information submitted from the form!
 Origin = Cstr(Request("Origin"))
 Destination = Cstr(Request("Destination"))
 Pieces = Cstr(Request("Pieces"))
 Weight = Cstr(Request("Weight"))
 Service = Cstr(Request("Service"))
 PickupDate = Cstr(Request("PickupDate"))
 PickupTime = Cstr(Request("PickupTime"))
 rspwntype = Cstr(Request("rspwntype"))

'# Build the XML string to send to Shipline Security!
 strXML = "<?xml version='1.0' encoding='UTF-8'?><XMLST xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><RequestHeader><xmlsacn>44710</xmlsacn><xmlsuid>446546456</xmlsuid><xmlstrn>45hd89s87</xmlstrn></RequestHeader><Quote><PickupZip>" & Origin & "</PickupZip><DeliverZip>" & Destination & "</DeliverZip><Pieces>" & Pieces & "</Pieces><Weight>" & Weight & "</Weight><ServiceType>" & Service & "</ServiceType><VehicleType>TRK</VehicleType><Pickupdate>" & xmlDate(PickupDate) & "</Pickupdate><Pickuptime>" & PickupTime & "</Pickuptime><Deliverdate>" & xmlDate(PickupDate) & "</Deliverdate><Deliverfrom></Deliverfrom><Deliverto></Deliverto></Quote></XMLST>"

'# Set Objects
 Set objXMLhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
 Set objXMLfileRcv = Server.CreateObject("Msxml2.DomDocument")

'# Send XML string off for processing!
 objXMLhttp.Open "POST", "http://rest.Shiplinesecurity.com/xml/data/index.asp?action=quote", False
 objXMLhttp.setRequestHeader "Content-type", "application/xml"
 objXMLhttp.Send(strXML)

'# Take XML response from Shipline Security.
 objXMLfileRcv.async = False
 loaded = objXMLfileRcv.loadXML(objXMLhttp.responseText)
 strXMLreply = objXMLhttp.responseText


If rspwntype = "xml" Then '<-- Display raw XML response!
 '################################
 '### Write the raw response! ###
 '################################
 Response.Write objXMLhttp.responseText


ElseIf rspwntype = "html" Then '<-- Parse the XML response
 '########################################
 '### Parse and clean up the response ###
 '########################################
 If loaded = True Then '#<-- Begin parsing the response.

 '# Get the unique identifier.
  Set xmlstrnNode = objXMLfileRcv.selectSingleNode("XMLST/ReplyHeader/xmlstrn")
  If Not xmlstrnNode Is Nothing Then
   xmlstrn = xmlstrnNode.Text
  End If

 '# Check for errors!
  Set ErrorLst = objXMLfileRcv.getElementsByTagName("Error")
  errCnt = ErrorLst.Length
 If errCnt <> 0 Then
   Response.Write("<b>Woops one or more errors have occured!</b><br>")
   For i = 0 to (errCnt - 1)
    thisErrorN = objXMLfileRcv.getElementsByTagName("Code").item(i).text '<- Specific Err Type!
    thisErrorM = objXMLfileRcv.getElementsByTagName("Message").item(i).text '<- Specific Err Type!
    'thisError = ErrorLst.item(i).text '<-- Get all elements in this error!
    Response.Write(thisErrorN & " - " & thisErrorM & "<br>")
   Next


 Else
 '# Shipment Origin. #<-- Not required but used in this example!
  Set OriginNode = objXMLfileRcv.selectSingleNode("XMLST/Quote/Origin")
   Origin = OriginNode.Text

 '# Shipment Destination.
  Set DestinationNode = objXMLfileRcv.selectSingleNode("XMLST/Quote/Destination")
   Destination = DestinationNode.Text

 '# Estimated Delivery Date.
  Set EstimatedDeliveryDateNode = objXMLfileRcv.selectSingleNode("XMLST/Quote/EstimatedDeliveryDate")
   EstimatedDeliveryDate = EstimatedDeliveryDateNode.Text

 '# Estimated Delivery Time.
  Set EstimatedDeliveryTimeNode = objXMLfileRcv.selectSingleNode("XMLST/Quote/EstimatedDeliveryTime")
   EstimatedDeliveryTime = EstimatedDeliveryTimeNode.Text

 '# Delivery Time Zone.
  Set DeliveryTimeZoneNode = objXMLfileRcv.selectSingleNode("XMLST/Quote/DeliveryTimeZone")
   DeliveryTimeZone = DeliveryTimeZoneNode.Text

 '# Confirmed Service Type.
  Set ServiceTypeNode = objXMLfileRcv.selectSingleNode("XMLST/Quote/ServiceType")
   ServiceType = ServiceTypeNode.Text

 '# Confirmed Vehicle Type.
  Set VehicleTypeNode = objXMLfileRcv.selectSingleNode("XMLST/Quote/VehicleType")
   VehicleType = VehicleTypeNode.Text

 '# Estimated Price.
  Set EstimatedPriceNode = objXMLfileRcv.selectSingleNode("XMLST/Quote/EstimatedPrice")
   EstimatedPrice = EstimatedPriceNode.Text

Response.Write("TRNS: " & xmlstrn & "<br><br>" & "Origin: " & Origin & "<br>" & "Destin: " & Destination & "<br>" & "E.T.A: " & FormatDateTime(EstimatedDeliveryDate, 1) & " (at) " & FormatDateTime(EstimatedDeliveryTime, 3) & " " & DeliveryTimeZone & "<br>" & "sType: " & ServiceType & "<br>" & "vType: " & VehicleType & "<br>" & "Price: " & FormatCurrency(EstimatedPrice))
End If

End If
End If

'# Clean up!
Set objXMLhttp = Nothing
%>

<%
'--- BEGIN FUNCTIONS ---
Function xmlDate(inVar)
 If IsDate(inVar) = True Then
  If Len(DatePart("m", inVar)) = 1 Then
   If Len(DatePart("d", inVar)) = 1 Then xmlDate = DatePart("yyyy", inVar) & "-" & "0" & DatePart("m", inVar) & "-" & "0" & DatePart("d", inVar) Else xmlDate = DatePart("yyyy", inVar) & "-" & "0" & DatePart("m", inVar) & "-" & DatePart("d", inVar)
  Else
   xmlDate = DatePart("yyyy", inVar) & "-" & DatePart("m", inVar) & "-" & DatePart("d", inVar)
  End If
 End If
End Function
%>


Next copy and paste this HTML into a file named inputdata.htm

<html>

<head>
<title>Shipline Security XML Sample | inputdata.htm</title>
<meta name="Microsoft Border" content="b, default">
</head>

<body>

<table border="0" width="100%">
<form method="POST" action="client.asp">
<tr>
<td><font face="Verdana"><span lang="en-us"><font size="2">&nbsp;</font></span>
<input type="text" name="Origin" size="8"><span lang="en-us"><font size="2"> Origin Zip-Code<br>&nbsp;</font></span>
<input type="text" name="Destination" size="8"><span lang="en-us"><font size="2"> Destination Zip-Code<br>&nbsp;</font></span>
<input type="text" name="Pieces" size="4"><span lang="en-us"><font size="2"> Pieces<br>&nbsp;</font></span>
<input type="text" name="Weight" size="4"><span lang="en-us"><font size="2"> Weight<br><br>&nbsp;</font></span> </font><small><small>
<select name="Service" size="1" tabindex="1" style="font-size: 10pt">
<option value="WHITEGLOVE">&gt; White Glove</option>
<option value="IMMEDIATE">&gt; Immediate</option>
<option value="NEXTFLIGHT" selected>&gt; Next Flight</option>
<option value="DAILY">&gt; Daily</option>
</select></small></small><span lang="en-us"><font size="2" face="Verdana"> Service Type<br></font></span><font face="Verdana"><span lang="en-us"><font size="2"> <br>&nbsp;</font></span> </font>
<input type="text" name="PickupDate" size="10"><span lang="en-us"><font size="2" face="Verdana"> </font></span><font face="Verdana"><span lang="en-us"><font size="2"> Ready Date<br>&nbsp;</font></span>
<select size="1" name="PickupTime" tabindex="2" style="font-size: 10pt">
<option selected value="Now!">NOW!</option>
<option value="07:00">7:00 AM</option>
<option value="07:15">7:15 AM</option>
<option value="07:30">7:30 AM</option>
<option value="07:45">7:45 AM</option>
<option value="08:00">8:00 AM</option>
<option value="08:15">8:15 AM</option>
<option value="08:30">8:30 AM</option>
<option value="08:45">8:45 AM</option>
<option value="09:00">9:00 AM</option>
<option value="09:15">9:15 AM</option>
<option value="09:30">9:30 AM</option>
<option value="09:45">9:45 AM</option>
<option value="10:00">10:00 AM</option>
<option value="10:15">10:15 AM</option>
<option value="10:30">10:30 AM</option>
<option value="10:45">10:45 AM</option>
<option value="11:00">11:00 AM</option>
<option value="11:15">11:15 AM</option>
<option value="11:30">11:30 AM</option>
<option value="11:45">11:45 AM</option>
<option value="12:00">12:00 PM</option>
<option value="12:15">12:15 PM</option>
<option value="12:30">12:30 PM</option>
<option value="12:45">12:45 PM</option>
<option value="13:00">1:00 PM</option>
<option value="13:15">1:15 PM</option>
<option value="13:30">1:30 PM</option>
<option value="13:45">1:45 PM</option>
<option value="14:00">2:00 PM</option>
<option value="14:15">2:15 PM</option>
<option value="14:30">2:30 PM</option>
<option value="14:45">2:45 PM</option>
<option value="15:00">3:00 PM</option>
<option value="15:15">3:15 PM</option>
<option value="15:30">3:30 PM</option>
<option value="15:45">3:45 PM</option>
<option value="16:00">4:00 PM</option>
<option value="16:15">4:15 PM</option>
<option value="16:30">4:30 PM</option>
<option value="16:45">4:45 PM</option>
<option value="17:00">5:00 PM</option>
<option value="17:15">5:15 PM</option>
<option value="17:30">5:30 PM</option>
<option value="17:45">5:45 PM</option>
<option value="18:00">6:00 PM</option>
<option value="18:15">6:15 PM</option>
<option value="18:30">6:30 PM</option>
<option value="18:45">6:45 PM</option>
<option value="19:00">7:00 PM</option>
<option value="19:15">7:15 PM</option>
<option value="19:30">7:30 PM</option>
<option value="19:45">7:45 PM</option>
<option value="20:00">8:00 PM</option>
<option value="20:15">8:15 PM</option>
<option value="20:30">8:30 PM</option>
<option value="20:45">8:45 PM</option>
<option value="21:00">9:00 PM</option>
<option value="21:15">9:15 PM</option>
<option value="21:30">9:30 PM</option>
<option value="21:45">9:45 PM</option>
<option value="22:00">10:00 PM</option>
<option value="22:15">10:15 PM</option>
<option value="22:30">10:30 PM</option>
<option value="22:45">10:45 PM</option>
<option value="23:00">11:00 PM</option>
<option value="23:15">11:15 PM</option>
<option value="23:30">11:30 PM</option>
<option value="23:45">11:45 PM</option>
<option value="00:01">12:00 AM</option>
<option value="01:00">1:00 AM</option>
<option value="01:15">1:15 AM</option>
<option value="01:30">1:30 AM</option>
<option value="01:45">1:45 AM</option>
<option value="02:00">2:00 AM</option>
<option value="02:15">2:15 AM</option>
<option value="02:30">2:30 AM</option>
<option value="02:45">2:45 AM</option>
<option value="03:00">3:00 AM</option>
<option value="03:15">3:15 AM</option>
<option value="03:30">3:30 AM</option>
<option value="03:45">3:45 AM</option>
<option value="04:00">4:00 AM</option>
<option value="04:15">4:15 AM</option>
<option value="04:30">4:30 AM</option>
<option value="04:45">4:45 AM</option>
<option value="05:00">5:00 AM</option>
<option value="05:15">5:15 AM</option>
<option value="05:30">5:30 AM</option>
<option value="05:45">5:45 AM</option>
<option value="06:00">6:00 AM</option>
<option value="06:15">6:15 AM</option>
<option value="06:30">6:30 AM</option>
<option value="06:45">6:45 AM</option>
</select><span lang="en-us"><font size="2"> Ready Time</font></span></font></p>
<table border="0" width="100%" id="table7">
<tr>
<td><hr></td>
<td width="266">&nbsp;</td>
</tr>
</table>
<font face="Verdana"><span lang="en-us"><font size="2">
&nbsp;<b><img border="0" src="http://www.Shiplinesecurity.com/images/xml.gif" width="36" height="14"> </b>|<b> Response
Options: </b><br>
&nbsp;<input type="radio" value="xml" name="rspwntype" checked> Just show the response
in it's raw XML format.<br>
&nbsp;<input type="radio" value="html" name="rspwntype"> Take the XML data returned, and
put some HTML around it.</font></span></font></p><p><span lang="en-us">&nbsp;</span><input type="submit" value="Send" name="B1"><span lang="en-us">
</span>
</form>
</table>
</body>
</html>