PAV I CSharp

From CDYNE Wiki
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.

 1 //Service client instance
 2 PavIntService.PavInternationalServiceClient service = null;
 3 
 4 public MainWindow()
 5 {
 6     InitializeComponent();
 7 
 8     //create the client using soap endpoint
 9     service = new PavIntService.PavInternationalServiceClient("pavisoap");
10 }

Button click handler:

 1 private void button1_Click(object sender, RoutedEventArgs e)
 2 {
 3     PavIntService.AddressInternationalRequest request = new PavIntService.AddressInternationalRequest();
 4 
 5     //Check each textbox and add corresponding field if the textbox is not empty
 6     List<KeyValue> availableFields = new List<KeyValue>();            
 7     AddKeyValue(availableFields, ORGANISATION, "ORGANISATION");
 8     AddKeyValue(availableFields, SUBBUILDING, "SUBBUILDING");
 9     AddKeyValue(availableFields, BUILDINGNAME, "BUILDINGNAME");
10     AddKeyValue(availableFields, BUILDINGNUMBER, "BUILDINGNUMBER");
11     AddKeyValue(availableFields, DEPSTREET, "DEPSTREET");
12     AddKeyValue(availableFields, STREET, "STREET");
13     AddKeyValue(availableFields, DEPLOCALITY, "DEPLOCALITY");
14     AddKeyValue(availableFields, LOCALITY, "LOCALITY");
15     AddKeyValue(availableFields, POSTTOWN, "POSTTOWN");
16     AddKeyValue(availableFields, COUNTY, "COUNTY");
17     AddKeyValue(availableFields, POSTCODE, "POSTCODE");
18     AddKeyValue(availableFields, ADDR, "ADDR");
19                
20     //Check what output fields are required on return
21     List<string> returnFields = new List<string>();
22     GetReturnFields(returnFields);
23 
24     //Convert to array and add to the request 
25     request.AddressFields = availableFields.ToArray();
26     request.ReturnFields = returnFields.ToArray();
27 
28     //Set License key
29     request.LicenseKey = "ADD VALID LICENSE KEY HERE";
30 
31     //Check if native output is requested
32     request.ReturnNativeOutput = (chkNATIVE.IsChecked == true);
33 
34     //Call the service
35     AddressInternationalResponse response = service.VerifyAddressInternational(request);
36 
37     //Update UI with the results
38     UpdateUI(response.AddressFields);
39 }

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