Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP XML Using ASP 3 and XML. See also the XML category for more XML discussions not relating to ASP. NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP XML section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 10th, 2004, 02:57 PM
Authorized User
 
Join Date: Jul 2003
Location: , New Jersey, .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML Transmission to USPS

I am trying to send an XML transmission to the US Postal Service to retrieve shipping rates but so far have been unsuccessful. My latest HTTP Status code is 501 and the HTTP Status text is "Not Implemented". I have no problem sending successful transmissions to both Fedex or UPS but USPS does things differently.

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%>










Reply With Quote
  #2 (permalink)  
Old October 11th, 2004, 05:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Since you're sending the data in the querystring you should use the GET verb, not POST.

Also, you should Server.URLEncode(strMessage) before you send it.
Reply With Quote
  #3 (permalink)  
Old October 12th, 2004, 08:56 PM
Authorized User
 
Join Date: Jul 2003
Location: , New Jersey, .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

pgtips,

Thanks for responding. A post on www.webmasterworld.com put me in the right direction.

Here is the corrected code.

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%>



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xml invalid top level from ASP write XML(solution) g000we XML 0 August 9th, 2006 03:56 AM
DTS Package, XML task. Read XML file and store it Victoria SQL Server DTS 0 July 24th, 2006 02:43 PM
Live shipping rates from FEDEX, UPS and USPS cycbot Classic ASP XML 1 January 4th, 2005 08:27 PM
Data Transmission via VB ashley_y VB How-To 2 September 10th, 2003 08:30 AM



All times are GMT -4. The time now is 07:30 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.