PAVv3 JAVA

From CDYNE Wiki
Jump to: navigation, search

Verify Address

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.util.Map;
import java.util.Properties;
 
import javax.xml.namespace.QName;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.http.HTTPBinding;
 
import org.w3c.dom.Document;
 
public final class VerifyAddress{
 
public static void main(String[] args) {
 
String LicenseKey = "(Your License Key)";
 
try{
URL url = new URL("http://pav3.cdyne.com/PavService.svc/VerifyAddress?FirmOrRecipient=Cdyne+Corporation&PrimaryAddressLine=2125+Smith+Ave&SecondaryAddressLine=&Urbanization=&CityName=Chesapeake&State=VA&ZipCode=23320&LicenseKey="+LicenseKey);
try{
InputStream in = url.openStream();
 
StreamSource source = new StreamSource(in);
 
printResult(source);
 
}catch(java.io.IOException e){
e.printStackTrace();
}
 
}catch (MalformedURLException e){
e.printStackTrace();
}
 
}
 
private static void printResult(Source source) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
StreamResult sr = new StreamResult(bos);
Transformer trans = TransformerFactory.newInstance().newTransformer();
Properties oprops = new Properties();
oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
trans.setOutputProperties(oprops);
trans.transform(source, sr);
System.out.println("**** Response ******");
System.out.println(bos.toString());
bos.close();
System.out.println();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Personal tools
Namespaces

Variants
Actions
Navigation
Tools

Trial Key