Email Validation 3 C# Code Snippet

EV3LibraryClient EV3Client_Backup = null;
ValidateEmailResponse response = null;
  
try
{
    EV3Client_Primary = new EV3LibraryClient("DOTSEV3PRIMARY");
    EV3Client_Primary.InnerChannel.OperationTimeout = new TimeSpan(0, 0, 0, WEB_SERVICE_REQUEST_TIMEOUT);
    response = EV3Client_Primary.ValidateEmailAddress(EmailAddress, AllowCorrection, Timeout, LicenseKey);///EQUATE TO RESPONSE
    //NULL ERROR || FATAL ERROR RETURNE -- TRY BACKUP
    if (response == null || (response.Error != null && response.Error.TypeCode == "3"))
    {
        throw new Exception();
    }
    return response;
}
catch (Exception e)
{
    try
    {
        EV3Client_Backup = new EV3LibraryClient("DOTSEV3BACKUP");
        EV3Client_Backup.InnerChannel.OperationTimeout = new TimeSpan(0, 0, 0, WEB_SERVICE_REQUEST_TIMEOUT);
        return EV3Client_Backup.ValidateEmailAddress(EmailAddress, AllowCorrection, Timeout, LicenseKey);
    }
    catch (System.Exception ex)
    {
        throw ex;
    }
    finally
    {
        if (EV3Client_Backup != null) { EV3Client_Backup.Close(); }
    }
}

Email Validation 3 Java Code Snippet

try{
  
          
    ValidateEmailResponse resp = null;
    ValidateEmailInfo result = null;
    Error error = null;
    String email = request.getParameter("iEmail");
    String allowcorrections = request.getParameter("iAllowCorrections");//
    String timeout = request.getParameter("iTimeout");//
    String key = request.getParameter("iKey");
      
    // Create soap request
    EV3LibraryLocator locator = new EV3LibraryLocator();
    // use ssl
    locator.setDOTSEmailValidation3EndpointAddress("https://trial.serviceobjects.com/ev3/soap.svc/soap");
    IEV3Library ev3 = locator.getDOTSEmailValidation3();
    DOTSEmailValidation3Stub soap = (DOTSEmailValidation3Stub)ev3;
    soap.setTimeout(5000);// set timeout
    try{
      
        resp = soap.validateEmailAddress(email, allowcorrections, timeout, key);//validateEmailFull
  
        result = resp.getValidateEmailInfo();
  
        error = resp.getError();
        if(resp == null || (error != null && error.getTypeCode() == "3"))
        {
            throw new Exception();
        }
          
        }
        catch(Exception e)
        {   //FAILOVER- USE BACKUP NOW
            try{
                //CALL SOAP USING BACKUP URL (Change the endpoint)
                resp = soap.validateEmailAddress(email, allowcorrections, timeout, key);
  
                result = resp.getValidateEmailInfo();
  
                error = resp.getError();
  
            }
            catch(Exception ex)
            {
          
                throw new Exception("Both Primary and Backup soap calls failed: " + ex.getMessage());
            }
        }

Email Validation 3 PHP Code Snippet

// Set these values per web service <as needed>
$wsdlUrl = "https://trial.serviceobjects.com/ev3/soap.svc?wsdl";
$backupWsdlUrl = "https://trial.serviceobjects.com/ev3/soap.svc?wsdl";
  
// Create the SoapClient and pass the URL to the WSDL file and optional parameters as needed
// $soapClient = new SoapClient($wsdlUrl, array("trace" => true, "exceptions" => false,));
  
  
$Email = trim($Email);
$AllowCorrections=trim($AllowCorrections);
$Timeout=trim($Timeout);
$LicenseKey = trim($LicenseKey);
  
$params['EmailAddress'] = $Email;
$params['AllowCorrections']=$AllowCorrections;
$params['Timeout']=$Timeout;
$params['LicenseKey'] = $LicenseKey;
  
  
// variable cleanup before generating url
  
$Email = strtr($Email,' ','+');
$AllowCorrections = strtr($AllowCorrections,' ','+');
$Timeout = strtr($Timeout,' ','+');
  
  
echo "<hr><h4>Email Validation 3 Result</h4><br><a href='https://trial.serviceobjects.com/ev3/web.svc/xml/ValidateEmailAddress?EmailAddress=".$Email."&AllowCorrections=".$AllowCorrections."&Timeout=".$Timeout."&LicenseKey=".$LicenseKey."'>Raw XML output</a><br>";
try{
$soapClient = new SoapClient($wsdlUrl, array( "trace" => 1 ));
$result = $soapClient->ValidateEmailAddress($params);
}
catch(Exception $e)
    {
        try
        {
        $soapClient = new SoapClient($backupWsdlUrl, array( "trace" => 1 ));
        $result = $soapClient->ValidateEmailAddress($params);
        }
        catch(Exception $ex)
        {//Both soap calls failed
            echo "<b> Primary and backup wsdls failed </b>";
            echo "$ex";
        }
      
    }

Email Validation 3 RoR Code Snippet

#Formats inputs into a hash to pass to Soap Client
        message =   {
                    "EmailAddress" => @request.email,
                    "AllowCorrections" => @request.allowcorrections,
                    "Timeout" => @request.timeout,
                    "LicenseKey" => @request.licensekey,
                    }
  
        #Implemented to make the code more readable when accessing the hash        
        @ev3response = :validate_email_address_response
        @ev3result = :validate_email_address_result
        @ev3info = :validate_email_info
        @ev3error = :error
  
        #Set Primary and Backup URLs here as needed
        dotsEV3Primary = "https://trial.serviceobjects.com/ev3/soap.svc?wsdl"
        dotsEV3Backup = "https://trial.serviceobjects.com/ev3/soap.svc?wsdl"
  
        begin
            #initializes the soap client. The convert request keys global is necessary to receive a response from the service.
            client = Savon.client(  wsdl: dotsEV3Primary )
            #Calls the validate_email_address operation with given inptus and converts response to a hash.
            response = client.call(:validate_email_address, 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 dotsEV3Backup url and attempt to retrieve data.
        rescue Savon::Error => e
            begin
            backupclient = Savon.client(wsdl: dotsEV3Backup)
  
            #Sets the response to the backclient call to the ValidateEmailAddress operation and converts response to a hash.
            response = backupclient.call(:validate_email_address, message: message).to_hash
            processresults(response)
  
            #If dotsEV3Backup failed, this will display the error received from the server
            rescue Savon::Error =>error
            end
        end
    end
    private
    def processresults(response)   
            #Processes Error Response from soap Client     
            #Processes Valid response from soap client 
            end
    end

Email Validation 3 Python Code Snippet

mEmailAddress =  EmailAddress.get()
if mEmailAddress is None or  mEmailAddress == "":
     mEmailAddress = " "
mAllowCorrections =  AllowCorrections.get()
if mAllowCorrections is None or  mAllowCorrections == "":
     mAllowCorrections = " "
mTimeout =  Timeout.get()
if mTimeout is None or  mTimeout == "":
     mTimeout = " "
mLicenseKey = LicenseKey.get()
if mLicenseKey is None or mLicenseKey == "":
    mLicenseKey = " "
#Set the primary and backup URLs as needed
primaryURL = 'https://trial.serviceobjects.com/ev3/soap.svc?wsdl'
backupURL = 'https://trial.serviceobjects.com/ev3/soap.svc?wsdl'
#This block of code calls the web service and prints the resulting values to the screen
try:
    client = Client(primaryURL)
    result = client.service.ValidateEmailAddress(EmailAddress= mEmailAddress, AllowCorrections=mAllowCorrections, Timeout=mTimeout, LicenseKey=mLicenseKey)

Email Validation 3 Code Snippet

<!--Makes Request to web service --->
<cfscript>
        try
        {
            if (isDefined("form.Action") AND Action neq "")
            {
                wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/ev3/soap.svc?wsdl");                           
                outputs = wsresponse.validateEmailAddress("#EmailAddress#", "#AllowCorrections#", "#Timeout#", "#LicenseKey#");
            }
        }
    catch(any Exception){
        try
            {
                if (isDefined("form.Action") AND Action neq "")
                {
                    wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/ev3/soap.svc?wsdl");                           
                    outputs = wsresponse.validateEmailAddress("#EmailAddress#", "#AllowCorrections#", "#Timeout#", "#LicenseKey#");
                }
            }
            catch(any Exception)    {
                 writeoutput("An Error Has Occured. Please Reload and try again");              
                }
        }
</cfscript>

Email Validation 3 Visual Basic Code Snippet

Dim ws As New EV3.EV3LibraryClient
Dim response As EV3.ValidateEmailResponse
  
response = ws.ValidateEmailAddress(EmailAddress.Text, AllowCorrections.Text, Timeout.Text, LicenseKey.Text)
If (response.Error Is Nothing) Then
    ProcessValidResponse(response)
Else
    ProcessErrorResponse(response.Error)
End If

Email Validation 3 Apex Code Snippet

wwwServiceobjectsComEV3.ValidateEmailResponse result;
try{
wwwServiceobjectsComEV3.DOTSEmailValidation3 client = new wwwServiceobjectsComEV3.DOTSEmailValidation3();
result = client.ValidateEmailAddress([EmailAddress], [AllowCorrections], [Timeout], [Licensekey]);
}
catch(Exception ex){
 //If the first request failed try the failover endpoint
wwwServiceobjectsComEV3.DOTSEmailValidation3 backupClient = new wwwServiceobjectsComEV3.DOTSEmailValidation3();
//The backup environment will be provided to you upon purchasing a production license key
backupClient.endpoint_x = 'https://trial.serviceobjects.com/EV3/soap.svc/soap';
result = backupClient.ValidateEmailAddress([EmailAddress], [AllowCorrections], [Timeout], [Licensekey]);
}

Email Validation 3 TSQL Code Snippet

SET @requestBody ='<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">'+
                   '<s:Body>'+
                   '<ValidateEmailAddress xmlns="https://www.serviceobjects.com">'+
                   '<EmailAddress>' + @email + '</EmailAddress>'+
                   '<AllowCorrections>' + @allowcorrections + '</AllowCorrections>'+
                   '<Timeout>' + @timeout + '</Timeout>'+
                   '<LicenseKey>' + @key + '</LicenseKey>'+
                   '</ValidateEmailAddress>'+
                   '</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://sws.serviceobjects.com/ev3/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/IEV3Library/ValidateEmailAddress"'
    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://swsbackup.serviceobjects.com/ev3/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/IEV3Library/ValidateEmailAddress"'
        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