This Visual Basic sample demonstrates how to send and receive XML messages with Jet Delivery's API using MSXML 4.0. Be sure to set a reference to "Microsoft XML, v4.0" or higher in your Visual Basic project.
Setup Notes
- Set a reference to
Microsoft XML, v4.0
or later. - Replace
<xmlsacn>
with your company account number. - Replace
<xmlsuid>
with your Jet Delivery license access number.
Sample Scenario
This example sends an XML message requesting a quote for a shipment from Los Angeles, CA (90021) to San Diego, CA (92050) containing 2 pieces weighing 50 pounds. The response includes estimated delivery time and price.
Visual Basic Sample Code
' Sample VB Code to send XML and receive response
Sub xmlGetQuote()
Dim objXMLhttp As New MSXML2.xmlHttp
Dim objXMLfileSnd As New MSXML2.DOMDocument
Dim objXMLfileRcv As New MSXML2.DOMDocument
Dim strXMLsend As String
Dim strXMLreply As String
strXMLsend = "" & _
"" & _
"" & _
"44710 " & _
"446546456 " & _
"45hd89s87 " & _
" " & _
"" & _
"90021 " & _
"92050 " & _
"2 " & _
"50 " & _
"IMMEDIATE " & _
"TRK " & _
"" & xmlDate(Date) & " " & _
"" & xmlDate(Date) & " " & _
"
" & _
" "
objXMLfileSnd.loadXML strXMLsend
If objXMLfileSnd.parseError.errorCode Then Exit Sub
objXMLhttp.Open "POST", "http://rest.jetdelivery.com/xml/data/index.asp?action=quote", False
objXMLhttp.setRequestHeader "Content-type", "application/xml"
objXMLhttp.send objXMLfileSnd
objXMLfileRcv.async = False
objXMLfileRcv.loadXML objXMLhttp.responseText
strXMLreply = objXMLhttp.responseText
MsgBox strXMLreply
End Sub
Function xmlDate(inVar)
xmlDate = Format(inVar, "yyyy-mm-dd")
End Function
For more details on Jet Delivery integrations, visit the Developer Center.