PAVv3 CSharp

From CDYNE Wiki
Jump to navigation Jump to search

Using as a Service Reference(.NET Framework 3.5+)

Add a service reference to your project: http://pav3.cdyne.com/PavService.svc?wsdl


Get Congressional District By Zip

 1 /*http://pav3.cdyne.com/PavService.svc?wsdl was added as Service Reference and given the name WSDL*/
 2 
 3 using System;
 4 using System.Collections.Generic;
 5 using System.Linq;
 6 using System.Text;
 7 using System.Threading.Tasks;
 8 using GetCongressionalDistrictByZip.WSDL;
 9 
10 namespace GetCongressionalDistrictByZip
11 {
12     class Program
13     {
14         static void Main(string[] args)
15         {
16             WSDL.PavServiceClient PSC = new WSDL.PavServiceClient("pavsoap");
17             WSDL.CongressionalDistrictResponse CDR = new WSDL.CongressionalDistrictResponse();
18 
19             CDR = PSC.GetCongressionalDistrictByZip("23320", "YOUR LICENSE KEY");
20 
21              if (CDR.ReturnCode == 0)
22                 Console.WriteLine("Congressional District Found: " + CDR.CongressionalDistrict);
23 
24              else if (CDR.ReturnCode == 1)
25                  Console.WriteLine("Invalid input.");
26 
27              else if (CDR.ReturnCode == 2)
28                  Console.WriteLine("Invalid license key.");
29 
30              else if (CDR.ReturnCode == 3)
31                  Console.WriteLine("Congressional District not found.");
32 
33              else if (CDR.ReturnCode == 4)
34             {
35                 Console.WriteLine("Multiple Congressional Districts Found:" + "\n");
36 
37                 foreach (Char CongressionalDistrict in CDR.CongressionalDistrict)
38                 {
39                     Console.WriteLine(CDR.CongressionalDistrict);
40                 }
41             }
42             Console.ReadLine();
43         }
44     }
45 }

Get City Names For Zip Code

 1 /*http://pav3.cdyne.com/PavService.svc?wsdl was added as Service Reference and given the name WSDL*/
 2 
 3 using System;
 4 using System.Collections.Generic;
 5 using System.Linq;
 6 using System.Text;
 7 using GetCityNamesForZipCode.WSDL;
 8 
 9 namespace GetCityNamesForZipCode
10 {
11     class Program
12     {
13         static void Main(string[] args)
14         {
15             WSDL.PavServiceClient PSC = new WSDL.PavServiceClient("pavsoap");
16             WSDL.CityNamesResponse CNR = new WSDL.CityNamesResponse();
17 
18             CNR = PSC.GetCityNamesForZipCode("23320", "YOUR LICENSE KEY");
19 
20             if (CNR.ReturnCode == 0)
21             {
22                 Console.WriteLine("City Name: " + "\n");
23 
24                 foreach (WSDL.City city in CNR.CityNames)
25                 {
26                     Console.WriteLine(city.Name);
27                 }
28             }
29             else if (CNR.ReturnCode == 1)
30                 Console.WriteLine("Invalid input.");
31 
32             else if (CNR.ReturnCode == 2)
33                 Console.WriteLine("Invalid license key.");
34 
35             else if (CNR.ReturnCode == 3)
36                 Console.WriteLine("No match found.");
37 
38             Console.ReadLine();
39         }
40     }
41 }

Get Zip Codes For City And State

 1 /*http://pav3.cdyne.com/PavService.svc?wsdl was added as Service Reference and given the name WSDL*/
 2 
 3 using System;
 4 using System.Collections.Generic;
 5 using System.Linq;
 6 using System.Text;
 7 using System.Threading.Tasks;
 8 using GetZipCodesForCityAndState.WSDL;
 9 
10 namespace GetZipCodesForCityAndState
11 {
12     class Program
13     {
14         static void Main(string[] args)
15         {
16             WSDL.PavServiceClient PSC = new WSDL.PavServiceClient("pavsoap");
17             WSDL.ZipCodesResponse ZCR = new WSDL.ZipCodesResponse();
18 
19             ZCR = PSC.GetZipCodesForCityAndState("Chesapeake", "VA", "YOUR LICENSE KEY");
20 
21             if (ZCR.ReturnCode == 0)
22             {
23                 Console.WriteLine("Zip Code(s) Found: " + "\n");
24 
25                 foreach (string Zip in ZCR.ZipCodes)
26                 {
27                     Console.WriteLine(Zip);
28                 }
29             }
30             else if (ZCR.ReturnCode == 1)
31                 Console.WriteLine("Invalid input.");
32 
33             else if (ZCR.ReturnCode == 2)
34                 Console.WriteLine("Invalid license key.");
35 
36             else if (ZCR.ReturnCode == 3)
37                 Console.WriteLine("No match found.");
38 
39             Console.ReadLine();
40         }
41     }
42 }

Get Urbanization List For ZipCode

 1 /*http://pav3.cdyne.com/PavService.svc?wsdl was added as Service Reference and given the name WSDL*/
 2 
 3 using System;
 4 using System.Collections.Generic;
 5 using System.Linq;
 6 using System.Text;
 7 using System.Threading.Tasks;
 8 using GetUrbanizationListForZipCode.WSDL;
 9 
10 namespace GetUrbanizationListForZipCode
11 {
12     class Program
13     {
14         static void Main(string[] args)
15         {
16             WSDL.PavServiceClient PSC = new PavServiceClient("pavsoap");
17             WSDL.UrbanizationResponse UR = new WSDL.UrbanizationResponse();
18 
19             UR = PSC.GetUrbanizationListForZipCode("23320", "YOUR LICENSE KEY");
20 
21             if (UR.ReturnCode == 0)
22             {
23                 Console.WriteLine("Urbanization Names Found: " + "\n");
24 
25                 foreach (string Urban in UR.UrbanizationList)
26                 {
27                     Console.WriteLine(Urban);
28                 }
29             }
30             else if (UR.ReturnCode == 1)
31                 Console.WriteLine("Invalid input.");
32 
33             else if (UR.ReturnCode == 2)
34                 Console.WriteLine("Invalid license key.");
35 
36             else if (UR.ReturnCode == 3)
37                 Console.WriteLine("No match found.");
38 
39             Console.ReadLine();
40         }
41     }
42 }

Verify Address Advanced

 1  /*http://pav3.cdyne.com/PavService.svc?wsdl was added as Service Reference and given the name WSDL*/
 2 
 3 using System;
 4 using System.Collections.Generic;
 5 using System.Linq;
 6 using System.Text;
 7 using VerifyAddressAdvanced.WSDL;
 8 
 9 namespace VerifyAddressAdvanced
10 {
11     class Program
12     {
13         static void Main(string[] args)
14         {
15             WSDL.PavServiceClient PSC = new WSDL.PavServiceClient("pavsoap");
16             WSDL.PavRequest PR = new WSDL.PavRequest();
17 
18             PR.LicenseKey = "YOUR LICENSE KEY";
19             PR.FirmOrRecipient = "CDYNE Corporation";
20             PR.PrimaryAddressLine = "505 Independence Parkway";
21             PR.SecondaryAddressLine = "Suite 300";
22             PR.CityName = "Chesapeake";
23             PR.State = "VA";
24             PR.ZipCode = "23320";
25             PR.Urbanization = "";
26             PR.ReturnCaseSensitive = true;
27             PR.ReturnCensusInfo = true;
28             PR.ReturnCityAbbreviation = true;
29             PR.ReturnGeoLocation = true;
30             PR.ReturnLegislativeInfo = true;
31             PR.ReturnMailingIndustryInfo = true;
32             PR.ReturnResidentialIndicator = true;
33             PR.ReturnStreetAbbreviated = true;
34 
35             WSDL.PavResponse PavRes = new WSDL.PavResponse();
36             PavRes = PSC.VerifyAddressAdvanced(PR);
37             
38             /* The return section below will output the return code with the return code text along with the address information.  
39             To view a list of all possible return codes: http://wiki.cdyne.com/index.php/PAVv3_Return_Codes*/
40 
41             if (PavRes.ReturnCode == 100)
42 
43                 Console.WriteLine(
44                     "Return Code: " + PavRes.ReturnCode + " - Input address is DPV confirmed for all components." + "\n" +
45                     PavRes.FirmOrRecipient + "\n" +
46                     PavRes.PrimaryDeliveryLine + "\n" +
47                     PavRes.CityName + ", " +
48                     PavRes.StateAbbreviation + "  " +
49                     PavRes.ZipCode + "\n" +
50                     PavRes.Country);
51 
52             else Console.WriteLine(
53                     "Return Code: " + PavRes.ReturnCode + "\n" +
54                     PavRes.FirmOrRecipient + "\n" +
55                     PavRes.PrimaryDeliveryLine + "\n" +
56                     PavRes.CityName + ", " +
57                     PavRes.StateAbbreviation + "  " +
58                     PavRes.ZipCode + "\n" +
59                     PavRes.Country);
60 
61             Console.ReadLine();       
62         }
63     }
64 }
65 
66 /*
67 Additional Return Fields:
68 
69 PavRes.CensusInfo
70 PavRes.GeoLocationInfo
71 PavRes.LegislativeInfo
72 PavRes.MailingIndustryInfo
73 PavRes.MultipleMatches
74 PavRes.ResidentialDeliveryIndicator
75 PavRes.County
76 PavRes.CountyNum
77 PavRes.FinanceNumber
78 PavRes.IntelligentMailBarcodeKey
79 PavRes.PMBDesignator
80 PavRes.PMBNumber
81 PavRes.PostDirectional
82 PavRes.PostnetBarcode
83 PavRes.PreDirectional
84 PavRes.PreferredCityName
85 PavRes.Primary
86 PavRes.PrimaryEO
87 PavRes.PrimaryHigh
88 PavRes.PrimaryLow
89 PavRes.ReturnCodeSpecified
90 PavRes.Secondary
91 PavRes.SecondaryAbbreviation
92 PavRes.SecondaryEO
93 PavRes.SecondaryHigh
94 PavRes.SecondaryLow
95 PavRes.StreetName
96 PavRes.Suffix
97 PavRes.Urbanization
98 */

Verify Address

 1 /*http://pav3.cdyne.com/PavService.svc?wsdl was added as Service Reference and given the name WSDL*/
 2 
 3 using System;
 4 using System.Collections.Generic;
 5 using System.Linq;
 6 using System.Text;
 7 using System.Threading.Tasks;
 8 using VerifyAddress.WSDL;
 9 
10 namespace VerifyAddress
11 {
12     class Program
13     {
14         static void Main(string[] args)
15         {
16             WSDL.PavServiceClient PSC = new WSDL.PavServiceClient("pavsoap");
17             WSDL.Address Res = new WSDL.Address();
18 
19             Res = PSC.VerifyAddress("CDYNE Corporation", "505 Independence Parkway", "Suite 300", "", "Chesapeake", "VA", "", "YOUR LICENSE KEY");
20 
21             /* The return section below will output the return code with the return code text along with the address information.  
22             To view a list of all possible return codes: http://wiki.cdyne.com/index.php/PAVv3_Return_Codes*/
23 
24             if (Res.ReturnCode == 100)
25 
26                 Console.WriteLine(
27                     "Return Code: " + Res.ReturnCode + " - Input address is DPV confirmed for all components." + "\n" +
28                     Res.FirmNameOrRecipient + "\n" +
29                     Res.PrimaryAddressLine + "\n" +
30                     Res.CityName + ", " +
31                     Res.StateAbbreviation + "  " +
32                     Res.ZipCode + "\n" +
33                     Res.Country);
34 
35             else
36                  Console.WriteLine(
37                    "Return Code: " +  Res.ReturnCode + "\n" +
38                    Res.FirmNameOrRecipient + "\n" +
39                    Res.PrimaryAddressLine + "\n" +
40                    Res.CityName + ", " +
41                    Res.StateAbbreviation + "  " +
42                    Res.ZipCode + "\n" +
43                    Res.Country);
44             Console.ReadLine();  
45         }
46     }
47 }
48 
49 /*
50 Additional Return Fields:
51 
52 Res.County
53 Res.Urbanization
54 */

Get Intelligent Mail Barcode

 1 /*http://pav3.cdyne.com/PavService.svc?wsdl was added as Service Reference and given the name WSDL*/
 2 
 3 using System;
 4 using System.Collections.Generic;
 5 using System.Linq;
 6 using System.Text;
 7 using System.Threading.Tasks;
 8 using GetIntelligentMailBarcode.WSDL;
 9 
10 namespace GetIntelligentMailBarcode
11 {
12     class Program
13     {
14         static void Main(string[] args)
15         {
16             WSDL.PavServiceClient PSC = new WSDL.PavServiceClient("pavsoap");
17             WSDL.IntelligentBarcodeResponse IMB = new WSDL.IntelligentBarcodeResponse();
18 
19             IMB = PSC.GetIntelligentMailBarcode("12", "123", "123456", "123456789", "dw/cKC9h9Au0zJy+WGvQkQ==", "YOUR LICENSE KEY");
20 
21             if (IMB.ReturnCode == 0)
22                 Console.WriteLine("Intelligent Mail Barcode: " + IMB.Barcode);
23 
24             else if (IMB.ReturnCode == 1)
25                 Console.WriteLine("Invalid input.");
26 
27             Console.ReadLine();
28         }
29     }
30 }

Get Zip Codes For Fips

 1 /*http://pav3.cdyne.com/PavService.svc?wsdl was added as Service Reference and given the name WSDL*/
 2 
 3 using System;
 4 using System.Collections.Generic;
 5 using System.Linq;
 6 using System.Text;
 7 using System.Threading.Tasks;
 8 using GetZipCodesForFips.WSDL;
 9 
10 namespace GetZipCodesForFips
11 {
12     class Program
13     {
14         static void Main(string[] args)
15         {
16             WSDL.PavServiceClient PSC = new PavServiceClient("pavsoap");
17             WSDL.ZipCodesResponse ZCR = new ZipCodesResponse();
18 
19             ZCR = PSC.GetZipCodesForFips("51550", "YOUR LICENSE KEY");
20 
21             if (ZCR.ReturnCode == 0)
22             {
23                 Console.WriteLine("Zip Codes(s) Found: " + "\n");
24 
25                 foreach (string Zip in ZCR.ZipCodes)
26                 {
27                     Console.WriteLine(Zip);
28                 }
29             }
30             else if (ZCR.ReturnCode == 1)
31                 Console.WriteLine("Invalid input.");
32 
33             else if (ZCR.ReturnCode == 2)
34                 Console.WriteLine("Invalid license key.");
35 
36             else if (ZCR.ReturnCode == 3)
37                 Console.WriteLine("No zip codes found.");
38 
39             Console.ReadLine();
40         }
41     }
42 }

Get Zip Codes Within Distance

 1 /*http://pav3.cdyne.com/PavService.svc?wsdl was added as Service Reference and given the name WSDL*/
 2 
 3 using System;
 4 using System.Collections.Generic;
 5 using System.Linq;
 6 using System.Text;
 7 using System.Threading.Tasks;
 8 using GetZipCodesWithinDistance.WSDL;
 9 
10 namespace GetZipCodesWithinDistance
11 {
12     class Program
13     {
14         static void Main(string[] args)
15         {
16             WSDL.PavServiceClient PSC = new WSDL.PavServiceClient("pavsoap");
17             WSDL.ZipCodesResponse ZCR = new WSDL.ZipCodesResponse();
18 
19             ZCR = PSC.GetZipCodesWithinDistance("36.761560", "-76.259964", "5", "YOUR LICENSE KEY");
20 
21             if (ZCR.ReturnCode == 0)
22             {
23                 Console.WriteLine("Zip code(s) found:" + "\n");
24 
25                 foreach (string Zip in ZCR.ZipCodes)
26                 {
27                     Console.WriteLine(Zip);
28                 }
29             }
30             else if (ZCR.ReturnCode == 1)
31                 Console.WriteLine("Invalid input.");
32 
33             else if (ZCR.ReturnCode == 2)
34                 Console.WriteLine("Invalid license key.");
35 
36             else if (ZCR.ReturnCode == 3)
37                 Console.WriteLine("No match found.");
38 
39             else if (ZCR.ReturnCode == 4)
40                 Console.WriteLine("Outside of Latitude/Longitude range.");
41 
42             Console.ReadLine();
43         }
44     }
45 }

Back to Postal_Address_Verification_V3