2

I am trying to use the USPS Address Standardization Web Tool and integrate it with Adobe AEM Forms. In this link it explains the three steps:

  1. Build the XML Request
  2. Make the Internet Connection & Send the XML Request
  3. Unpack the XML Response

The XML will be built by AEM, what I need to do is append it to the end of the url like so:

https://servername/ShippingAPI.dll?API=Verify&XML=<AddressValidateRequest USERID="XXXXXXXX">[insert XML here]</AddressValidateRequest>

I found this Stack overflow post which explains the HTTP request GET and POST which seems similar to what I am doing:
Send xml as part of URL request in Java

I started writing code off of that post and only got so far..

HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost("https://production.shippingapis.com/ShippingAPI.dll");

List<String> params = new ArrayLIst<String>(2);
params.add(new BasicNameValuePair("API", "Verify"));
params.add(new BasicNameValuePair("XML", FuncTOGenerateXML()));
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));

I understand that the XML that is accepted through AEM:

<AddressValidateRequest USERID="XXXXX">
<Revision>1</Revision>
  <Address ID="0">
    <Address1></Address1>
    <Address2>29851 Aventura #k</Address2>
    <City></City>
    <State>CA</State>
    <Zip5>92688</Zip5>
    <Zip4></Zip4>
  </Address>
</AddressValidateRequest>

will be placed in FuncTOGenerateXML() however, I do not know how to place it there.

Has anyone worked with the USPS API and understand how to use the Address Standardization Web Tool? Also, Adobe AEM Forms would be helpful too.

Thank you.

0 Answers0