Point of Entry Address Validation with Web Services (.NET)
This example is a VERY simplistic integration example for integrating an application with DuoShare. You can get more information about DuoShare and request an account through our website or contact our Sales Department at 214-691-4884. You will not be able to run this example without an account to connect to DuoShare's service.
This example was written in Visual Studio 2005 using the .Net framework 2.0. You will also need to download WSE 3 from Microsoft at the link below. http://msdn.microsoft.com/webservices/webservices/building/wse/default.aspx
Reference documentation for the record classes is available here.
First, obtain a developer login and password from DuoShare and then get the PostML wsdl at this link:
https://duoshare.com/dsWS/services/PostML/wsdlSave this wsdl on your computer and run WseWsdl3, which should be located in your WSE 3.0 installation directory:
WseWsdl3.exe /type:webClient /nologo /namespace:DuoShare.Webservices postML.wsdl
This will generate PostMLService.cs
Create a new console application in Visual Studio. Name it
Interactive Test
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.
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 this next bit of code right after the PostML initialization in Main:
stringusername ="YourUserName";stringpassword ="YourPassword";long?customerPk =null;//This should be your account's customer primary key... it won't work without it UsernameTokentoken =newUsernameToken(username, password,PasswordOption.SendPlainText);Policypolicy =newPolicy(); policy.Assertions.Add(newUsernameOverTransportAssertion()); service.SetClientCredential(token); service.SetPolicy(policy);
That concludes the security portion of this example. Now it's time to validate an address.
//You can remove the vowels for most city and street names to save //keystrokes when validating an address WsPostalinputRecordrecord =newWsPostalinputRecord(); record.deliveryaddressline1Input ="10401 mllr rd #150"; record.lastlineinput ="dlls tx 75238"; record.customerpk = customerPk;WsPostaloutputRecordoutput = service.validateInteractive(record);Console.WriteLine (output.deliveryaddressline1Answer);Console.WriteLine(output.lastlineanswer);Console.Read();
The entirety of Program.cs is below for completeness.
usingSystem.Security;usingSystem.Net;usingSystem.Net.Security;usingDuoShare.Webservices;usingMicrosoft.Web.Services3.Security.Tokens;usingMicrosoft.Web.Services3.Security;usingMicrosoft.Web.Services3.Design;namespaceInteractiveTest {static classProgram{static voidMain() {//Initialize PostmL PostMLServiceservice =newPostMLService();//Your username and passwordstringusername ="YourUserName";stringpassword ="YourPassword";long? customerPk =null;//This should be your account's customer primary key... it won't work without it //Username token for webservices UsernameTokentoken =newUsernameToken(username, password,PasswordOption.SendPlainText);Policypolicy =newPolicy(); policy.Assertions.Add(newUsernameOverTransportAssertion()); service.SetClientCredential(token); service.SetPolicy(policy);//You can remove the vowels for most city and street names to save //keystrokes when validating an address WsPostalinputRecordrecord =newWsPostalinputRecord(); record.deliveryaddressline1Input ="10401 mllr rd #150"; record.lastlineinput ="dlls tx 75238"#59; record.customerpk = customerPk;WsPostaloutputRecordoutput = service.validateInteractive(record);Console.WriteLine(output.deliveryaddressline1Answer);Console.WriteLine(output.lastlineanswer);ConsoleRead(); }
