This sample demonstrates how to send and receive an XML quote request to Jet Delivery's API using classic ASP.
Note: This example assumes your server is running Microsoft IIS 5.0 or higher.
client.asp
Paste the following code into a file named client.asp
:
<%
' ASP Sample: Send XML Quote Request to Jet Delivery
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"))
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></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>" & _
"</Quote></XMLST>"
Set objXMLhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
objXMLhttp.Open "POST", "https://rest.jetdelivery.com/xml/data/index.asp?action=quote", False
objXMLhttp.setRequestHeader "Content-type", "application/xml"
objXMLhttp.Send strXML
Response.ContentType = "text/html"
Response.Write objXMLhttp.responseText
Function xmlDate(inVar)
If IsDate(inVar) Then
Dim m, d
m = Right("0" & Month(inVar), 2)
d = Right("0" & Day(inVar), 2)
xmlDate = Year(inVar) & "-" & m & "-" & d
Else
xmlDate = ""
End If
End Function
%>
inputdata.htm
Paste this form code into a separate file named inputdata.htm
in the same directory:
<html>
<head>
<title>Jet Delivery XML Sample Form</title>
</head>
<body>
<form method="POST" action="client.asp">
<p>Origin Zip: <input type="text" name="Origin"></p>
<p>Destination Zip: <input type="text" name="Destination"></p>
<p>Pieces: <input type="text" name="Pieces"></p>
<p>Weight (lbs): <input type="text" name="Weight"></p>
<p>Service Type:
<select name="Service">
<option value="WHITEGLOVE">White Glove</option>
<option value="IMMEDIATE">Immediate</option>
<option value="NEXTFLIGHT">Next Flight</option>
<option value="DAILY">Daily</option>
</select>
</p>
<p>Pickup Date: <input type="text" name="PickupDate" placeholder="YYYY-MM-DD"></p>
<p>Pickup Time: <input type="text" name="PickupTime" placeholder="HH:MM"></p>
<p>Response Type:
<input type="radio" name="rspwntype" value="xml" checked> XML
<input type="radio" name="rspwntype" value="html"> HTML
</p>
<p><input type="submit" value="Send Request"></p>
</form>
</body>
</html>