Solved

XML and USPS Shipping API Question

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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. 
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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