Thanks for writing back.
Yes, I have a couple questions.
I'm trying to get started with the address verification API.
The USPS requires that you verify you can connect to their site before they will switch you to the "production" server.
I'm not sure, from the doucumentation how to actually do this initial connection. I do have an account, but it's not clear to me if "verification" means I just need to pack up some URL line with parameters and send it to them with my ID embedded or if I need to write some code.
Then, I couldn't find any Java examples of how to package up a SOAP request, ship it off and how to unpack it when it returns.
I bet it's pretty simple; I'm just having trouble getting started.
Any help or suggestions would be greatly appreciated. <s>
I looked at http://www.usps.com/webtools/_pdf/Address-Information.pdf.
It looks like the client will send an xml as an html parameter. It doesnt use soap.
For that reason, maybe you can test right now, by pasting the below at your browser url input, and press enter:
<Address2>6406 Ivy Lane</Address2><City>Greenbelt</City><State>MD</State>
I got this from the documentation I mentioned above.
Replace the SERVERNAME, xxxxxxx and xxxxxxx for the approriate value(server, user, password). And input the address details that you want.
In addition, the entire xml string must be url-encoded. This is quite expected, as it is an html url parameter. For this one, I am not familiar with url encoding; I see spaces in the sample above so you might need to manually url-encode it now before sending it.
Other than that, I think you can test it now.
That pdf seems to give enough details, but is implemented in microsoft technology. So instead of the microsoft dom codes, you might use java. As I have mentioned, it looks like it is pure xml, no soap.
The user and password are exposed, so I think you will have some additional stuff in production, like https.
And then send the html request, along with the html parameters required, like the API parameter (e.g. API=Verify), and the XML(the xml you built)
I am not familiar how to send the html request via java code; maybe via java http connection classes. Also, that class might have methods to encode the url for you.
[ January 08, 2006: Message edited by: Jesus Angeles ]
I got the Java Web Services book at your suggestion, but was disappointed that the very first example I downloaded from their site didn't work. I tried with two different versions of xerces.
I supposed I'd really use JDOM in practice anyway. <s>
Thanks for your other suggestions.
I did the chapter 2 handsons last week. And I wouldnt have been able to run the first one without your posts. The null trick did it. But all the other codes in the chapter went flawlessly.
This chapter 2 has codes that both build xml via dom, and parse an xml using dom(to process it).
Mike London wrote:Has anybody successfully written a WS client that access the USPS Web Service?
The service is cool in principle, but there isn't much documentation.
Look forward to any replies.
This is an old post I'm replying to but info is kind of sparse even now for Java and USPS web tools. Today I got the zip code lookup API working in Java. I used Groovy for the XML part. Here is the Groovy part for putting an address into the required XML form
The user ID is obtained at the USPS web site https://www.usps.com/business/webtools.htm ... Once you register you get access to their test server.
Here is the Groovy code for parsing the XML back into fields