IP Address Validation C# Rest Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
//encodes the URLs for the get Call. Set the primary and back urls as necessary
string primaryurl = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + WebUtility.UrlEncode(ipaddress) + "&LicenseKey=" + WebUtility.UrlEncode(licensekey);
string backupurl = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + WebUtility.UrlEncode(ipaddress) + "&LicenseKey=" + WebUtility.UrlEncode(licensekey);
IP4 wsresponse = httpGet(primaryurl);
//checks if a response was returned from the service, uses the backup url if response is null or a fatal error occured.
if (wsresponse == null || (wsresponse.Error != null && wsresponse.Error.Number == "3"));
{
wsresponse = httpGet(backupurl);
}
if (wsresponse.Error != null)
{
ProcessErrorResponse(wsresponse.Error);
}
else
{
ProcessSuccessfulResponse(wsresponse);
}
//encodes the URLs for the get Call. Set the primary and back urls as necessary string primaryurl = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + WebUtility.UrlEncode(ipaddress) + "&LicenseKey=" + WebUtility.UrlEncode(licensekey); string backupurl = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + WebUtility.UrlEncode(ipaddress) + "&LicenseKey=" + WebUtility.UrlEncode(licensekey); IP4 wsresponse = httpGet(primaryurl); //checks if a response was returned from the service, uses the backup url if response is null or a fatal error occured. if (wsresponse == null || (wsresponse.Error != null && wsresponse.Error.Number == "3")); { wsresponse = httpGet(backupurl); } if (wsresponse.Error != null) { ProcessErrorResponse(wsresponse.Error); } else { ProcessSuccessfulResponse(wsresponse); }
//encodes the URLs for the get Call. Set the primary and back urls as necessary
string primaryurl = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + WebUtility.UrlEncode(ipaddress) + "&LicenseKey=" + WebUtility.UrlEncode(licensekey);
string backupurl = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + WebUtility.UrlEncode(ipaddress) + "&LicenseKey=" + WebUtility.UrlEncode(licensekey);
IP4 wsresponse = httpGet(primaryurl);
//checks if a response was returned from the service, uses the backup url if response is null or a fatal error occured.
if (wsresponse == null || (wsresponse.Error != null && wsresponse.Error.Number == "3"));
{
    wsresponse = httpGet(backupurl);
}
if (wsresponse.Error != null)
{
    ProcessErrorResponse(wsresponse.Error);
}
else
{
    ProcessSuccessfulResponse(wsresponse);
}

IP Address Validation Java Rest Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
JSONObject results = RestClient(mainURL);
try {
if (ErrorMessages != null || (results.getJSONObject("IP4").has("Error") && results.getJSONObject("IP4").getJSONObject("Error").get("Number") == "3")) {
// BACKUP
results = RestClient(backupURL);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return results;
JSONObject results = RestClient(mainURL); try { if (ErrorMessages != null || (results.getJSONObject("IP4").has("Error") && results.getJSONObject("IP4").getJSONObject("Error").get("Number") == "3")) { // BACKUP results = RestClient(backupURL); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return results;
JSONObject results = RestClient(mainURL);  
try {
    if (ErrorMessages != null || (results.getJSONObject("IP4").has("Error") && results.getJSONObject("IP4").getJSONObject("Error").get("Number") == "3")) {
        // BACKUP
        results = RestClient(backupURL);
    }
} catch (JSONException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
 
return results;

IP Address Validation PHP Rest Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$URL = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=".urlencode($IP)."&LicenseKey=".urlencode($LicenseKey);
//use backup url once given purchased license key
$backupURL = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=".urlencode($IP)."&LicenseKey=".urlencode($LicenseKey);
// Get cURL resource
$curl = curl_init();
curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $URL, CURLOPT_USERAGENT => 'DOTS IP Address Validation'));
curl_setopt($curl, CURLOPT_TIMEOUT, 50); //timeout in seconds
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
if($resp == false)
{
echo "IN back up block";
curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $backupURL, CURLOPT_USERAGENT => 'DOTS IP Address Validation'));
curl_setopt($curl, CURLOPT_TIMEOUT, 50); //timeout in seconds
// Send the request & save response to $resp
$resp = curl_exec($curl);
if($resp == false)
{
echo "<b> Both rest calls failed </b>";
curl_close($curl);
return;
}
}
$URL = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=".urlencode($IP)."&LicenseKey=".urlencode($LicenseKey); //use backup url once given purchased license key $backupURL = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=".urlencode($IP)."&LicenseKey=".urlencode($LicenseKey); // Get cURL resource $curl = curl_init(); curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $URL, CURLOPT_USERAGENT => 'DOTS IP Address Validation')); curl_setopt($curl, CURLOPT_TIMEOUT, 50); //timeout in seconds // Send the request & save response to $resp $resp = curl_exec($curl); // Close request to clear up some resources if($resp == false) { echo "IN back up block"; curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $backupURL, CURLOPT_USERAGENT => 'DOTS IP Address Validation')); curl_setopt($curl, CURLOPT_TIMEOUT, 50); //timeout in seconds // Send the request & save response to $resp $resp = curl_exec($curl); if($resp == false) { echo "<b> Both rest calls failed </b>"; curl_close($curl); return; } }
$URL = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=".urlencode($IP)."&LicenseKey=".urlencode($LicenseKey);
//use backup url once given purchased license key
$backupURL = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=".urlencode($IP)."&LicenseKey=".urlencode($LicenseKey);
  
// Get cURL resource
$curl = curl_init();
curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $URL, CURLOPT_USERAGENT => 'DOTS IP Address Validation'));
curl_setopt($curl, CURLOPT_TIMEOUT, 50); //timeout in seconds
// Send the request & save response to $resp
$resp = curl_exec($curl);
// Close request to clear up some resources
if($resp == false)
{
    echo "IN back up block";
    curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $backupURL, CURLOPT_USERAGENT => 'DOTS IP Address Validation'));
    curl_setopt($curl, CURLOPT_TIMEOUT, 50); //timeout in seconds
    // Send the request & save response to $resp
    $resp = curl_exec($curl);
    if($resp == false)
    {
        echo "<b> Both rest calls failed </b>";
        curl_close($curl);
        return;
    }
}

IP Address Validation RoR Rest Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#Set Primary and Backup URLs as needed. This method encodes and standardizes the URI to pass to the REST service.
primaryURL = URI.encode("https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + ipaddress + "&LicenseKey=" + licensekey)
backupURL = URI.encode("https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + ipaddress + "&LicenseKey=" + licensekey)
#These are set to access the hash that is returned
@ipavresult ="IP4"
@ipaverror = "Error"
#Begins the call the RESTful web service
begin
response = HTTParty.get(primaryURL, timeout: default_timeout)
#processes the response to display to the screen
#Passes the response returned from HTTParty and processes them depending on the results
processresults(response)
rescue StandardError => e
begin
#uses the backupURl in the event that the service encountered an error
response = HTTParty.get(backupURL, timeout: default_timeout)
#processes the response returned from using the backupURL
processresults(response)
#If the backup url railed this will raise an error and display the
#error message returned from the HTTParty gem.
rescue StandardError => error
@status = error.message
@displaydata = {"Error" => "A Big Error Occured"}
end
end
#Set Primary and Backup URLs as needed. This method encodes and standardizes the URI to pass to the REST service. primaryURL = URI.encode("https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + ipaddress + "&LicenseKey=" + licensekey) backupURL = URI.encode("https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + ipaddress + "&LicenseKey=" + licensekey) #These are set to access the hash that is returned @ipavresult ="IP4" @ipaverror = "Error" #Begins the call the RESTful web service begin response = HTTParty.get(primaryURL, timeout: default_timeout) #processes the response to display to the screen #Passes the response returned from HTTParty and processes them depending on the results processresults(response) rescue StandardError => e begin #uses the backupURl in the event that the service encountered an error response = HTTParty.get(backupURL, timeout: default_timeout) #processes the response returned from using the backupURL processresults(response) #If the backup url railed this will raise an error and display the #error message returned from the HTTParty gem. rescue StandardError => error @status = error.message @displaydata = {"Error" => "A Big Error Occured"} end end
#Set Primary and Backup URLs as needed. This method encodes and standardizes the URI to pass to the REST service.
primaryURL = URI.encode("https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + ipaddress + "&LicenseKey=" + licensekey)
backupURL = URI.encode("https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + ipaddress + "&LicenseKey=" + licensekey)
#These are set to access the hash that is returned
@ipavresult ="IP4"
@ipaverror = "Error"
#Begins the call the RESTful web service
begin
response = HTTParty.get(primaryURL, timeout: default_timeout)
#processes the response to display to the screen
#Passes the response returned from HTTParty and processes them depending on the results
processresults(response)
 
rescue StandardError => e
        begin
        #uses the backupURl in the event that the service encountered an error
        response = HTTParty.get(backupURL, timeout: default_timeout)
   
  #processes the response returned from using the backupURL
        processresults(response)
  #If the backup url railed this will raise an error and display the
  #error message returned from the HTTParty gem.
        rescue StandardError => error
            @status = error.message
            @displaydata = {"Error" => "A Big Error Occured"}
        end
end

IP Address Validation Python Rest Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#The Requests package allows the user to format the path parameters like so instead of having to manually insert them into the URL
inputs = {'IPAddress': mIPAddress, 'LicenseKey': mLicenseKey}
try:
result = requests.get(primaryURL, params=inputs)
#Parses the XML response from the service into a python dictionary type
outputs = xmltodict.parse(result.content)
#checks the output for Errors and displays the info accordingly
if 'Error' in outputs['IP4']:
#loops through the response from the service and prints the values to the screen.
for key, value in outputs['IP4']['Error'].iteritems():
Label(swin.window, text=str(key) + " : " + str(value)).pack()
else:
#This code removes extra entries that were parsed in from the xml response
outputs['IP4'].pop("@xmlns:xsi", None)
outputs['IP4'].pop("@xmlns:xsd", None)
outputs['IP4'].pop("@xmlns", None)
for key, value in outputs['IP4'].iteritems():
Label(swin.window, text=str(key) + " : " + str(value)).pack()
except:
try:
result = requests.get(backupURL, params=inputs)
#Parses the XML response from the service into a python dictionary type
outputs = xmltodict.parse(result.content)
#checks the output for Errors and displays the info accordingly
if 'Error' in outputs['IP4']:
#loops through the response from the service and prints the values to the screen.
for key, value in outputs['IP4']['Error'].iteritems():
Label(swin.window, text=str(key) + " : " + str(value)).pack()
else:
#This code removes extra entries that were parsed in from the xml response
outputs['IP4'].pop("@xmlns:xsi", None)
outputs['IP4'].pop("@xmlns:xsd", None)
outputs['IP4'].pop("@xmlns", None)
for key, value in outputs['IP4'].iteritems():
Label(swin.window, text=str(key) + " : " + str(value)).pack()
primaryURL = 'https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?' backupURL = 'https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?' #The Requests package allows the user to format the path parameters like so instead of having to manually insert them into the URL inputs = {'IPAddress': mIPAddress, 'LicenseKey': mLicenseKey} try: result = requests.get(primaryURL, params=inputs) #Parses the XML response from the service into a python dictionary type outputs = xmltodict.parse(result.content) #checks the output for Errors and displays the info accordingly if 'Error' in outputs['IP4']: #loops through the response from the service and prints the values to the screen. for key, value in outputs['IP4']['Error'].iteritems(): Label(swin.window, text=str(key) + " : " + str(value)).pack() else: #This code removes extra entries that were parsed in from the xml response outputs['IP4'].pop("@xmlns:xsi", None) outputs['IP4'].pop("@xmlns:xsd", None) outputs['IP4'].pop("@xmlns", None) for key, value in outputs['IP4'].iteritems(): Label(swin.window, text=str(key) + " : " + str(value)).pack() except: try: result = requests.get(backupURL, params=inputs) #Parses the XML response from the service into a python dictionary type outputs = xmltodict.parse(result.content) #checks the output for Errors and displays the info accordingly if 'Error' in outputs['IP4']: #loops through the response from the service and prints the values to the screen. for key, value in outputs['IP4']['Error'].iteritems(): Label(swin.window, text=str(key) + " : " + str(value)).pack() else: #This code removes extra entries that were parsed in from the xml response outputs['IP4'].pop("@xmlns:xsi", None) outputs['IP4'].pop("@xmlns:xsd", None) outputs['IP4'].pop("@xmlns", None) for key, value in outputs['IP4'].iteritems(): Label(swin.window, text=str(key) + " : " + str(value)).pack()
primaryURL = 'https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?'
backupURL = 'https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?'
#The Requests package allows the user to format the path parameters like so instead of having to manually insert them into the URL
inputs = {'IPAddress': mIPAddress, 'LicenseKey': mLicenseKey}
try:
    result = requests.get(primaryURL, params=inputs)
    #Parses the XML response from the service into a python dictionary type
    outputs = xmltodict.parse(result.content)
    #checks the output for Errors and displays the info accordingly
    if 'Error' in outputs['IP4']:
        #loops through the response from the service and prints the values to the screen.
        for key, value in outputs['IP4']['Error'].iteritems():
            Label(swin.window, text=str(key) + " : " + str(value)).pack()
    else:
        #This code removes extra entries that were parsed in from the xml response
        outputs['IP4'].pop("@xmlns:xsi", None)
        outputs['IP4'].pop("@xmlns:xsd", None)
        outputs['IP4'].pop("@xmlns", None)
        for key, value in outputs['IP4'].iteritems():
            Label(swin.window, text=str(key) + " : " + str(value)).pack()
except:
    try:
        result = requests.get(backupURL, params=inputs)
        #Parses the XML response from the service into a python dictionary type
        outputs = xmltodict.parse(result.content)
        #checks the output for Errors and displays the info accordingly
        if 'Error' in outputs['IP4']:
            #loops through the response from the service and prints the values to the screen.
            for key, value in outputs['IP4']['Error'].iteritems():
                Label(swin.window, text=str(key) + " : " + str(value)).pack()
        else:
            #This code removes extra entries that were parsed in from the xml response
            outputs['IP4'].pop("@xmlns:xsi", None)
            outputs['IP4'].pop("@xmlns:xsd", None)
            outputs['IP4'].pop("@xmlns", None)
            for key, value in outputs['IP4'].iteritems():
                Label(swin.window, text=str(key) + " : " + str(value)).pack()

IP Address Validation ColdFusion Rest Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!--Makes Request to web service --->
<cfIf isDefined("form.Action") AND Action neq "" >
<cftry>
<cfhttp url="#primaryURL#" method="get" result="response">
<cfset outputs = XmlParse(response.FileContent)>
<cfcatch >
<cftry>
<cfhttp url="#backupURL#" method="get" result="response">
<cfset outputs = XmlParse(response.FileContent)>
<cfcatch >
<cfoutput >
The Following Error Occured: #response.StatusCode#
</cfoutput>
</cfcatch>
</cftry>
</cfcatch>
</cftry>
</cfif>
<!--Makes Request to web service ---> <cfIf isDefined("form.Action") AND Action neq "" > <cftry> <cfset primaryURL = "https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?IPAddress=#IPAddress#&LicenseKey=#LicenseKey#"> <cfhttp url="#primaryURL#" method="get" result="response"> <cfset outputs = XmlParse(response.FileContent)> <cfcatch > <cftry> <cfset backupURL = "https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?IPAddress=#IPAddress#&LicenseKey=#LicenseKey#"> <cfhttp url="#backupURL#" method="get" result="response"> <cfset outputs = XmlParse(response.FileContent)> <cfcatch > <cfoutput > The Following Error Occured: #response.StatusCode# </cfoutput> </cfcatch> </cftry> </cfcatch> </cftry> </cfif>
<!--Makes Request to web service --->
<cfIf isDefined("form.Action") AND Action neq ""  >
    <cftry>
        <cfset primaryURL = "https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?IPAddress=#IPAddress#&LicenseKey=#LicenseKey#">
        <cfhttp url="#primaryURL#" method="get" result="response">
        <cfset outputs = XmlParse(response.FileContent)>
    <cfcatch >
        <cftry>
            <cfset backupURL = "https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?IPAddress=#IPAddress#&LicenseKey=#LicenseKey#">
            <cfhttp url="#backupURL#" method="get" result="response">
            <cfset outputs = XmlParse(response.FileContent)>             
            <cfcatch >
                <cfoutput >
                    The Following Error Occured: #response.StatusCode#
                </cfoutput>
            </cfcatch>
        </cftry>
    </cfcatch>
    </cftry>
</cfif>

IP Address Validation VB Rest Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Try
'encodes the URLs for the get Call. Set the primary and back urls as necessary
Dim primaryurl As String = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + WebUtility.UrlEncode(ipaddress) + "&LicenseKey=" + WebUtility.UrlEncode(licensekey)
Dim backupurl As String = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + WebUtility.UrlEncode(ipaddress) + "&LicenseKey=" + WebUtility.UrlEncode(licensekey)
Dim wsresponse As IPResponse.IP4 = httpGet(primaryurl)
'checks if a response was returned from the service, uses the backup url if response is null or a fatal error occured.
If wsresponse Is Nothing OrElse (wsresponse.[Error] IsNot Nothing AndAlso wsresponse.[Error].Number = "3") Then
End If
If True Then
wsresponse = httpGet(backupurl)
End If
If wsresponse.[Error] IsNot Nothing Then
ProcessErrorResponse(wsresponse.[Error])
Else
ProcessSuccessfulResponse(wsresponse)
End If
Catch ex As Exception
'Displays the relevant error mesasge if both backup and primary urls failed.
StatusLabel.Text = ex.Message
StatusLabel.Visible = True
End Try
Try 'encodes the URLs for the get Call. Set the primary and back urls as necessary Dim primaryurl As String = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + WebUtility.UrlEncode(ipaddress) + "&LicenseKey=" + WebUtility.UrlEncode(licensekey) Dim backupurl As String = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + WebUtility.UrlEncode(ipaddress) + "&LicenseKey=" + WebUtility.UrlEncode(licensekey) Dim wsresponse As IPResponse.IP4 = httpGet(primaryurl) 'checks if a response was returned from the service, uses the backup url if response is null or a fatal error occured. If wsresponse Is Nothing OrElse (wsresponse.[Error] IsNot Nothing AndAlso wsresponse.[Error].Number = "3") Then End If If True Then wsresponse = httpGet(backupurl) End If If wsresponse.[Error] IsNot Nothing Then ProcessErrorResponse(wsresponse.[Error]) Else ProcessSuccessfulResponse(wsresponse) End If Catch ex As Exception 'Displays the relevant error mesasge if both backup and primary urls failed. StatusLabel.Text = ex.Message StatusLabel.Visible = True End Try
Try
    'encodes the URLs for the get Call. Set the primary and back urls as necessary
    Dim primaryurl As String = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + WebUtility.UrlEncode(ipaddress) + "&LicenseKey=" + WebUtility.UrlEncode(licensekey)
    Dim backupurl As String = "https://trial.serviceobjects.com/GPP/web.svc/json/GetLocationByIP_V4?IPAddress=" + WebUtility.UrlEncode(ipaddress) + "&LicenseKey=" + WebUtility.UrlEncode(licensekey)
    Dim wsresponse As IPResponse.IP4 = httpGet(primaryurl)
    'checks if a response was returned from the service, uses the backup url if response is null or a fatal error occured.
    If wsresponse Is Nothing OrElse (wsresponse.[Error] IsNot Nothing AndAlso wsresponse.[Error].Number = "3") Then
 
    End If
    If True Then
        wsresponse = httpGet(backupurl)
    End If
    If wsresponse.[Error] IsNot Nothing Then
        ProcessErrorResponse(wsresponse.[Error])
    Else
        ProcessSuccessfulResponse(wsresponse)
 
    End If
Catch ex As Exception
    'Displays the relevant error mesasge if both backup and primary urls failed.
    StatusLabel.Text = ex.Message
    StatusLabel.Visible = True
End Try

IP Address Validation TSQL Rest Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
BEGIN
SET @sUrl = 'https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?IPAddress=' + @ipaddress + '&LicenseKey=' + @key
EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
EXEC sp_OAMethod @obj, 'Open', NULL, 'Get', @sUrl, false
EXEC sp_OAMethod @obj, 'send'
EXEC sp_OAGetProperty @obj, 'responseText', @response OUT
--Checks the Response for a fatal error or if null.
IF @response IS NULL
BEGIN
SET @sBackupUrl = 'https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?IPAddress=' + @ipaddress + '&LicenseKey=' + @key
EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
EXEC sp_OAMethod @obj, 'Open', NULL, 'Get', @sBackupUrl, false
EXEC sp_OAMethod @obj, 'send'
EXEC sp_OAGetProperty @obj, 'responseText', @response OUT
END
END
BEGIN SET @sUrl = 'https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?IPAddress=' + @ipaddress + '&LicenseKey=' + @key EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT EXEC sp_OAMethod @obj, 'Open', NULL, 'Get', @sUrl, false EXEC sp_OAMethod @obj, 'send' EXEC sp_OAGetProperty @obj, 'responseText', @response OUT --Checks the Response for a fatal error or if null. IF @response IS NULL BEGIN SET @sBackupUrl = 'https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?IPAddress=' + @ipaddress + '&LicenseKey=' + @key EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT EXEC sp_OAMethod @obj, 'Open', NULL, 'Get', @sBackupUrl, false EXEC sp_OAMethod @obj, 'send' EXEC sp_OAGetProperty @obj, 'responseText', @response OUT END END
BEGIN
    SET @sUrl = 'https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?IPAddress=' + @ipaddress + '&LicenseKey=' + @key
    EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
    EXEC sp_OAMethod @obj, 'Open', NULL, 'Get', @sUrl, false
    EXEC sp_OAMethod @obj, 'send'
    EXEC sp_OAGetProperty @obj, 'responseText', @response OUT
             
    --Checks the Response for a fatal error or if null.
    IF @response IS NULL
    BEGIN
        SET @sBackupUrl = 'https://trial.serviceobjects.com/GPP/web.svc/xml/GetLocationByIP_V4?IPAddress=' + @ipaddress + '&LicenseKey=' + @key
        EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT
        EXEC sp_OAMethod @obj, 'Open', NULL, 'Get', @sBackupUrl, false
        EXEC sp_OAMethod @obj, 'send'
        EXEC sp_OAGetProperty @obj, 'responseText', @response OUT
    END
END