Email Validation 3 Java Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<%
try{
String licensekey = request.getParameter("licensekey");
URL url = null;
licensekey = URLEncoder.encode(licensekey,"UTF-8").replaceAll("+", "%20");
Gson gson = new Gson();
HttpsURLConnection conn = null;
url = new URL(mainurl);
System.out.println(url);
conn = (HttpsURLConnection) url.openConnection();
conn.setConnectTimeout(5000);
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));
StringBuilder sb = new StringBuilder();
String output;
//System.out.println("info from the server n");
while ((output = br.readLine()) != null) {
sb.append(output);
//System.out.println(output);
}
JSONObject results = XML.toJSONObject(sb.toString());
JSONObject outputs = results.getJSONObject("JobSummaryReportResponse");
%>
<% try{ String licensekey = request.getParameter("licensekey"); URL url = null; licensekey = URLEncoder.encode(licensekey,"UTF-8").replaceAll("+", "%20"); String mainurl = "https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=" + licensekey; String backupurl = "https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=" + licensekey; Gson gson = new Gson(); HttpsURLConnection conn = null; url = new URL(mainurl); System.out.println(url); conn = (HttpsURLConnection) url.openConnection(); conn.setConnectTimeout(5000); conn.setRequestMethod("GET"); conn.setRequestProperty("Accept", "application/json"); if (conn.getResponseCode() != 200) { throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode()); } BufferedReader br = new BufferedReader(new InputStreamReader( (conn.getInputStream()))); StringBuilder sb = new StringBuilder(); String output; //System.out.println("info from the server n"); while ((output = br.readLine()) != null) { sb.append(output); //System.out.println(output); } JSONObject results = XML.toJSONObject(sb.toString()); JSONObject outputs = results.getJSONObject("JobSummaryReportResponse"); %>
<% 
          
try{
    String licensekey = request.getParameter("licensekey");
    URL url = null;
    licensekey = URLEncoder.encode(licensekey,"UTF-8").replaceAll("+", "%20");
      
    String mainurl = "https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=" + licensekey;
    String backupurl = "https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=" + licensekey;
  
      
    Gson gson = new Gson();
    HttpsURLConnection conn = null;
    url = new URL(mainurl);
      
      
    System.out.println(url);
    conn = (HttpsURLConnection) url.openConnection();
    conn.setConnectTimeout(5000);
    conn.setRequestMethod("GET");
    conn.setRequestProperty("Accept", "application/json");
  
    if (conn.getResponseCode() != 200) {
        throw new RuntimeException("Failed : HTTP error code : "
                + conn.getResponseCode());
    }
  
    BufferedReader br = new BufferedReader(new InputStreamReader(
        (conn.getInputStream())));
    StringBuilder sb = new StringBuilder();
    String output;
    //System.out.println("info from the server n");
    while ((output = br.readLine()) != null) {
        sb.append(output);
        //System.out.println(output);
    }
      
        JSONObject results = XML.toJSONObject(sb.toString());
        JSONObject outputs = results.getJSONObject("JobSummaryReportResponse");
          
%>

Email Validation 3 RoR 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.
#These are set to access the hash that is returned
@ncoaresponse ="JobSummaryReportResponse"
@ncoajobs = "Jobs"
@ncoainfo = "JobInfo"
@ncoaerror = "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 = response
@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/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=" + licensekey) backupURL = URI.encode("https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=" + licensekey) #These are set to access the hash that is returned @ncoaresponse ="JobSummaryReportResponse" @ncoajobs = "Jobs" @ncoainfo = "JobInfo" @ncoaerror = "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 = response @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/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=" + licensekey)
backupURL = URI.encode("https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=" + licensekey)
  
#These are set to access the hash that is returned
@ncoaresponse ="JobSummaryReportResponse"
@ncoajobs = "Jobs"
@ncoainfo = "JobInfo"
@ncoaerror = "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 = response
            @displaydata = {"Error" => "A Big Error Occured"}
        end
  
end

Email Validation 3 Python 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 = {'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['JobSummaryReportResponse']:
#loops through the response from the service and prints the values to the screen.
for key, value in outputs['JobSummaryReportResponse']['Error'].iteritems():
Label(swin.window, text=str(key) + " : " + str(value)).pack()
else:
#Prints a title with the JobSummaryReport number and the resulting details for the job number
for i in range(0, len(outputs['JobSummaryReportResponse']['Jobs']['JobInfo'])):
Label(swin.window, font='bold', text="Job Summary #"+str(i+1)).pack()
for key, value in outputs['JobSummaryReportResponse']['Jobs']['JobInfo'][i].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['JobSummaryReportResponse']:
#loops through the response from the service and prints the values to the screen.
for key, value in outputs['JobSummaryReportResponse']['Error'].iteritems():
Label(swin.window, text=str(key) + " : " + str(value)).pack()
else:
#Prints a title with the JobSummaryReport number and the resulting details for the job number
for i in range(0, len(outputs['JobSummaryReportResponse']['Jobs']['JobInfo'])):
Label(swin.window, font='bold', text="Job Summary #"+str(i+1)).pack()
for key, value in outputs['JobSummaryReportResponse']['Jobs']['JobInfo'][i].iteritems():
Label(swin.window, text=str(key) + " : " + str(value)).pack()
#The Requests package allows the user to format the path parameters like so instead of having to manually insert them into the URL primaryURL = 'https://trial.serviceobjects.com/nl/noalive.asmx/GetJobSummaryReport?' backupURL = 'https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?' inputs = {'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['JobSummaryReportResponse']: #loops through the response from the service and prints the values to the screen. for key, value in outputs['JobSummaryReportResponse']['Error'].iteritems(): Label(swin.window, text=str(key) + " : " + str(value)).pack() else: #Prints a title with the JobSummaryReport number and the resulting details for the job number for i in range(0, len(outputs['JobSummaryReportResponse']['Jobs']['JobInfo'])): Label(swin.window, font='bold', text="Job Summary #"+str(i+1)).pack() for key, value in outputs['JobSummaryReportResponse']['Jobs']['JobInfo'][i].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['JobSummaryReportResponse']: #loops through the response from the service and prints the values to the screen. for key, value in outputs['JobSummaryReportResponse']['Error'].iteritems(): Label(swin.window, text=str(key) + " : " + str(value)).pack() else: #Prints a title with the JobSummaryReport number and the resulting details for the job number for i in range(0, len(outputs['JobSummaryReportResponse']['Jobs']['JobInfo'])): Label(swin.window, font='bold', text="Job Summary #"+str(i+1)).pack() for key, value in outputs['JobSummaryReportResponse']['Jobs']['JobInfo'][i].iteritems(): Label(swin.window, text=str(key) + " : " + str(value)).pack()
#The
 Requests package allows the user to format the path parameters like so
instead of having to manually insert them into the URL
primaryURL = 'https://trial.serviceobjects.com/nl/noalive.asmx/GetJobSummaryReport?'
backupURL = 'https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?'
inputs = {'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['JobSummaryReportResponse']:
        #loops through the response from the service and prints the values to the screen.
        for key, value in outputs['JobSummaryReportResponse']['Error'].iteritems():
            Label(swin.window, text=str(key) + " : " + str(value)).pack()
    else:
        #Prints a title with the JobSummaryReport number and the resulting details for the job number
        for i in range(0, len(outputs['JobSummaryReportResponse']['Jobs']['JobInfo'])):
            Label(swin.window, font='bold', text="Job Summary #"+str(i+1)).pack()
            for key, value in outputs['JobSummaryReportResponse']['Jobs']['JobInfo'][i].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['JobSummaryReportResponse']:
            #loops through the response from the service and prints the values to the screen.
            for key, value in outputs['JobSummaryReportResponse']['Error'].iteritems():
                Label(swin.window, text=str(key) + " : " + str(value)).pack()
        else:
            #Prints a title with the JobSummaryReport number and the resulting details for the job number
            for i in range(0, len(outputs['JobSummaryReportResponse']['Jobs']['JobInfo'])):
                Label(swin.window, font='bold', text="Job Summary #"+str(i+1)).pack()
                for key, value in outputs['JobSummaryReportResponse']['Jobs']['JobInfo'][i].iteritems():
                    Label(swin.window, text=str(key) + " : " + str(value)).pack()

Email Validation 3 ColdFusion 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(outputs.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/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=#LicenseKey#"> <cfhttp url="#primaryURL#" method="get" result="response"> <cfset outputs = XmlParse(response.FileContent)> <cfcatch > <cftry> <cfset backupURL = "https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=#LicenseKey#"> <cfhttp url="#backupURL#" method="get" result="response"> <cfset outputs = XmlParse(outputs.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/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=#LicenseKey#">
        <cfhttp url="#primaryURL#" method="get" result="response">
        <cfset outputs = XmlParse(response.FileContent)>
    <cfcatch >
        <cftry>
            <cfset backupURL = "https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=#LicenseKey#">
            <cfhttp url="#backupURL#" method="get" result="response">
            <cfset outputs = XmlParse(outputs.FileContent)>              
            <cfcatch >
                <cfoutput >
                    The Following Error Occured: #response.StatusCode#
                </cfoutput>
            </cfcatch>
        </cftry>
    </cfcatch>
    </cftry>
</cfif>

Email Validation 3 VB 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
Dim wsresponse As NCOAResponse.JobSummaryReportResponse = 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].TypeCode = "3") Then
wsresponse = httpGet(backupurl)
End If
If wsresponse.[Error] IsNot Nothing Then
ProcessErrorResponse(wsresponse.[Error])
Else
ProcessSuccessfulResponse(wsresponse)
End If
'encodes the URLs for the get Call. Set the primary and back urls as necessary Dim primaryurl As String = "https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=" & licensekey Dim backupurl As String = "https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=" & licensekey Dim wsresponse As NCOAResponse.JobSummaryReportResponse = 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].TypeCode = "3") Then wsresponse = httpGet(backupurl) End If If wsresponse.[Error] IsNot Nothing Then ProcessErrorResponse(wsresponse.[Error]) Else ProcessSuccessfulResponse(wsresponse) End If
'encodes the URLs for the get Call. Set the primary and back urls as necessary
Dim primaryurl As String = "https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=" & licensekey
Dim backupurl As String = "https://trial.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?LicenseKey=" & licensekey
Dim wsresponse As NCOAResponse.JobSummaryReportResponse = 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].TypeCode = "3") Then
    wsresponse = httpGet(backupurl)
End If
If wsresponse.[Error] IsNot Nothing Then
    ProcessErrorResponse(wsresponse.[Error])
Else
    ProcessSuccessfulResponse(wsresponse)
  
End If

Email Validation 3 TSQL Code Snippet

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
BEGIN
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
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://sws.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?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://swsbackup.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?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://sws.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?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://swsbackup.serviceobjects.com/nl/ncoalive.asmx/GetJobSummaryReport?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