Forum Moderators: open
According to the USPS documentation, the XML is sent to "http://testing.shippingapis.com/ShippingAPItest.dll?" & "API=Rate&XML=" & XMLString
The XML and ASP code being used are below. Can anyone help with this? Unfortunately, the USPS technical staff doesn't appear to be too technical. Maybe they'll find someone who actually understands code but then again maybe not.
Thanks,
Robin
**********************************
XML:
<RateRequest USERID="************" PASSWORD="************">
<Package ID="0">
<Service>Express</Service>
<ZipOrigination>27261</ZipOrigination>
<ZipDestination>92110</ZipDestination>
<Pounds>3</Pounds>
<Ounces>8</Ounces>
<Container>None</Container>
<Size>Regular</Size>
<Machinable/>
</Package>
</RateRequest>
***************************************
Code:
<%Function SendXMLFiletoUSPS()%>
<%
Dim RateType
Dim USPSURL
Dim objSrvHTTP
RateType = "API=Rate&XML="
USPSURL = "http://testing.shippingapis.com/ShippingAPItest.dll" & "?" & RateType & strMessage & ""
Set objSrvHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
objSrvHTTP.open "POST", USPSURL, false
objSrvHTTP.SetRequestHeader "Content-Type","application/x-www-form-urlencoded"
objSrvHTTP.send ""
strResponseMessage = objSrvHTTP.responseText
intHTTPStatusCode = objSrvHTTP.status
strHTTPStatusText = objSrvHTTP.statusText
%>
<%End Function%>
Oh, also change this Server.CreateObject("MSXML2.ServerXMLHTTP") to Server.CreateObject("MSXML2.ServerXMLHTTP.3.0") if you have msxml 3.0 or higher installed on the server. It just allows for better performance and some other methods like extending the timeout of the object itself if the remote server is slow in responding back.
Thanks for responding. I will try Server.CreateObject("MSXML2.ServerXMLHTTP.3.0"). In the meantime, I figured out how to send it from a previous post on this forum.
The code is below.
Robin
*****************
<%Function SendXMLFiletoUSPS()%>
<%
Dim RateType
Dim USPSURL
Dim objSrvHTTP
RateType = "API=Rate&XML="
USPSURL = "http://testing.shippingapis.com/ShippingAPITest.dll?"
strXML = RateType & strMessage
Set objSrvHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
objSrvHTTP.open "POST", USPSURL, false
objSrvHTTP.SetRequestHeader "Content-Type","application/x-www-form-urlencoded"
objSrvHTTP.send (strXML)
strResponseMessage = objSrvHTTP.responseText
intHTTPStatusCode = objSrvHTTP.status
strHTTPStatusText = objSrvHTTP.statusText
%>
<%End Function%>