Difference between revisions of "PAV I CSharp"

From CDYNE Wiki
Jump to navigation Jump to search
(Created page with "This the C# code example that we used in our simple helper WPF application. <code type=csharp> //Service client instance PavIntService.PavInternationalServiceClient service = nu...")
(No difference)

Revision as of 14:41, 28 February 2012

This the C# code example that we used in our simple helper WPF application.

//Service client instance PavIntService.PavInternationalServiceClient service = null;

public MainWindow() {

   //create the client using soap endpoint
   service = new PavIntService.PavInternationalServiceClient("pavisoap");


Button click handler:

private void button1_Click(object sender, RoutedEventArgs e) {

   PavIntService.AddressInternationalRequest request = new PavIntService.AddressInternationalRequest();
   //Check each textbox and add corresponding field if the textbox is not empty
   List<KeyValue> availableFields = new List<KeyValue>();            
   AddKeyValue(availableFields, ORGANISATION, "ORGANISATION");
   AddKeyValue(availableFields, SUBBUILDING, "SUBBUILDING");
   AddKeyValue(availableFields, BUILDINGNAME, "BUILDINGNAME");
   AddKeyValue(availableFields, BUILDINGNUMBER, "BUILDINGNUMBER");
   AddKeyValue(availableFields, DEPSTREET, "DEPSTREET");
   AddKeyValue(availableFields, STREET, "STREET");
   AddKeyValue(availableFields, DEPLOCALITY, "DEPLOCALITY");
   AddKeyValue(availableFields, LOCALITY, "LOCALITY");
   AddKeyValue(availableFields, POSTTOWN, "POSTTOWN");
   AddKeyValue(availableFields, COUNTY, "COUNTY");
   AddKeyValue(availableFields, POSTCODE, "POSTCODE");
   AddKeyValue(availableFields, ADDR, "ADDR");
   //Check what output fields are required on return
   List<string> returnFields = new List<string>();
   //Convert to array and add to the request 
   request.AddressFields = availableFields.ToArray();
   request.ReturnFields = returnFields.ToArray();
   //Set License key
   request.LicenseKey = "ADD VALID LICENSE KEY HERE";
   //Check if native output is requested
   request.ReturnNativeOutput = (chkNATIVE.IsChecked == true);
   //Call the service
   AddressInternationalResponse response = service.VerifyAddressInternational(request);
   //Update UI with the results


3rd party C# .Net tutorial can be found here: Video and Source,