The following .NET class calls the ValidateAddress web service. It is written in C# on Visual Studio 2010. Proxy class implementations for the web service data types ValidateAddressClient, requestRow, context, options, and responseRow were generated using Visual Studio .NET's "Add Service Reference" command. It is important to note that in this example the appropriate credentials must be provided or the call will fail.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Text;
using ConsoleApplication1.ValidateAddress_Reference;
namespace Test
{
class Program
{
static void Main(string[] args)
{
var validateClient = new ValidateAddress {Credentials = new NetworkCredential("admin", "admin")};
var address1 = new input_portAddress
{
AddressLine1 = "1825B Kramer Lane",
AddressLine2 = "Suite 100",
PostalCode = "78758",
City = "Austin",
StateProvince = "Texas"
};
var address2 = new input_portAddress
{
AddressLine1 = "100 Congress",
PostalCode = "78701",
City = "Austin",
StateProvince = "Texas"
};
var addresses = new input_portAddress[2];
addresses[0] = address1;
addresses[1] = address2;
var options = new options {OutputCasing = OutputCasing.M};
output_portAddress[] results = validateClient.CallValidateAddress(options, addresses);
for (int i = 0; i < results.Length; i++)
{
System.Console.WriteLine("Record " + (i+1) + ":");
System.Console.WriteLine("AddressLine1=" + results[i].AddressLine1);
System.Console.WriteLine("City=" + results[i].City);
System.Console.WriteLine("StateProvince=" + results[i].StateProvince);
System.Console.WriteLine("PostalCode=" + results[i].PostalCode + "\n");
}
System.Console.Write("Press any key to continue...");
System.Console.ReadKey();
}
}
}