{"id":2502,"date":"2022-11-09T07:20:54","date_gmt":"2022-11-09T07:20:54","guid":{"rendered":"https:\/\/serviceobjects.wpaladdin.com\/?post_type=serviceobjects&#038;p=2502"},"modified":"2024-03-29T09:13:07","modified_gmt":"2024-03-29T16:13:07","slug":"aius-soap","status":"publish","type":"page","link":"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/aius-soap\/","title":{"rendered":"AIUS &#8211; SOAP"},"content":{"rendered":"\n<div class=\"wp-block-create-block-tabs\"><ul class=\"tab-labels\" role=\"tablist\" aria-label=\"tabbed content\"><li class=\"tab-label active\" role=\"tab\" aria-selected=\"true\" aria-controls=\"C#\" tabindex=\"0\">C#<\/li><li class=\"tab-label\" role=\"tab\" aria-selected=\"false\" aria-controls=\"Java\" tabindex=\"0\">Java<\/li><\/ul><div class=\"tab-content\">\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Address Insight C# Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">public partial class AIN_Form : System.Web.UI.Page\n   {\n       const string TrialURL = \"https:\/\/trial.serviceobjects.com\/ain\/soap.svc\/SOAP\";\n       \/\/ A trial license key is not compatible with the backup datacenter.\n       \/\/ The backup url is provided with a production license key.\n       const string BackupURL = \"https:\/\/trial.serviceobjects.com\/ain\/soap.svc\/SOAP\";\n       protected void Page_Load(object sender, EventArgs e)\n       {\n           ErrorLabel.Visible = false;\n       }\n       protected void btn_Validate_Click(object sender, EventArgs e)\n       {\n           try\n           {\n               AIN.ResponseObject response = GetAddressInsight();\n               PrintResponse(response);\n           }\n           catch (Exception ex)\n           {\n               ErrorLabel.Visible = true;\n               ErrorLabel.Text = ex.Message;\n           }\n       }\n       protected AIN.ResponseObject GetAddressInsight()\n       {\n           AIN.ResponseObject Response = null;\n  \n           try\n           {\n               using (AIN.SOAPClient Client = new AIN.SOAPClient())\n               {\n                   \/\/ Implement Failover logic here\n                   try\n                   {\n                       Client.Endpoint.Address = new System.ServiceModel.EndpointAddress(TrialURL);\n                       Response = Client.GetAddressInsight(BusinessName.Text,\n                                                           Address1.Text,\n                                                           Address2.Text,\n                                                           City.Text,\n                                                           State.Text,\n                                                           Zip.Text,\n                                                           TestType.Text,\n                                                           inputLicenseKey.Text);\n                   }\n                   catch (WebException)\n                   {\n                       Client.Endpoint.Address = new System.ServiceModel.EndpointAddress(BackupURL);\n                       Response = Client.GetAddressInsight(BusinessName.Text,\n                                                           Address1.Text,\n                                                           Address2.Text,\n                                                           City.Text,\n                                                           State.Text,\n                                                           Zip.Text,\n                                                           TestType.Text,\n                                                           inputLicenseKey.Text);\n                   }\n                   catch (CommunicationException)\n                   {\n                       Client.Abort();\n                   }\n                   catch (TimeoutException)\n                   {\n                       Client.Abort();\n                   }\n                   catch (Exception Ex)\n                   {\n                       Client.Abort();\n                   }\n               }\n           }\n           catch (Exception)\n           {\n               \/\/ throw;\n           }\n           return Response;\n       }\n       protected void PrintResponse(AIN.ResponseObject response)\n       {\n           DataTable dtProvider = new DataTable();\n           \/\/Proccess result\n           \/\/We just output it here but this would be a good place to save data\n           \/\/to a database or send an email etc.\n           dtProvider.Columns.Add(new DataColumn(\"Output\", typeof(string)));\n           dtProvider.Columns.Add(new DataColumn(\"Values\", typeof(string)));\n           if (response.ContainsKey(\"AddressInsightResponse\"))\n           {\n               AIN.ResultObject ro = response[\"AddressInsightResponse\"];\n               \/\/Loop through the fields\n               \/*\n               foreach (string Key in ro[0].Keys)\n               {\n                   dtProvider.Rows.Add(Key, ro[0][Key]);\n               }\n               *\/\n               \/\/Or access the fields directly.\n               dtProvider.Rows.Add(\"Status\", ro[0].ContainsKey(\"Status\") ? ro[0][\"Status\"] : \"\");\n               dtProvider.Rows.Add(\"StatusScore\", ro[0].ContainsKey(\"StatusScore\") ? ro[0][\"StatusScore\"] : \"\");\n               dtProvider.Rows.Add(\"AddressStatus\", ro[0].ContainsKey(\"AddressStatus\") ? ro[0][\"AddressStatus\"] : \"\");\n               dtProvider.Rows.Add(\"DPV\", ro[0].ContainsKey(\"DPV\") ? ro[0][\"DPV\"] : \"\");\n               dtProvider.Rows.Add(\"DPVDesc\", ro[0].ContainsKey(\"DPVDesc\") ? ro[0][\"DPVDesc\"] : \"\");\n               .\n               .\n               .\n               dtProvider.Rows.Add(\"ZipHouseholdIncome\", ro[0].ContainsKey(\"ZipHouseholdIncome\") ? ro[0][\"ZipHouseholdIncome\"] : \"\");\n               dtProvider.Rows.Add(\"CountyHouseholdIncome\", ro[0].ContainsKey(\"CountyHouseholdIncome\") ? ro[0][\"CountyHouseholdIncome\"] : \"\");\n               dtProvider.Rows.Add(\"StateHouseholdIncome\", ro[0].ContainsKey(\"StateHouseholdIncome\") ? ro[0][\"StateHouseholdIncome\"] : \"\");\n               dtProvider.Rows.Add(\"ZipNotes\", ro[0].ContainsKey(\"ZipNotes\") ? ro[0][\"ZipNotes\"] : \"\");\n               dtProvider.Rows.Add(\"ZipNotesCodes\", ro[0].ContainsKey(\"ZipNotesCodes\") ? ro[0][\"ZipNotesCodes\"] : \"\");\n           }\n           else\n           {\n               if (response.ContainsKey(\"Error\"))\n               {\n                   AIN.ResultObject roError = response[\"Error\"];\n                   \/\/Loop throught he fields\n                   \/*\n                   foreach (string Key in roError[0].Keys)\n                   {\n                       dtProvider.Rows.Add(Key, roError[0][Key]);\n                   }\n                   *\/\n                   \/\/Or access the fields directly.\n                   dtProvider.Rows.Add(\"Type\", roError[0].ContainsKey(\"Type\") ? roError[0][\"Type\"] : \"\");\n                   dtProvider.Rows.Add(\"TypeCode\", roError[0].ContainsKey(\"TypeCode\") ? roError[0][\"TypeCode\"] : \"\");\n                   dtProvider.Rows.Add(\"Desc   \", roError[0].ContainsKey(\"Desc \") ? roError[0][\"Desc   \"] : \"\");\n                   dtProvider.Rows.Add(\"DescCode\", roError[0].ContainsKey(\"DescCode\") ? roError[0][\"DescCode\"] : \"\");\n               }\n           }\n           ResultGrid.DataSource = new DataView(dtProvider);\n           ResultGrid.DataBind();\n       }\n   }<\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Address Insight Java Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">String businessName = request.getParameter(\"businessName\");\nString address1 = request.getParameter(\"address1\");\nString address2 = request.getParameter(\"address2\");\nString city = request.getParameter(\"city\");\nString state = request.getParameter(\"state\");\nString zip = request.getParameter(\"zip\");\nString testType = request.getParameter(\"testType\");\nString licenseKey = request.getParameter(\"licensekey\");\n  \n\/\/Creating the soap client\nSOAP soap = new SOAP();\n  \nISOAP client = soap.getAddressInsightSOAP();\n  \nResponseObject addressPlus;\n  \n\/\/Call the web service\ntry{\n    addressPlus = client.getAddressInsight(businessName, address1, address2, city, state, zip, testType, licenseKey);\n}catch(Exception ex){\n    \/\/Create a backup client if an exception is thrown\n    ISOAP backupClient = soap.getAddressInsightSOAP();\n    addressPlus = backupClient.getAddressInsight(businessName, address1, address2, city, state, zip, testType, licenseKey);\n}\n  \nList&lt;ResponseObject.Response> responses = addressPlus.getResponse();\n    %>\n    &lt;H2>Service Response&lt;\/H2>\n    &lt;table>\n    &lt;%\n    for(ResponseObject.Response res : responses){\n        ResultObject resList = res.getValue();\n        String resultKey = res.getKey();\n        %>\n            &lt;tr>\n                &lt;td>&lt;b>&lt;%=resultKey%>&lt;\/b>&lt;\/td>\n            &lt;\/tr>\n        &lt;%\n        List&lt;FieldObject> results = resList.getResult();\n        for(FieldObject result : results){\n            List&lt;FieldObject.Field> fields = result.getField();\n            for(FieldObject.Field kvp : fields){\n                String key = kvp.getKey();\n                String value = kvp.getValue();\n            %>\n            &lt;tr>\n                &lt;td>&lt;%=key%>&lt;\/td>\n                &lt;td>&lt;%=value%>&lt;\/td>\n            &lt;\/tr>\n            &lt;%\n                  \n            }\n        }\n    }<\/pre>\n<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":2492,"menu_order":1,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2502","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>AIUS - SOAP<\/title>\n<meta name=\"description\" content=\"C#Java Address Insight C# Code Snippet public partial class AIN_Form : System.Web.UI.Page { const string TrialURL =\" \/>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AIUS - SOAP\" \/>\n<meta property=\"og:description\" content=\"C#Java Address Insight C# Code Snippet public partial class AIN_Form : System.Web.UI.Page { const string TrialURL =\" \/>\n<meta property=\"og:url\" content=\"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/aius-soap\/\" \/>\n<meta property=\"og:site_name\" content=\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-29T16:13:07+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/aius-soap\/\",\"url\":\"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/aius-soap\/\",\"name\":\"AIUS - SOAP\",\"isPartOf\":{\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/#website\"},\"datePublished\":\"2022-11-09T07:20:54+00:00\",\"dateModified\":\"2024-03-29T16:13:07+00:00\",\"description\":\"C#Java Address Insight C# Code Snippet public partial class AIN_Form : System.Web.UI.Page { const string TrialURL =\",\"breadcrumb\":{\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/aius-soap\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/aius-soap\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/aius-soap\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/test.serviceobjects.com\/docs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DOTS Address Insight &#8211; US\",\"item\":\"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"AIUS &#8211; Code Snippets and Sample Code\",\"item\":\"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"AIUS &#8211; SOAP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/#website\",\"url\":\"https:\/\/test.serviceobjects.com\/docs\/\",\"name\":\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/test.serviceobjects.com\/docs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/#organization\",\"name\":\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\",\"url\":\"https:\/\/test.serviceobjects.com\/docs\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/test.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png\",\"contentUrl\":\"https:\/\/test.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png\",\"width\":2560,\"height\":1440,\"caption\":\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\"},\"image\":{\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"AIUS - SOAP","description":"C#Java Address Insight C# Code Snippet public partial class AIN_Form : System.Web.UI.Page { const string TrialURL =","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"AIUS - SOAP","og_description":"C#Java Address Insight C# Code Snippet public partial class AIN_Form : System.Web.UI.Page { const string TrialURL =","og_url":"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/aius-soap\/","og_site_name":"Service Objects | Contact, Phone, Email Verification | Data Quality Services","article_modified_time":"2024-03-29T16:13:07+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/aius-soap\/","url":"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/aius-soap\/","name":"AIUS - SOAP","isPartOf":{"@id":"https:\/\/test.serviceobjects.com\/docs\/#website"},"datePublished":"2022-11-09T07:20:54+00:00","dateModified":"2024-03-29T16:13:07+00:00","description":"C#Java Address Insight C# Code Snippet public partial class AIN_Form : System.Web.UI.Page { const string TrialURL =","breadcrumb":{"@id":"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/aius-soap\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/aius-soap\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/aius-soap\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/test.serviceobjects.com\/docs\/"},{"@type":"ListItem","position":2,"name":"DOTS Address Insight &#8211; US","item":"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/"},{"@type":"ListItem","position":3,"name":"AIUS &#8211; Code Snippets and Sample Code","item":"https:\/\/test.serviceobjects.com\/docs\/dots-address-insight-us\/aius-code-snippets-and-sample-code\/"},{"@type":"ListItem","position":4,"name":"AIUS &#8211; SOAP"}]},{"@type":"WebSite","@id":"https:\/\/test.serviceobjects.com\/docs\/#website","url":"https:\/\/test.serviceobjects.com\/docs\/","name":"Service Objects | Contact, Phone, Email Verification | Data Quality Services","description":"","publisher":{"@id":"https:\/\/test.serviceobjects.com\/docs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/test.serviceobjects.com\/docs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/test.serviceobjects.com\/docs\/#organization","name":"Service Objects | Contact, Phone, Email Verification | Data Quality Services","url":"https:\/\/test.serviceobjects.com\/docs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/test.serviceobjects.com\/docs\/#\/schema\/logo\/image\/","url":"https:\/\/test.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png","contentUrl":"https:\/\/test.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png","width":2560,"height":1440,"caption":"Service Objects | Contact, Phone, Email Verification | Data Quality Services"},"image":{"@id":"https:\/\/test.serviceobjects.com\/docs\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/2502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/comments?post=2502"}],"version-history":[{"count":4,"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/2502\/revisions"}],"predecessor-version":[{"id":10041,"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/2502\/revisions\/10041"}],"up":[{"embeddable":true,"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/2492"}],"wp:attachment":[{"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/media?parent=2502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}