Point of Entry Address Validation for .NET

This is a simple Point of Entry Validation example using .NET. The example was written in Visual Studio 2005 using the .NET Framework 2.0.

Getting Started

  • Generate PostMLService.cs: Run WseWsdl3 which should be located in your WSE 3.0 installation directory

    (WseWsdl3.exe /type:webClient /nologo /namespace:DuoShare.Webservices postML.wsdl)
  • Create a new console application in Visual Studio.
  • Add the newly generated PostMLService.cs file to your project.
  • Right click References, find and add Microsoft.Web.Services3, System.Web.Services, and System.Security

    to the project.

Sample Code

In Program.cs, add the following code:

using System.Security;
using System.Net;
using System.Net.Security;
using DuoShare.Webservices;
using Microsoft.Web.Services3.Security.Tokens;
using Microsoft.Web.Services3.Security;
using Microsoft.Web.Services3.Design;

In your main method, create an instance of postML:

PostMLService service = new PostMLService()

Add the following code right after the PostML initialization in Main:

string username = "YourUserName";
string password = "YourPassword";
long? customerPk = null; //This should be your account's customer primary key... it won't work without it 

UsernameToken token = new UsernameToken(username, password, PasswordOption.SendPlainText);
Policy policy = new Policy(); 
policy.Assertions.Add(new UsernameOverTransportAssertion()); 
 
service.SetClientCredential(token); 
service.SetPolicy(policy); 

To validate an address:

//You can remove the vowels for most city and street names to save
//keystrokes when validating an address 
WsPostalinputRecord record = new WsPostalinputRecord();
record.deliveryaddressline1Input = "10401 mllr rd #150";
record.lastlineinput = "dlls tx 75238";

record.customerpk = customerPk;
 
WsPostaloutputRecord output = service.validateInteractive(record);

Console.WriteLine (output.deliveryaddressline1Answer);
Console.WriteLine(output.lastlineanswer);
Console.Read();

Helpful Documents

Getting Started with Web Services

A quick guide to using DuoShare's SOAP-based web services

Record Class Documentation

Definitions for the request and response fields used for Interactive Validation