Address Validation International C# Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
//Add the necessary service reference to the AVI WSDL
AVI.AVIServiceClient ws = new AVI.AVIServiceClient();
AVI.AddressInfoResponse response = default(AVI.AddressInfoResponse);
response = ws.GetAddressInfo(Address1.Text, Address2.Text, Address3.Text, Address4.Text, Address5.Text, Locality.Text, AdministrativeArea.Text, PostalCode.Text, Country.Text, OutputLanguage.Text, LicenseKey.Text);
if ((response.Error == null))
{
ProcessValidResponse(response);
}
else {
ProcessErrorResponse(response.Error);
}
//Add the necessary service reference to the AVI WSDL AVI.AVIServiceClient ws = new AVI.AVIServiceClient(); AVI.AddressInfoResponse response = default(AVI.AddressInfoResponse); response = ws.GetAddressInfo(Address1.Text, Address2.Text, Address3.Text, Address4.Text, Address5.Text, Locality.Text, AdministrativeArea.Text, PostalCode.Text, Country.Text, OutputLanguage.Text, LicenseKey.Text); if ((response.Error == null)) { ProcessValidResponse(response); } else { ProcessErrorResponse(response.Error); }
//Add the necessary service reference to the AVI WSDL
AVI.AVIServiceClient ws = new AVI.AVIServiceClient();
AVI.AddressInfoResponse response = default(AVI.AddressInfoResponse);
response = ws.GetAddressInfo(Address1.Text, Address2.Text, Address3.Text, Address4.Text, Address5.Text, Locality.Text, AdministrativeArea.Text, PostalCode.Text, Country.Text, OutputLanguage.Text, LicenseKey.Text);
if ((response.Error == null))
{
    ProcessValidResponse(response);
}
else {
    ProcessErrorResponse(response.Error);
}

Address Validation International Java Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
try{
outputs = soap.getAddressInfo(address1, address2, address3, address4, address5, locality, administrativearea, postalcode, country, outputlanguage, licenseKey);
if(outputs.getError() !=null && outputs.getError().getTypeCode() == 3)
{
throw new Exception();
}
}
catch(Exception e)
{ //FAILOVER- USE BACKUP NOW
try{
//CALL SOAP USING BACKUP URL (Change the endpoint)
outputs = soap.getAddressInfo(address1, address2, address3, address4, address5, locality, administrativearea, postalcode, country, outputlanguage, licenseKey);
}
catch(Exception ex)
{
throw new Exception("Both Primary and Backup soap calls failed: " + ex.getMessage());
}
}
try{ outputs = soap.getAddressInfo(address1, address2, address3, address4, address5, locality, administrativearea, postalcode, country, outputlanguage, licenseKey); if(outputs.getError() !=null && outputs.getError().getTypeCode() == 3) { throw new Exception(); } } catch(Exception e) { //FAILOVER- USE BACKUP NOW try{ //CALL SOAP USING BACKUP URL (Change the endpoint) outputs = soap.getAddressInfo(address1, address2, address3, address4, address5, locality, administrativearea, postalcode, country, outputlanguage, licenseKey); } catch(Exception ex) { throw new Exception("Both Primary and Backup soap calls failed: " + ex.getMessage()); } }
try{
    outputs = soap.getAddressInfo(address1, address2, address3, address4, address5, locality, administrativearea, postalcode, country, outputlanguage, licenseKey);
      
      
    if(outputs.getError() !=null && outputs.getError().getTypeCode() == 3)
    {
        throw new Exception();
    }
    }
    catch(Exception e)
    {   //FAILOVER- USE BACKUP NOW
        try{
            //CALL SOAP USING BACKUP URL (Change the endpoint)
            outputs = soap.getAddressInfo(address1, address2, address3, address4, address5, locality, administrativearea, postalcode, country, outputlanguage, licenseKey);
        }
        catch(Exception ex)
        {
          
            throw new Exception("Both Primary and Backup soap calls failed: " + ex.getMessage());
        }
    }

Address Validation International PHP Code Snippets

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
//Set the primary and backup URLs as necessary
$client = new SoapClient($URL);
$outputs = $client->GetAddressInfo($params)->GetAddressInfoResult;
if (empty($outputs))
{
$backupClient = new SoapClient($backupURL);
$outputs = $client->GetAddressInfo($params)->GetAddressInfoResult;
}
//Set the primary and backup URLs as necessary $client = new SoapClient($URL); $outputs = $client->GetAddressInfo($params)->GetAddressInfoResult; if (empty($outputs)) { $backupClient = new SoapClient($backupURL); $outputs = $client->GetAddressInfo($params)->GetAddressInfoResult; }
//Set the primary and backup URLs as necessary
$client = new SoapClient($URL);
$outputs = $client->GetAddressInfo($params)->GetAddressInfoResult;
if (empty($outputs))
{
    $backupClient = new SoapClient($backupURL);
    $outputs = $client->GetAddressInfo($params)->GetAddressInfoResult;
}

Address Validation International RoR SOAP Code Snippets

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#Formats inputs into a hash to pass to Soap Client
#Hash Keys must be named as they are shown here.
message = {
"Address1" => @request.address1,
"Address2" => @request.address2,
"Address3" => @request.address3,
"Address4" => @request.address4,
"Address5" => @request.address5,
"Locality" => @request.locality,
"AdministrativeArea" => @request.administrativearea,
"PostalCode" => @request.postalcode,
"Country" => @request.country,
"OutputLanguage" => @request.language,
"LicenseKey" => @request.licensekey,
}
begin
#initializes the soap client. The convert request keys global is necessary to receive a response from the service.
client = Savon.client( wsdl: dotsAVIPrimary,
element_form_default: :qualified,
convert_request_keys_to: :camelcase
)
#Calls the with given inptus and converts response to a hash.
response = client.call(:get_address_info, message: message).to_hash
#Checks to see what results came back from the service
processresults(response)
#If an error occurs during the call, this will use the Backup url and attempt to retrieve data.
rescue StandardError => e
begin
backupclient = Savon.client( wsdl: dotsAVIBackup,
element_form_default: :qualified,
convert_request_keys_to: :camelcase
)
#Sets the response to the backclient call to the operation and converts response to a hash.
response = backupclient.call(:get_address_info, message: message).to_hash
processresults(response)
#If the backup url failed, this will display the error received from the server
rescue StandardError =>error
@status = response
@displaydata = {"error" => "A Big Error Occured"}
end
end
#Formats inputs into a hash to pass to Soap Client #Hash Keys must be named as they are shown here. message = { "Address1" => @request.address1, "Address2" => @request.address2, "Address3" => @request.address3, "Address4" => @request.address4, "Address5" => @request.address5, "Locality" => @request.locality, "AdministrativeArea" => @request.administrativearea, "PostalCode" => @request.postalcode, "Country" => @request.country, "OutputLanguage" => @request.language, "LicenseKey" => @request.licensekey, } begin #initializes the soap client. The convert request keys global is necessary to receive a response from the service. client = Savon.client( wsdl: dotsAVIPrimary, element_form_default: :qualified, convert_request_keys_to: :camelcase ) #Calls the with given inptus and converts response to a hash. response = client.call(:get_address_info, message: message).to_hash #Checks to see what results came back from the service processresults(response) #If an error occurs during the call, this will use the Backup url and attempt to retrieve data. rescue StandardError => e begin backupclient = Savon.client( wsdl: dotsAVIBackup, element_form_default: :qualified, convert_request_keys_to: :camelcase ) #Sets the response to the backclient call to the operation and converts response to a hash. response = backupclient.call(:get_address_info, message: message).to_hash processresults(response) #If the backup url failed, this will display the error received from the server rescue StandardError =>error @status = response @displaydata = {"error" => "A Big Error Occured"} end end
#Formats inputs into a hash to pass to Soap Client
#Hash Keys must be named as they are shown here.
message =   {
            "Address1" => @request.address1,
            "Address2" => @request.address2,
            "Address3" => @request.address3,
            "Address4" => @request.address4,
            "Address5" => @request.address5,
            "Locality" => @request.locality,
            "AdministrativeArea" => @request.administrativearea,
            "PostalCode" => @request.postalcode,
            "Country" => @request.country,
            "OutputLanguage" => @request.language,
            "LicenseKey" => @request.licensekey,
            }
   
begin
    #initializes the soap client. The convert request keys global is necessary to receive a response from the service.
    client = Savon.client(  wsdl: dotsAVIPrimary,
                            element_form_default: :qualified,
                            convert_request_keys_to: :camelcase
                         )
    #Calls the with given inptus and converts response to a hash.
    response = client.call(:get_address_info, message: message).to_hash
    #Checks to see what results came back from the service
    processresults(response)          
      
#If an error occurs during the call, this will use the Backup url and attempt to retrieve data.
rescue StandardError => e
    begin
    backupclient = Savon.client(    wsdl: dotsAVIBackup,
                                    element_form_default: :qualified,
                                    convert_request_keys_to: :camelcase
                               )
    #Sets the response to the backclient call to the operation and converts response to a hash.
    response = backupclient.call(:get_address_info, message: message).to_hash
    processresults(response)
    #If the backup url failed, this will display the error received from the server
    rescue StandardError =>error
        @status = response
        @displaydata = {"error" => "A Big Error Occured"}
    end
end

Address Validation International Python Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
try:
client = Client(primaryURL)
result = client.service.GetAddressInfo(Address1=mAddress1, Address2=mAddress2, Address3=mAddress3, Address4=mAddress4, Address5=mAddress5, Locality=mLocality, AdministrativeArea=mAdministrativeArea, PostalCode=mPostalCode, Country=mCountry, OutputLanguage=mOutputLanguage, LicenseKey=mLicenseKey)
#Loops through either the error result or proper result and displays values to the screen.
if hasattr(result, 'Error') :
#Handle Error response
else:
#Handles successful response
#Tries the backup URL if the primary URL failed
except:
try:
client = Client(backupURL)
result = client.service.GetAddressInfo(Address1=mAddress1, Address2=mAddress2, Address3=mAddress3, Address4=mAddress4, Address5=mAddress5, Locality=mLocality, AdministrativeArea=mAdministrativeArea, PostalCode=mPostalCode, Country=mCountry, OutputLanguage=mOutputLanguage, LicenseKey=mLicenseKey)
if hasattr(result, 'Error') :
#handles error response
else:
#Handles successful response
try: client = Client(primaryURL) result = client.service.GetAddressInfo(Address1=mAddress1, Address2=mAddress2, Address3=mAddress3, Address4=mAddress4, Address5=mAddress5, Locality=mLocality, AdministrativeArea=mAdministrativeArea, PostalCode=mPostalCode, Country=mCountry, OutputLanguage=mOutputLanguage, LicenseKey=mLicenseKey) #Loops through either the error result or proper result and displays values to the screen. if hasattr(result, 'Error') : #Handle Error response else: #Handles successful response #Tries the backup URL if the primary URL failed except: try: client = Client(backupURL) result = client.service.GetAddressInfo(Address1=mAddress1, Address2=mAddress2, Address3=mAddress3, Address4=mAddress4, Address5=mAddress5, Locality=mLocality, AdministrativeArea=mAdministrativeArea, PostalCode=mPostalCode, Country=mCountry, OutputLanguage=mOutputLanguage, LicenseKey=mLicenseKey) if hasattr(result, 'Error') : #handles error response else: #Handles successful response
try:
    client = Client(primaryURL)
    result = client.service.GetAddressInfo(Address1=mAddress1, Address2=mAddress2, Address3=mAddress3, Address4=mAddress4, Address5=mAddress5, Locality=mLocality, AdministrativeArea=mAdministrativeArea, PostalCode=mPostalCode, Country=mCountry, OutputLanguage=mOutputLanguage, LicenseKey=mLicenseKey)
    #Loops through either the error result or proper result and displays values to the screen.
    if hasattr(result, 'Error') :
        #Handle Error response
    else:
        #Handles successful response
#Tries the backup URL if the primary URL failed
except:
    try:
        client = Client(backupURL)
        result = client.service.GetAddressInfo(Address1=mAddress1, Address2=mAddress2, Address3=mAddress3, Address4=mAddress4, Address5=mAddress5, Locality=mLocality, AdministrativeArea=mAdministrativeArea, PostalCode=mPostalCode, Country=mCountry, OutputLanguage=mOutputLanguage, LicenseKey=mLicenseKey)
        if hasattr(result, 'Error') :
            #handles error response
        else:
            #Handles successful response

Address Validation International ColdFusion Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!--Makes Request to web service --->
<cfscript>
try
{
if (isDefined("form.Action") AND Action neq "")
{
wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/avi/api.svc?wsdl");
outputs = wsresponse.getAddressInfo("#Address1#", "#Address2#", "#Address3#", "#Address4#", "#Address5#", "#Locality#", "#AdministrativeArea#", "#PostalCode#", "#Country#", "#OutputLanguage#", "#LicenseKey#");
}
}
catch(any Exception){
try
{
if (isDefined("form.Action") AND Action neq "")
{
wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/avi/api.svc?wsdl");
outputs = wsresponse.getAddressInfo("#Address1#", "#Address2#", "#Address3#", "#Address4#", "#Address5#", "#Locality#", "#AdministrativeArea#", "#PostalCode#", "#Country#", "#OutputLanguage#", "#LicenseKey#");
}
}
catch(any Exception)
{
writeoutput("An Error Has Occured. Please Reload and try again #Exception.message#");
}
}
</cfscript>
<!--Makes Request to web service ---> <cfscript> try { if (isDefined("form.Action") AND Action neq "") { wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/avi/api.svc?wsdl"); outputs = wsresponse.getAddressInfo("#Address1#", "#Address2#", "#Address3#", "#Address4#", "#Address5#", "#Locality#", "#AdministrativeArea#", "#PostalCode#", "#Country#", "#OutputLanguage#", "#LicenseKey#"); } } catch(any Exception){ try { if (isDefined("form.Action") AND Action neq "") { wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/avi/api.svc?wsdl"); outputs = wsresponse.getAddressInfo("#Address1#", "#Address2#", "#Address3#", "#Address4#", "#Address5#", "#Locality#", "#AdministrativeArea#", "#PostalCode#", "#Country#", "#OutputLanguage#", "#LicenseKey#"); } } catch(any Exception) { writeoutput("An Error Has Occured. Please Reload and try again #Exception.message#"); } } </cfscript>
<!--Makes Request to web service --->
<cfscript>
        try
        {
            if (isDefined("form.Action") AND Action neq "")
            {
                wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/avi/api.svc?wsdl");                           
                outputs = wsresponse.getAddressInfo("#Address1#", "#Address2#", "#Address3#", "#Address4#", "#Address5#", "#Locality#", "#AdministrativeArea#", "#PostalCode#", "#Country#", "#OutputLanguage#", "#LicenseKey#");
            }
        }
    catch(any Exception){
        try
            {
                if (isDefined("form.Action") AND Action neq "")
                {
                    wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/avi/api.svc?wsdl");                           
                    outputs = wsresponse.getAddressInfo("#Address1#", "#Address2#", "#Address3#", "#Address4#", "#Address5#", "#Locality#", "#AdministrativeArea#", "#PostalCode#", "#Country#", "#OutputLanguage#", "#LicenseKey#");
                }
            }
            catch(any Exception)  
                {
                 writeoutput("An Error Has Occured. Please Reload and try again #Exception.message#");             
                }
        }
</cfscript>

Address Validation International VB Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Try
Dim ws As New AVI.AVIServiceClient
Dim response As AVI.AddressInfoResponse
response = ws.GetAddressInfo(Address1.Text, Address2.Text, Address3.Text, Address4.Text, Address5.Text, Locality.Text, AdministrativeArea.Text, PostalCode.Text, Country.Text, OutputLanguage.Text, LicenseKey.Text)
If (response.Error Is Nothing) Then
ProcessValidResponse(response)
Else
ProcessErrorResponse(response.Error)
End If
Catch er As Exception
''Set the Primary and Backup Service References as necessary
Try
Dim wsbackup As New AVI.AVIServiceClient
Dim response As AVI.AddressInfoResponse
response = wsbackup.GetAddressInfo(Address1.Text, Address2.Text, Address3.Text, Address4.Text, Address5.Text, Locality.Text, AdministrativeArea.Text, PostalCode.Text, Country.Text, OutputLanguage.Text, LicenseKey.Text)
If (response.Error Is Nothing) Then
ProcessValidResponse(response)
Else
ProcessErrorResponse(response.Error)
End If
Catch ex As Exception
resultsLabel.Visible = True
resultsLabel.Text = ex.Message
End Try
End Try
Try Dim ws As New AVI.AVIServiceClient Dim response As AVI.AddressInfoResponse response = ws.GetAddressInfo(Address1.Text, Address2.Text, Address3.Text, Address4.Text, Address5.Text, Locality.Text, AdministrativeArea.Text, PostalCode.Text, Country.Text, OutputLanguage.Text, LicenseKey.Text) If (response.Error Is Nothing) Then ProcessValidResponse(response) Else ProcessErrorResponse(response.Error) End If Catch er As Exception ''Set the Primary and Backup Service References as necessary Try Dim wsbackup As New AVI.AVIServiceClient Dim response As AVI.AddressInfoResponse response = wsbackup.GetAddressInfo(Address1.Text, Address2.Text, Address3.Text, Address4.Text, Address5.Text, Locality.Text, AdministrativeArea.Text, PostalCode.Text, Country.Text, OutputLanguage.Text, LicenseKey.Text) If (response.Error Is Nothing) Then ProcessValidResponse(response) Else ProcessErrorResponse(response.Error) End If Catch ex As Exception resultsLabel.Visible = True resultsLabel.Text = ex.Message End Try End Try
Try
    Dim ws As New AVI.AVIServiceClient
    Dim response As AVI.AddressInfoResponse
    response = ws.GetAddressInfo(Address1.Text, Address2.Text, Address3.Text, Address4.Text, Address5.Text, Locality.Text, AdministrativeArea.Text, PostalCode.Text, Country.Text, OutputLanguage.Text, LicenseKey.Text)
    If (response.Error Is Nothing) Then
        ProcessValidResponse(response)
    Else
        ProcessErrorResponse(response.Error)
    End If
  
Catch er As Exception
    ''Set the Primary and Backup Service References as necessary
    Try
        Dim wsbackup As New AVI.AVIServiceClient
        Dim response As AVI.AddressInfoResponse
        response = wsbackup.GetAddressInfo(Address1.Text, Address2.Text, Address3.Text, Address4.Text, Address5.Text, Locality.Text, AdministrativeArea.Text, PostalCode.Text, Country.Text, OutputLanguage.Text, LicenseKey.Text)
        If (response.Error Is Nothing) Then
            ProcessValidResponse(response)
        Else
            ProcessErrorResponse(response.Error)
        End If
    Catch ex As Exception
        resultsLabel.Visible = True
        resultsLabel.Text = ex.Message
    End Try
End Try

Address Validation International Apex Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wwwServiceobjectscom.AddressInfoResponse result;
try{
wwwServiceobjectsCom.DOTSAddressValidationInternational client = new wwwServiceobjectsCom.DOTSAddressValidationInternational();
result = client.GetAddressInfo([Address1], [Address2], [Address3], [Address4], [Address5], [Locality], [AdministrativeArea], [PostalCode], [Country], [OutputLanguage], [LicenseKey]);
}
catch(Exception ex){
//If the first request failed try the failover endpoint
wwwServiceobjectsCom.DOTSAddressValidationInternational backupClient = new wwwServiceobjectsCom.DOTSAddressValidationInternational();
//The backup environment will be provided to you upon purchasing a production license key
result = backupClient.GetAddressInfo([Address1], [Address2], [Address3], [Address4], [Address5], [Locality], [AdministrativeArea], [PostalCode], [Country], [OutputLanguage], [LicenseKey]);
}
wwwServiceobjectscom.AddressInfoResponse result; try{ wwwServiceobjectsCom.DOTSAddressValidationInternational client = new wwwServiceobjectsCom.DOTSAddressValidationInternational(); result = client.GetAddressInfo([Address1], [Address2], [Address3], [Address4], [Address5], [Locality], [AdministrativeArea], [PostalCode], [Country], [OutputLanguage], [LicenseKey]); } catch(Exception ex){ //If the first request failed try the failover endpoint wwwServiceobjectsCom.DOTSAddressValidationInternational backupClient = new wwwServiceobjectsCom.DOTSAddressValidationInternational(); //The backup environment will be provided to you upon purchasing a production license key backupClient.endpoint_x = 'https://trial.serviceobjects.net/AVI/api.svc/soap'; result = backupClient.GetAddressInfo([Address1], [Address2], [Address3], [Address4], [Address5], [Locality], [AdministrativeArea], [PostalCode], [Country], [OutputLanguage], [LicenseKey]); }
wwwServiceobjectscom.AddressInfoResponse result;
try{
wwwServiceobjectsCom.DOTSAddressValidationInternational client = new wwwServiceobjectsCom.DOTSAddressValidationInternational();
result = client.GetAddressInfo([Address1], [Address2], [Address3], [Address4], [Address5], [Locality], [AdministrativeArea], [PostalCode], [Country], [OutputLanguage], [LicenseKey]);
}
catch(Exception ex){
 //If the first request failed try the failover endpoint
wwwServiceobjectsCom.DOTSAddressValidationInternational backupClient = new wwwServiceobjectsCom.DOTSAddressValidationInternational();
//The backup environment will be provided to you upon purchasing a production license key
backupClient.endpoint_x = 'https://trial.serviceobjects.net/AVI/api.svc/soap';
result = backupClient.GetAddressInfo([Address1], [Address2], [Address3], [Address4], [Address5], [Locality], [AdministrativeArea], [PostalCode], [Country], [OutputLanguage], [LicenseKey]);
}

Address Validation International TSQL Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SET @requestBody ='<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">'+
'<s:Body>'+
'<GetAddressInfo xmlns="https://www.serviceobjects.com">'+
'<Address1>' + @address1 + '</Address1>'+
'<Address2>' + @address2 + '</Address2>'+
'<Address3>' + @address3 + '</Address3>'+
'<Address4>' + @address4 + '</Address4>'+
'<Address5>' + @address5 + '</Address5>'+
'<Locality>' + @locality + '</Locality>'+
'<AdministrativeArea>' + @administrativearea + '</AdministrativeArea>'+
'<PostalCode>' + @postalcode + '</PostalCode>'+
'<Country>' + @country + '</Country>'+
'<OutputLanguage>' + @outputlanguage + '</OutputLanguage>'+
'<LicenseKey>' + @key + '</LicenseKey>'+
'</GetAddressInfo>'+
'</s:Body>'+
'</s:Envelope>'
SET @requestLength = LEN(@requestBody)
--If a production key is purchased, this will execute the failover
IF @isLiveKey = 1
BEGIN
EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', 'https://trial.serviceobjects.com/AVI/soap.svc/SOAP', false
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'sws.serviceobjects.com'
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'text/xml; charset=UTF-8'
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'SOAPAction', '"https://www.serviceobjects.com/IAVISoapService/GetAddressInfo"'
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Length', @requestLength
EXEC sp_OAMethod @obj, 'send', NULL, @requestBody
EXEC sp_OAGetProperty @obj, 'Status', @responseCode OUTPUT
EXEC sp_OAGetProperty @obj, 'StatusText', @statusText OUTPUT
EXEC sp_OAGetProperty @obj, 'responseText', @response OUTPUT
--Checks the Response for a fatal error or if null.
IF @response IS NULL
BEGIN
EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', 'https://trial.serviceobjects.com/AVI/soap.svc/SOAP', false
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'swsbackup.serviceobjects.com'
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'text/xml; charset=UTF-8'
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'SOAPAction', '"https://www.serviceobjects.com/IAVISoapService/GetAddressInfo"'
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Length', @requestLength
EXEC sp_OAMethod @obj, 'send', NULL, @requestBody
EXEC sp_OAGetProperty @obj, 'Status', @responseCode OUTPUT
EXEC sp_OAGetProperty @obj, 'StatusText', @statusText OUTPUT
EXEC sp_OAGetProperty @obj, 'responseText', @response OUTPUT
END
END
SET @requestBody ='<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">'+ '<s:Body>'+ '<GetAddressInfo xmlns="https://www.serviceobjects.com">'+ '<Address1>' + @address1 + '</Address1>'+ '<Address2>' + @address2 + '</Address2>'+ '<Address3>' + @address3 + '</Address3>'+ '<Address4>' + @address4 + '</Address4>'+ '<Address5>' + @address5 + '</Address5>'+ '<Locality>' + @locality + '</Locality>'+ '<AdministrativeArea>' + @administrativearea + '</AdministrativeArea>'+ '<PostalCode>' + @postalcode + '</PostalCode>'+ '<Country>' + @country + '</Country>'+ '<OutputLanguage>' + @outputlanguage + '</OutputLanguage>'+ '<LicenseKey>' + @key + '</LicenseKey>'+ '</GetAddressInfo>'+ '</s:Body>'+ '</s:Envelope>' SET @requestLength = LEN(@requestBody) --If a production key is purchased, this will execute the failover IF @isLiveKey = 1 BEGIN EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', 'https://trial.serviceobjects.com/AVI/soap.svc/SOAP', false EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'sws.serviceobjects.com' EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'text/xml; charset=UTF-8' EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'SOAPAction', '"https://www.serviceobjects.com/IAVISoapService/GetAddressInfo"' EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Length', @requestLength EXEC sp_OAMethod @obj, 'send', NULL, @requestBody EXEC sp_OAGetProperty @obj, 'Status', @responseCode OUTPUT EXEC sp_OAGetProperty @obj, 'StatusText', @statusText OUTPUT EXEC sp_OAGetProperty @obj, 'responseText', @response OUTPUT --Checks the Response for a fatal error or if null. IF @response IS NULL BEGIN EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', 'https://trial.serviceobjects.com/AVI/soap.svc/SOAP', false EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'swsbackup.serviceobjects.com' EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'text/xml; charset=UTF-8' EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'SOAPAction', '"https://www.serviceobjects.com/IAVISoapService/GetAddressInfo"' EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Length', @requestLength EXEC sp_OAMethod @obj, 'send', NULL, @requestBody EXEC sp_OAGetProperty @obj, 'Status', @responseCode OUTPUT EXEC sp_OAGetProperty @obj, 'StatusText', @statusText OUTPUT EXEC sp_OAGetProperty @obj, 'responseText', @response OUTPUT END END
SET @requestBody ='<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">'+
                   '<s:Body>'+
                   '<GetAddressInfo xmlns="https://www.serviceobjects.com">'+
                   '<Address1>' + @address1 + '</Address1>'+
                   '<Address2>' + @address2 + '</Address2>'+
                   '<Address3>' + @address3 + '</Address3>'+
                   '<Address4>' + @address4 + '</Address4>'+
                   '<Address5>' + @address5 + '</Address5>'+
                   '<Locality>' + @locality + '</Locality>'+
                   '<AdministrativeArea>' + @administrativearea + '</AdministrativeArea>'+
                   '<PostalCode>' + @postalcode + '</PostalCode>'+
                   '<Country>' + @country + '</Country>'+
                   '<OutputLanguage>' + @outputlanguage + '</OutputLanguage>'+
                   '<LicenseKey>' + @key + '</LicenseKey>'+
                   '</GetAddressInfo>'+
                   '</s:Body>'+
                   '</s:Envelope>'
SET @requestLength = LEN(@requestBody)
    --If a production key is purchased, this will execute the failover
IF @isLiveKey = 1
BEGIN
    EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
    EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', 'https://trial.serviceobjects.com/AVI/soap.svc/SOAP', false
    EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'sws.serviceobjects.com'
    EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'text/xml; charset=UTF-8'
    EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'SOAPAction', '"https://www.serviceobjects.com/IAVISoapService/GetAddressInfo"'
    EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Length', @requestLength
    EXEC sp_OAMethod @obj, 'send', NULL, @requestBody
    EXEC sp_OAGetProperty @obj, 'Status', @responseCode OUTPUT
    EXEC sp_OAGetProperty @obj, 'StatusText', @statusText OUTPUT
    EXEC sp_OAGetProperty @obj, 'responseText', @response OUTPUT
              
    --Checks the Response for a fatal error or if null.
    IF @response IS NULL
    BEGIN
        EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
        EXEC sp_OAMethod @obj, 'Open', NULL, 'POST', 'https://trial.serviceobjects.com/AVI/soap.svc/SOAP', false
        EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'swsbackup.serviceobjects.com'
        EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Type', 'text/xml; charset=UTF-8'
        EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'SOAPAction', '"https://www.serviceobjects.com/IAVISoapService/GetAddressInfo"'
        EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'Content-Length', @requestLength
        EXEC sp_OAMethod @obj, 'send', NULL, @requestBody
        EXEC sp_OAGetProperty @obj, 'Status', @responseCode OUTPUT
        EXEC sp_OAGetProperty @obj, 'StatusText', @statusText OUTPUT
        EXEC sp_OAGetProperty @obj, 'responseText', @response OUTPUT
    END
END

Address Validation International NodeJS Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
var args = {Address1: 'Address1',
Address2: 'Address2',
Address3: 'Address3',
Address4: 'Address4',
Address5: 'Address5',
Locality: 'Locality',
AdministrativeArea: 'AdministrativeArea',
PostalCode: 'PostalCode',
Country: 'Country',
OutputLanguage: 'OutputLanguage',
LicenseKey: 'LicenseKey'};
soap.createClient(primaryUrl, function(err, client) {
client.GetAddressInfo(args, function(err, result) {
//This is where you will handle the service results. Your business logic will determine
//how the validated information is used.
//The exact output can be found in our documentation:
//https://www.serviceobjects.com/docs/dots-address-validation-international/
if(err != null || result == null)
{
//There was an error that occurred that wasn't part of the normal service response
return;
}
else{
//Check for an error object
if(result.GetAddressInfoResult.Error != null)
{
//An error object was returned by the service and you will want to use
//the following failover logic.
//If it was a Service Objects Fatal exception we recommend trying
//a backup server.
if(result.GetAddressInfoResult.Error.TypeCode == "3")
{
//The actual backup url will be provided when you purchase a license key
var backupUrl = 'https://trial.serviceobjects.com/avi/soap.svc?wsdl';
soap.createClient(backupUrl, function(failoverErr, backupClient) {
backupClient.GetAddressInfo(args, function(failoverErr, failoverResult) {
//Handle the failoverErr or failoverResult objects.
return;
});
});
}
else{
//The Error object isn't of the type "Service Objects Fatal" so
//there is no need to use the failover logic. There was some Error of
//type Authorization, User Input, or Domain Specific.
response.writeHead(200, "OK", {'Content-Type': 'text/html'});
response.end(JSON.stringify(result));
return;
}
}
else{
//You have a non Error response.
//All of the data will reside within the result object
//As an easy to see what the service returns I am returning a JSON
//serialized version as the response.
response.writeHead(200, "OK", {'Content-Type': 'text/html'});
response.end(JSON.stringify(result));
return;
}
}
});
});
var args = {Address1: 'Address1', Address2: 'Address2', Address3: 'Address3', Address4: 'Address4', Address5: 'Address5', Locality: 'Locality', AdministrativeArea: 'AdministrativeArea', PostalCode: 'PostalCode', Country: 'Country', OutputLanguage: 'OutputLanguage', LicenseKey: 'LicenseKey'}; soap.createClient(primaryUrl, function(err, client) { client.GetAddressInfo(args, function(err, result) { //This is where you will handle the service results. Your business logic will determine //how the validated information is used. //The exact output can be found in our documentation: //https://www.serviceobjects.com/docs/dots-address-validation-international/ if(err != null || result == null) { //There was an error that occurred that wasn't part of the normal service response return; } else{ //Check for an error object if(result.GetAddressInfoResult.Error != null) { //An error object was returned by the service and you will want to use //the following failover logic. //If it was a Service Objects Fatal exception we recommend trying //a backup server. if(result.GetAddressInfoResult.Error.TypeCode == "3") { //The actual backup url will be provided when you purchase a license key var backupUrl = 'https://trial.serviceobjects.com/avi/soap.svc?wsdl'; soap.createClient(backupUrl, function(failoverErr, backupClient) { backupClient.GetAddressInfo(args, function(failoverErr, failoverResult) { //Handle the failoverErr or failoverResult objects. return; }); }); } else{ //The Error object isn't of the type "Service Objects Fatal" so //there is no need to use the failover logic. There was some Error of //type Authorization, User Input, or Domain Specific. response.writeHead(200, "OK", {'Content-Type': 'text/html'}); response.end(JSON.stringify(result)); return; } } else{ //You have a non Error response. //All of the data will reside within the result object //As an easy to see what the service returns I am returning a JSON //serialized version as the response. response.writeHead(200, "OK", {'Content-Type': 'text/html'}); response.end(JSON.stringify(result)); return; } } }); });
var args = {Address1: 'Address1',
            Address2: 'Address2',
            Address3: 'Address3',
            Address4: 'Address4',
            Address5: 'Address5',
            Locality: 'Locality',
            AdministrativeArea: 'AdministrativeArea',
            PostalCode: 'PostalCode',
            Country: 'Country',
            OutputLanguage: 'OutputLanguage',
            LicenseKey: 'LicenseKey'};
soap.createClient(primaryUrl, function(err, client) {
      
    client.GetAddressInfo(args, function(err, result) {
        //This is where you will handle the service results. Your business logic will determine
        //how the validated information is used.
        //The exact output can be found in our documentation:
        //https://www.serviceobjects.com/docs/dots-address-validation-international/
        if(err != null || result == null)
        {
            //There was an error that occurred that wasn't part of the normal service response
            return;
        }
        else{
            //Check for an error object
            if(result.GetAddressInfoResult.Error != null)
            {
                //An error object was returned by the service and you will want to use
                //the following failover logic.
                //If it was a Service Objects Fatal exception we recommend trying
                //a backup server.
                if(result.GetAddressInfoResult.Error.TypeCode == "3")
                {
                    //The actual backup url will be provided when you purchase a license key
                    var backupUrl = 'https://trial.serviceobjects.com/avi/soap.svc?wsdl';
                    soap.createClient(backupUrl, function(failoverErr, backupClient) {
      
                        backupClient.GetAddressInfo(args, function(failoverErr, failoverResult) {
                            //Handle the failoverErr or failoverResult objects.
                            return;
                        });
                    });
                }
                else{
                    //The Error object isn't of the type "Service Objects Fatal" so
                    //there is no need to use the failover logic. There was some Error of
                    //type Authorization, User Input, or Domain Specific.
                    response.writeHead(200, "OK", {'Content-Type': 'text/html'});
                    response.end(JSON.stringify(result));
                    return;
                }
            }
            else{
                //You have a non Error response.
                //All of the data will reside within the result object
                //As an easy to see what the service returns I am returning a JSON
                //serialized version as the response.
                response.writeHead(200, "OK", {'Content-Type': 'text/html'});
                response.end(JSON.stringify(result));
                return;
            }
        }
        });
});