GeoPhone C# Code Snippet

//Add a service to your application https://trial.serviceobjects.com/gp/GeoPhone.asmx
GPClient_Primary = new GPLibraryClient("DOTSGP");
response = GPClient_Primary.tns:GetPhoneInfo_V2(PhoneNumber, licenseKey);
         
if (response.Error != null)
{
    //Process Error
}
else
{
    //Process Response     
}

GeoPhone Java Code Snippet

PhoneInfo_V2Response resp = null;
PhoneInfo result = null;
Error error = null;
// Create soap request
GPLibraryLocator locator = new GPLibraryLocator();
// use ssl
locator.setDOTSGeophoneEndpointAddress("https://trial.serviceobjects.com/gp/GeoPhone.asmx");
IGPLibrary gp = locator.getDOTSGeophone();
DOTSGeophoneStub soap = (DOTSGeophoneStub)gp;
soap.setTimeout(5000);// set timeout
resp = soap.getPhoneInfo_V2(phoneNumber, key);
result = resp.getPhoneInfo();
error = resp.getError();
if(resp == null || (error != null && error.getTypeCode() == "3"))
{
    throw new Exception();
}
  
//Process Results
if(error == null){
    //DOTS GeoPhone Results
}
//Process Errors
else{
    //DOTS GeoPhone Error Results  
}

GeoPhone PHP Code Snippet

<?php
// Set these values per web service <as needed>
$wsdlUrl = "https://trial.serviceobjects.com/gp/GeoPhone.asmx?WSDL";
 
$params['PhoneNumber'] = $phoneNumber;
$params['LicenseKey'] = $LicenseKey;
 
$soapClient = new SoapClient($wsdlUrl, array( "trace" => 1 ));
$result = $soapClient->GetPhoneInfo_V2($params);
if (!isset($result->PhoneInfo_V2Result ->Error)) {
    foreach($result->PhoneInfo_V2Result ->PhoneInfo as $k=>$v) {
        echo $k . ", " . $v;
    }
} else {
    foreach($result->PhoneInfo_V2Result ->Error as $k=>$v) {
        echo $k . ", " . $v;
    }
}
?>

GeoPhone RoR Code Snippet

#Formats inputs into a hash to pass to Soap Client
        #Hash Keys must be named as they are shown here.
        message =   {
                    "PhoneNumber" => @request.phonenumber,
                    "LicenseKey" => @request.licensekey
                    }
         
        #Implemented to make the code more readable when accessing the hash        
        @gpresponse = :get_phone_info_v2_response
        @gpresult = :get_phone_info_v2_result
        @gpproviders = :providers
        @gpprovider = :provider
        @gpcontacts = :contacts
        @gpcontact = :contact
        @gperror = :error
 
        #Set Primary and Backup URLs here as needed
        dotsGPPrimary = "https://trial.serviceobjects.com/gp/GeoPhone.asmx?WSDL"
        dotsGPBackup = "https://trial.serviceobjects.com/gp/GeoPhone.asmx?WSDL"
 
        begin
            #initializes the soap client. The convert request keys global is necessary to receive a response from the service.
            client = Savon.client(wsdl: dotsGPPrimary)
            #Calls the given operation with given inptus and converts response to a hash.
            response = client.call(:get_phone_info_v2, 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 Savon::Error =>e
            begin
            backupclient = Savon.client(wsdl: dotsGPBackup)
            #Sets the response to the backupclient call to the operation and converts response to a hash.
            response = backupclient.call(:get_phone_info_v2, 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
    def processresults(response)   
            #Processes Error Response from soap Client     
            #Processes Valid response from soap client 
    end
end

GeoPhone Python Code Snippet

mPhoneNumber = PhoneNumber.get()
  if mPhoneNumber is None or mPhoneNumber == "":
      mPhoneNumber = " "
  mLicenseKey = LicenseKey.get()
  if mLicenseKey is None or mLicenseKey == "":
      mLicenseKey = " "
  #Set the primary and backup URLs as needed
  primaryURL = 'https://trial.serviceobjects.com/gp/GeoPhone.asmx?WSDL'
  backupURL = 'https://trial.serviceobjects.com/gp/GeoPhone.asmx?WSDL'
   #This block of code calls the web service and prints the resulting values to the screen
  try:
      client = Client(primaryURL)
      result = client.service.GetExchangeInfo(PhoneNumber=mPhoneNumber, 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.GetExchangeInfo(PhoneNumber=mPhoneNumber, 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)

GeoPhone ColdFusion Code Snippet

<!--Makes Request to web service --->
<cfscript>
        try
        {
            if (isDefined("form.Action") AND Action neq "")
            {
                wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/gp/GeoPhone.asmx?WSDL");                           
                outputs = wsresponse.getPhoneInfo_V2("#PhoneNumber#", "#LicenseKey#");             
            }
        }
    catch(any Exception){
        try
            {
                if (isDefined("form.Action") AND Action neq "")
                {
                    wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/gp/GeoPhone.asmx?WSDL");                           
                    outputs = wsresponse.getPhoneInfo_V2("#PhoneNumber#", "#LicenseKey#");
                }
            }
            catch(any Exception)   
                {
                 writeoutput("An Error Has Occured. Please Reload and try again");              
                }
        }
         
 </cfscript>

GeoPhone VB Code Snippet

Try
    Dim ws As New GP.DOTSGeoPhoneSoapClient
    Dim response As GP.PhoneInfo_V2
    response = ws.GetPhoneInfo_V2(PhoneNumber.Text, LicenseKey.Text)
    If (response.Error Is Nothing) Then
        ProcessValidResponse(response)
    Else
        ProcessErrorResponse(response.Error)
    End If
 
Catch er As Exception
    Try
        ''Set the primary and backup service references as necessary
        Dim wsbackup As New GP.DOTSGeoPhoneSoapClient
        Dim response As GP.PhoneInfo_V2
        response = wsbackup.GetPhoneInfo_V2(PhoneNumber.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

GeoPhone Apex Code Snippet

wwwServiceobjectsCom.PhoneInfo result;
try{
wwwServiceobjectsCom.DOTSGeoPhoneSoap client = new wwwServiceobjectsCom.DOTSGeoPhoneSoap();
result = client.GetContactInfo([PhoneNumber], [LicenseKey]);
}
catch(Exception ex){
 //If the first request failed try the failover endpoint
wwwServiceobjectsCom.DOTSGeoPhoneSoap backupClient = new wwwServiceobjectsCom.DOTSGeoPhoneSoap();
//The backup environment will be provided to you upon purchasing a production license key
backupClient.endpoint_x = 'https://trial.serviceobjects.com/GP/api.svc/soap';
result = backupClient.GetContactInfo([PhoneNumber], [LicenseKey]);
}

GeoPhone TSQL Code Snippet

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">'+
                   '<GetPhoneInfo_V2 xmlns="https://www.serviceobjects.com/">'+
                   '<PhoneNumber>' + @phonenumber + '</PhoneNumber>'+
                   '<LicenseKey>' + @key + '</LicenseKey>'+
                   '</GetPhoneInfo_V2>'+
                   '</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/gp/GeoPhone.asmx', 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/GetPhoneInfo_V2"'
    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/gp/GeoPhone.asmx', 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/GetPhoneInfo_V2"'
        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