Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

XML and USPS Shipping API Question

Posted on 2003-11-10
3
Medium Priority
?
741 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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. 
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

604 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