Solved

XML and USPS Shipping API Question

Posted on 2003-11-10
3
732 Views
Last Modified: 2007-12-19
I know asp3 but have never worked with XML. Im trying to figure out the US Postal services address verification API which is XML based.

I need some help in making a sample vbscript page to post the XML string and to recieve the result.

Heres their docs...
http://www.usps.com/webtools/htm/Address-Information.htm

There are ASP examples on this page
http://www.usps.com/webtools/htm/Domestic-Rates.htm#_Toc26081573

However im haivng difficulty figuring out how to modify the example in the Domestic Rates API to post a valid address lookup XML query as specified in the first document mentioned.

Any ideas? Anyone had to do this before?

Thanks!

-Matt




0
Comment
Question by:mjreine
3 Comments
 
LVL 26

Accepted Solution

by:
rdcpro earned 500 total points
ID: 9723751
The example they show simply creates the XML document.  Then you must post it.  But DO NOT use the WinInet example they show...

The easiest way to do this is with the ServerXMLHTTPRequest object.  This is a server-safe XML posting object.  It's quite easy to use.  Basically, assuming you have an XML document called xmlDoc to post, all you have to do is instantiate the object, open a connection, and send the request.  Like:

Dim srvXmlHttp
Set srvXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
srvXmlHttp.Open "POST", "http://uspsserver/serviceEndPoint.dll", false
srvXmlHttp.Send xmlDoc

' Now just write out the response XML
Response.ContentType = "text/xml"
srvXmlHttp.responseXML.save Response

I'm assuming the API supports POSTing...but if it's only a GET, you'll have to append the XML string as they show in:

sUrl = "http://SERVERNAME/ShippingAPITest.dll?API=Rate&XML=" & xmlDoc.xml

This would be pretty bogus, though, because why use XML if you're simply going to turn it into a query string?  You might have to experiment with setting variouse request headers on the srvXmlHttp object before sending:

e.g.
srvXmlHttp.setRequestHeader "ContentType", "application/xml"


Regards,
Mike Sharp
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now