PAV I CSharp

From CDYNE Wiki
Revision as of 14:57, 9 January 2013 by imported>Nfesette
Jump to navigation Jump to search

PAV-I will be discontinued in March 2013. We sincerely appreciate your support and regret any inconvenience this may cause.

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,