Bin Validation C# Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
//Add a service to your application https://trial.serviceobjects.com/bv/soap.svc?wsdl
DOTSBinValidation DOTSBinValidation = new DOTSBinValidation();
BinValidationResult response = DOTSBinValidation.ValidateBIN(BinNumber.Text, LicenseKey.Text);
if (response.Error != null)
{
//Process Error
}
else
{
//Process Response
}
//Add a service to your application https://trial.serviceobjects.com/bv/soap.svc?wsdl DOTSBinValidation DOTSBinValidation = new DOTSBinValidation(); BinValidationResult response = DOTSBinValidation.ValidateBIN(BinNumber.Text, LicenseKey.Text); if (response.Error != null) { //Process Error } else { //Process Response }
//Add a service to your application https://trial.serviceobjects.com/bv/soap.svc?wsdl
DOTSBinValidation DOTSBinValidation = new DOTSBinValidation();
BinValidationResult response = DOTSBinValidation.ValidateBIN(BinNumber.Text, LicenseKey.Text);
         
if (response.Error != null)
{
    //Process Error
}
else
{
    //Process Response     
}

Bin Validation Java Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
BinValidationResult binValidationResult;
DOTSBinValidationLocator locator = new DOTSBinValidationLocator();
DOTSBinValidationSoap soapRequest = locator.getDOTSBinValidationSoap();
binValidationResult = soapRequest.validateBIN(binNumber,key);
Error error = binValidationResult.getError();
BinValidationInfo binInfo = binValidationResult.getBinValidationInfo();
if(binInfo== null || (error != null && error.getTypeCode() == "3"))
{
throw new Exception();
}
//Process Results
if(error == null){
//DOTS Bin Validation Results
}
//Process Errors
else{
//DOTS Bin Validation Error Results
}
BinValidationResult binValidationResult; DOTSBinValidationLocator locator = new DOTSBinValidationLocator(); DOTSBinValidationSoap soapRequest = locator.getDOTSBinValidationSoap(); binValidationResult = soapRequest.validateBIN(binNumber,key); Error error = binValidationResult.getError(); BinValidationInfo binInfo = binValidationResult.getBinValidationInfo(); if(binInfo== null || (error != null && error.getTypeCode() == "3")) { throw new Exception(); } //Process Results if(error == null){ //DOTS Bin Validation Results } //Process Errors else{ //DOTS Bin Validation Error Results }
BinValidationResult binValidationResult;
DOTSBinValidationLocator locator = new DOTSBinValidationLocator();
DOTSBinValidationSoap soapRequest = locator.getDOTSBinValidationSoap();
binValidationResult = soapRequest.validateBIN(binNumber,key);
Error error = binValidationResult.getError();
BinValidationInfo binInfo = binValidationResult.getBinValidationInfo();
if(binInfo== null || (error != null && error.getTypeCode() == "3"))
{
    throw new Exception();
}
  
//Process Results
if(error == null){
    //DOTS Bin Validation Results  
}
//Process Errors
else{
    //DOTS Bin Validation Error Results
}

Bin Validation PHP Code Snippets

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<?php
// Set these values per web service <as needed>
$params['BinNumber'] = $binNumber;
$params['LicenseKey'] = $licenseKey;
$soapClient = new SoapClient($wsdlUrl, array( "trace" => 1 ));
$result = $soapClient->ValidateBIN($params)->ValidateBINResult;
if (!isset($result->Error)) {
foreach($result->BinValidationInfo; $k=>$v) {
echo $k . ", " . $v;
}
} else {
foreach($result->Error as $k=>$v) {
echo $k . ", " . $v;
}
}
?>
<?php // Set these values per web service <as needed> $wsdlUrl = "https://trial.serviceobjects.com/bv/soap.svc?wsdl"; $params['BinNumber'] = $binNumber; $params['LicenseKey'] = $licenseKey; $soapClient = new SoapClient($wsdlUrl, array( "trace" => 1 )); $result = $soapClient->ValidateBIN($params)->ValidateBINResult; if (!isset($result->Error)) { foreach($result->BinValidationInfo; $k=>$v) { echo $k . ", " . $v; } } else { foreach($result->Error as $k=>$v) { echo $k . ", " . $v; } } ?>
<?php
// Set these values per web service <as needed>
$wsdlUrl = "https://trial.serviceobjects.com/bv/soap.svc?wsdl";
 
$params['BinNumber'] = $binNumber;
$params['LicenseKey'] = $licenseKey;
 
$soapClient = new SoapClient($wsdlUrl, array( "trace" => 1 ));
$result = $soapClient->ValidateBIN($params)->ValidateBINResult;
if (!isset($result->Error)) {
    foreach($result->BinValidationInfo; $k=>$v) {
        echo $k . ", " . $v;
    }
} else {
    foreach($result->Error as $k=>$v) {
        echo $k . ", " . $v;
    }
}
?>

Bin Validation RoR 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 = {
"BinNumber" => @request.binnumber,
"LicenseKey" => @request.licensekey,
}
#Implemented to make the code more readable when accessing the hash
@bvresponse = :validate_bin_response
@bvresult = :validate_bin_result
@bvinfo = :bin_validation_info
@bverror = :error
#Set Primary and Backup URLs here as needed
begin
#initializes the soap client. The convert request keys global is necessary to receive a response from the service.
client = Savon.client( wsdl: dotsBVPrimary,
element_form_default: :qualified,
convert_request_keys_to: :camelcase
)
#Calls the operation with given inptus and converts response to a hash.
response = client.call(:validate_bin, 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 backup url and attempt to retrieve data.
rescue Savon::Error => e
begin
backupclient = Savon.client( wsdl: dotsBVBackup,
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(:validate_bin, message: message).to_hash
processresults(response)
#If backup url failed, this will display the error received from the server
rescue Savon::Error =>error
end
end
end
private
#processes HTTParty response and uses hash names to display
def processresults(response)
#Processes Error Response from the web service
#Processes a valid response from the web service
end
#Formats inputs into a hash to pass to Soap Client #Hash Keys must be named as they are shown here. message = { "BinNumber" => @request.binnumber, "LicenseKey" => @request.licensekey, } #Implemented to make the code more readable when accessing the hash @bvresponse = :validate_bin_response @bvresult = :validate_bin_result @bvinfo = :bin_validation_info @bverror = :error #Set Primary and Backup URLs here as needed dotsBVPrimary = "https://trial.serviceobjects.com/bv/soap.svc?wsdl" dotsBVBackup = "https://trial.serviceobjects.com/bv/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: dotsBVPrimary, element_form_default: :qualified, convert_request_keys_to: :camelcase ) #Calls the operation with given inptus and converts response to a hash. response = client.call(:validate_bin, 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 backup url and attempt to retrieve data. rescue Savon::Error => e begin backupclient = Savon.client( wsdl: dotsBVBackup, 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(:validate_bin, message: message).to_hash processresults(response) #If backup url failed, this will display the error received from the server rescue Savon::Error =>error end end end private #processes HTTParty response and uses hash names to display def processresults(response) #Processes Error Response from the web service #Processes a valid response from the web service end
#Formats inputs into a hash to pass to Soap Client
    #Hash Keys must be named as they are shown here.
    message =   {
                "BinNumber" => @request.binnumber,
                "LicenseKey" => @request.licensekey,
                }
    #Implemented to make the code more readable when accessing the hash        
    @bvresponse = :validate_bin_response
    @bvresult = :validate_bin_result
    @bvinfo = :bin_validation_info
    @bverror = :error
 
    #Set Primary and Backup URLs here as needed
    dotsBVPrimary = "https://trial.serviceobjects.com/bv/soap.svc?wsdl"
    dotsBVBackup = "https://trial.serviceobjects.com/bv/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: dotsBVPrimary,
                                element_form_default: :qualified,
                                convert_request_keys_to: :camelcase
                             )
        #Calls the operation with given inptus and converts response to a hash.
        response = client.call(:validate_bin, 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 backup url and attempt to retrieve data.
    rescue Savon::Error => e
        begin
        backupclient = Savon.client(    wsdl: dotsBVBackup,
                                        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(:validate_bin, message: message).to_hash
        processresults(response)
 
        #If backup url failed, this will display the error received from the server
        rescue Savon::Error =>error
        end
    end
end
private
  #processes HTTParty response and uses hash names to display
def processresults(response)   
        #Processes Error Response from the web service     
        #Processes a valid response from the web service
end

Bin Validation Python Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
mBinNumber = BinNumber.get()
if mBinNumber is None or mBinNumber == "":
mBinNumber = " "
mLicenseKey = LicenseKey.get()
if mLicenseKey is None or mLicenseKey == "":
mLicenseKey = " "
#Set the primary and backup URLs as needed
#This block of code calls the web service and prints the resulting values to the screen
try:
client = Client(primaryURL)
result = client.service.ValidateBIN(BinNumber= mBinNumber, LicenseKey=mLicenseKey)
#Handel response and check for errors
#Tries the backup URL if the primary URL failed
except:
try:
client = Client(backupURL)
result = client.service.ValidateBIN(BinNumber= mBinNumber, LicenseKey=mLicenseKey)
#Handel response and check for errors
#If the backup call failed then this will display an error to the screen
except:
Label(swin.window, text='Error').pack()
print (result)
mBinNumber = BinNumber.get() if mBinNumber is None or mBinNumber == "": mBinNumber = " " mLicenseKey = LicenseKey.get() if mLicenseKey is None or mLicenseKey == "": mLicenseKey = " " #Set the primary and backup URLs as needed primaryURL = 'https://trial.serviceobjects.com/bv/soap.svc?wsdl' backupURL = 'https://trial.serviceobjects.com/bv/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.ValidateBIN(BinNumber= mBinNumber, LicenseKey=mLicenseKey) #Handel response and check for errors #Tries the backup URL if the primary URL failed except: try: client = Client(backupURL) result = client.service.ValidateBIN(BinNumber= mBinNumber, LicenseKey=mLicenseKey) #Handel response and check for errors #If the backup call failed then this will display an error to the screen except: Label(swin.window, text='Error').pack() print (result)
mBinNumber =  BinNumber.get()
if mBinNumber is None or  mBinNumber == "":
     mBinNumber = " "
mLicenseKey = LicenseKey.get()
if mLicenseKey is None or mLicenseKey == "":
    mLicenseKey = " "
 
#Set the primary and backup URLs as needed
primaryURL = 'https://trial.serviceobjects.com/bv/soap.svc?wsdl'
backupURL = 'https://trial.serviceobjects.com/bv/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.ValidateBIN(BinNumber= mBinNumber, LicenseKey=mLicenseKey)
    #Handel response and check for errors
 
#Tries the backup URL if the primary URL failed
except:
    try:
        client = Client(backupURL)
        result = client.service.ValidateBIN(BinNumber= mBinNumber, LicenseKey=mLicenseKey)
        #Handel response and check for errors
 
 
    #If the backup call failed then this will display an error to the screen
    except:
        Label(swin.window, text='Error').pack()
        print (result)

Bin Validation ColdFusion Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!--Makes Request to web service --->
<!--Old Service Reference: https://trial.serviceobjects.com/bv/BinValidation.asmx?WSDL --->
<cfscript>
try
{
if (isDefined("form.Action") AND Action neq "")
{
wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/bv/soap.svc?wsdl");
outputs = wsresponse.validateBin("#BinNumber#" ,"#LicenseKey#");
}
}
catch(any Exception)
{
try
{
if (isDefined("form.Action") AND Action neq "")
{
wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/bv/soap.svc?wsdl");
outputs = wsresponse.validateBin("#BinNumber#" ,"#LicenseKey#");
}
}
catch(any Exception)
{
writeoutput("An Error Has Occured. Please Reload and try again #Exception.message#");
}
}
</cfscript>
<!--Makes Request to web service ---> <!--Old Service Reference: https://trial.serviceobjects.com/bv/BinValidation.asmx?WSDL ---> <cfscript> try { if (isDefined("form.Action") AND Action neq "") { wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/bv/soap.svc?wsdl"); outputs = wsresponse.validateBin("#BinNumber#" ,"#LicenseKey#"); } } catch(any Exception) { try { if (isDefined("form.Action") AND Action neq "") { wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/bv/soap.svc?wsdl"); outputs = wsresponse.validateBin("#BinNumber#" ,"#LicenseKey#"); } } catch(any Exception) { writeoutput("An Error Has Occured. Please Reload and try again #Exception.message#"); } } </cfscript>
<!--Makes Request to web service --->
<!--Old Service Reference: https://trial.serviceobjects.com/bv/BinValidation.asmx?WSDL --->
<cfscript>
    try
    {
        if (isDefined("form.Action") AND Action neq "")
        {
            wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/bv/soap.svc?wsdl");                            
            outputs = wsresponse.validateBin("#BinNumber#" ,"#LicenseKey#");
        }
    }
    catch(any Exception)
    {
        try
            {
                if (isDefined("form.Action") AND Action neq "")
                {
                    wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/bv/soap.svc?wsdl");                            
                    outputs = wsresponse.validateBin("#BinNumber#" ,"#LicenseKey#");
                }
            }
            catch(any Exception)   
                {
                 writeoutput("An Error Has Occured. Please Reload and try again #Exception.message#");              
                }
     }
</cfscript>

Bin Validation VB Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Try
Dim ws As New BV.DOTSBinValidationSoapClient
Dim response As BV.BinValidationResult
response = ws.ValidateBIN(BIN.Text, LicenseKey.Text)
If (response.Error Is Nothing) Then
ProcessValidResponse(response.BinValidationInfo)
Else
ProcessErrorResponse(response.Error)
End If
Catch er As Exception
Try
Dim ws As New BV.DOTSBinValidationSoapClient
Dim response As BV.BinValidationResult
response = ws.ValidateBIN(BIN.Text, LicenseKey.Text)
If (response.Error Is Nothing) Then
ProcessValidResponse(response.BinValidationInfo)
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 BV.DOTSBinValidationSoapClient Dim response As BV.BinValidationResult response = ws.ValidateBIN(BIN.Text, LicenseKey.Text) If (response.Error Is Nothing) Then ProcessValidResponse(response.BinValidationInfo) Else ProcessErrorResponse(response.Error) End If Catch er As Exception Try Dim ws As New BV.DOTSBinValidationSoapClient Dim response As BV.BinValidationResult response = ws.ValidateBIN(BIN.Text, LicenseKey.Text) If (response.Error Is Nothing) Then ProcessValidResponse(response.BinValidationInfo) 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 BV.DOTSBinValidationSoapClient
    Dim response As BV.BinValidationResult
    response = ws.ValidateBIN(BIN.Text, LicenseKey.Text)
    If (response.Error Is Nothing) Then
        ProcessValidResponse(response.BinValidationInfo)
    Else
        ProcessErrorResponse(response.Error)
    End If
 
Catch er As Exception
    Try
        Dim ws As New BV.DOTSBinValidationSoapClient
        Dim response As BV.BinValidationResult
        response = ws.ValidateBIN(BIN.Text, LicenseKey.Text)
        If (response.Error Is Nothing) Then
            ProcessValidResponse(response.BinValidationInfo)
        Else
            ProcessErrorResponse(response.Error)
        End If
    Catch ex As Exception
        resultsLabel.Visible = True
        resultsLabel.Text = ex.Message
    End Try
End Try

Bin Validation Apex Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wwwServiceobjectsCom.BinValidationResult result;
try{
wwwServiceobjectsCom.DOTSBinValidationSoap client = new wwwServiceobjectsCom.DOTSBinValidationSoap();
result = client.ValidateBIN([BINNumber], [LicenseKey]);
}
catch(Exception ex){
//If the first request failed try the failover endpoint
wwwServiceobjectsCom.DOTSBinValidationSoap backupClient = new wwwServiceobjectsCom.DOTSBinValidationSoap();
//The backup environment will be provided to you upon purchasing a production license key
result = backupClient.ValidateBIN([BINNumber], [LicenseKey]);
}
wwwServiceobjectsCom.BinValidationResult result; try{ wwwServiceobjectsCom.DOTSBinValidationSoap client = new wwwServiceobjectsCom.DOTSBinValidationSoap(); result = client.ValidateBIN([BINNumber], [LicenseKey]); } catch(Exception ex){ //If the first request failed try the failover endpoint wwwServiceobjectsCom.DOTSBinValidationSoap backupClient = new wwwServiceobjectsCom.DOTSBinValidationSoap(); //The backup environment will be provided to you upon purchasing a production license key backupClient.endpoint_x = 'https://trial.serviceobjects.com/BV/api.svc/soap'; result = backupClient.ValidateBIN([BINNumber], [LicenseKey]); }
wwwServiceobjectsCom.BinValidationResult result;
try{
wwwServiceobjectsCom.DOTSBinValidationSoap client = new wwwServiceobjectsCom.DOTSBinValidationSoap();
result = client.ValidateBIN([BINNumber], [LicenseKey]);
}
catch(Exception ex){
 //If the first request failed try the failover endpoint
wwwServiceobjectsCom.DOTSBinValidationSoap backupClient = new wwwServiceobjectsCom.DOTSBinValidationSoap();
//The backup environment will be provided to you upon purchasing a production license key
backupClient.endpoint_x = 'https://trial.serviceobjects.com/BV/api.svc/soap';
result = backupClient.ValidateBIN([BINNumber], [LicenseKey]);
}

Bin Validation 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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'+
'<ValidateBIN xmlns="https://www.serviceobjects.com/">'+
'<BinNumber>' + @bin + '</BinNumber>'+
'<LicenseKey>' + @key + '</LicenseKey>'+
'</ValidateBIN>'+
'</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/bv/BinValidation.asmx', false
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'trial.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/ValidateBIN"'
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/bv/BinValidation.asmx', false
EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'trial.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/ValidateBIN"'
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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'+ '<ValidateBIN xmlns="https://www.serviceobjects.com/">'+ '<BinNumber>' + @bin + '</BinNumber>'+ '<LicenseKey>' + @key + '</LicenseKey>'+ '</ValidateBIN>'+ '</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/bv/BinValidation.asmx', false EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'trial.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/ValidateBIN"' 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/bv/BinValidation.asmx', false EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'trial.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/ValidateBIN"' 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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">'+
                   '<ValidateBIN xmlns="https://www.serviceobjects.com/">'+
                   '<BinNumber>' + @bin + '</BinNumber>'+
                   '<LicenseKey>' + @key + '</LicenseKey>'+
                   '</ValidateBIN>'+
                   '</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/bv/BinValidation.asmx', false
    EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'trial.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/ValidateBIN"'
    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/bv/BinValidation.asmx', false
        EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 'trial.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/ValidateBIN"'
        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