?
Solved

XML and USPS Shipping API Question

Posted on 2003-11-10
3
Medium Priority
?
738 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 26

Accepted Solution

by:
rdcpro earned 2000 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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, …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

777 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