Solved

XML and USPS Shipping API Question

Posted on 2003-11-10
3
735 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

829 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