Telephone Verification C# Code Snippet

//Add a service to your application https://trial.serviceobjects.com/tv
/TelephoneVerification.asmx
TVClient_Primary = new DOTSTelephoneVerification();
response = TVClient_Primary.PlaceCall(CountryCodeUSACanada, PhoneNumber, 
Extension, ExtensionPauseTime, "", CallerID, Language, LicenseKey);
 
if (response.Error != null)
{
 //Process Error
}
else
{
 //Process Response 
}

Telephone Verification Java Code Snippet

// Declare Result Object 
TelephoneInfo phoneInfo = null;
 
// Create client through proxy class
DOTSTelephoneVerificationLocator locator = new 
DOTSTelephoneVerificationLocator();
 
// Handle request to client
DOTSTelephoneVerificationSoap soapRequest = locator.
getDOTSTelephoneVerificationSoap();
 
// Handle any errors in response
Error error;
phoneInfo = soapRequest.placeCall(countryCode,phoneNumber,extension,
exensionPauseTime,verificationCode,callerId,language,licenseKey);
error = phoneInfo.getError();
if(phoneInfo == null || (error != null && error.getTypeCode() == "3"))
{
 throw new Exception();
}
//Process Results
if(error == null){
 //DOTS Telephone Verification Results 
}
//Process Errors
else{
 //DOTS Telephone Verification Error Results 
}

Telephone Verification PHP Code Snippets

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

Telephone Verification RoR SOAP Code Snippets

#Formats inputs into a hash to pass to Soap Client
 #Hash Keys must be named as they are shown here.
 message = {
 "CountryCode" => @request.
countrycode,
 "PhoneNumber" => @request.
phonenumber,
 "Message" => @request.message,
 "LicenseKey" => @request.
licensekey,
 }
 #Implemented to make the code more readable when accessing 
the response hash from the soap client 
 @tvresponse = :send_sms_response
 @tvresult = :send_sms_result
 @tverror = :error
 #Set Primary and Backup URLs here as needed
 dotsTVPrimary = "https://trial.serviceobjects.com/tv
/TelephoneVerification.asmx?WSDL"
 dotsAV3Backup = "https://trial.serviceobjects.com/tv
/TelephoneVerification.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: dotsTVPrimary )
 #Calls the operation with given inptus and 
converts response to a hash.
 response = client.call(:send_sms, 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: dotsTVBackup )
 #Sets the response to the backclient call to the 
operation and converts response to a hash.
 response = backupclient.call(:send_sms, 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

Telephone Verification Python Code Snippet

mCountryCode = CountryCode.get()
 if mCountryCode is None or mCountryCode == "":
 mCountryCode = " "
 mPhoneNumber = PhoneNumber.get()
 if mPhoneNumber is None or mPhoneNumber == "":
 mPhoneNumber = " "
 mMessage = Message.get()
 if mMessage is None or mMessage == "":
 mMessage = " "
 mLicenseKey = LicenseKey.get()
 if mLicenseKey is None or mLicenseKey == "":
 mLicenseKey = " "
 #Set the primary and backup URLs as needed
 primaryURL = 'https://trial.serviceobjects.com/tv/TelephoneVerification.
asmx?WSDL'
 backupURL = 'https://trial.serviceobjects.com/tv/TelephoneVerification.
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.SendSMS(CountryCode=mCountryCode, 
PhoneNumber= mPhoneNumber, Message=mMessage, 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.SendSMS(CountryCode=mCountryCode, 
PhoneNumber= mPhoneNumber, Message=mMessage, 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)

Telephone Verification ColdFusion Code Snippet

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

Telephone Verification VB Code Snippet

Try
 Dim ws As New TV.DOTSTelephoneVerificationSoapClient
 Dim response As TV.TelephoneInfo
 response = ws.SendSMS(CountryCode.Text, PhoneNumber.Text, Message.
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 TV.DOTSTelephoneVerificationSoapClient
 Dim response As TV.TelephoneInfo
 response = wsbackup.SendSMS(CountryCode.Text, PhoneNumber.Text, 
Message.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

Telephone Verification Apex Code Snippet

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

Telephone Verification 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"
>' +
 '<SendSMS xmlns="https://www.
serviceobjects.com/">' +
 '<CountryCode>' + @countrycode + 
'</CountryCode>' +
 '<PhoneNumber>' + @phonenumber + 
'</PhoneNumber>' +
 '<Message>' + @message + '<
/Message>' +
 '<LicenseKey>' + @key + '<
/LicenseKey>' +
 '</SendSMS>' +
 '</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/tv/TelephoneVerification.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/SendSMS"'
 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/tv/TelephoneVerification.asmx', false
 EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'HOST', 
'swsbackup.serviceobjects.com'
 EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'ContentType', 'text/xml; charset=UTF-8'
 EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 
'SOAPAction', '"https://www.serviceobjects.com/SendSMS"'
 EXEC sp_OAMethod @obj, 'setRequestHeader', NULL, 'ContentLength', @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