- C#
- Java
- PHP
- RoR
- Python
- ColdFusion
- VB
- Apex
- TSQL
Phone Exchange C# Code Snippet
//Add a service to your application https://trial.serviceobjects.com/pe2/soap.svc
PE2Client = new PhoneExchange2Client("DOTSPE2Primary");
response = PE2Client.GetExchangeInfo(number, licenseKey);
if (response.Error != null)
{
//Process Error
}
else
{
//Process Response
}
//Add a service to your application https://trial.serviceobjects.com/pe2/soap.svc
PE2Client = new PhoneExchange2Client("DOTSPE2Primary");
response = PE2Client.GetExchangeInfo(number, licenseKey);
if (response.Error != null)
{
//Process Error
}
else
{
//Process Response
}
//Add a service to your application https://trial.serviceobjects.com/pe2/soap.svc PE2Client = new PhoneExchange2Client("DOTSPE2Primary"); response = PE2Client.GetExchangeInfo(number, licenseKey); if (response.Error != null) { //Process Error } else { //Process Response }
Phone Exchange Java Code Snippet
ExchangeInfoResponse resp = null;
ExchangeInfo result = null;
PE2Error error = null;
// Create soap request
PhoneExchange2Locator locator = new PhoneExchange2Locator();
// use ssl
IPhoneExchange2 PE2 = locator.getsoap();
SoapStub soap = (SoapStub) pe;
soap.setTimeout(5000);// set timeout
resp = soap.getExchangeInfo(phoneNumbers, key);
result = resp.getPhoneExchangeInfo();
error = resp.getError();
if(resp == null || (error != null && error.getTypeCode() == "3"))
{
throw new Exception();
}
//Process Results
if(error == null){
//DOTS Phone Exchange Results
}
//Process Errors
else{
//DOTS Phone Exchange 2 Error Results
}
ExchangeInfoResponse resp = null;
ExchangeInfo result = null;
PE2Error error = null;
// Create soap request
PhoneExchange2Locator locator = new PhoneExchange2Locator();
// use ssl
locator.setsoapEndpointAddress("https://trial.serviceobjects.com/PE2/soap.svc/soap");
IPhoneExchange2 PE2 = locator.getsoap();
SoapStub soap = (SoapStub) pe;
soap.setTimeout(5000);// set timeout
resp = soap.getExchangeInfo(phoneNumbers, key);
result = resp.getPhoneExchangeInfo();
error = resp.getError();
if(resp == null || (error != null && error.getTypeCode() == "3"))
{
throw new Exception();
}
//Process Results
if(error == null){
//DOTS Phone Exchange Results
}
//Process Errors
else{
//DOTS Phone Exchange 2 Error Results
}
ExchangeInfoResponse resp = null; ExchangeInfo result = null; PE2Error error = null; // Create soap request PhoneExchange2Locator locator = new PhoneExchange2Locator(); // use ssl locator.setsoapEndpointAddress("https://trial.serviceobjects.com/PE2/soap.svc/soap"); IPhoneExchange2 PE2 = locator.getsoap(); SoapStub soap = (SoapStub) pe; soap.setTimeout(5000);// set timeout resp = soap.getExchangeInfo(phoneNumbers, key); result = resp.getPhoneExchangeInfo(); error = resp.getError(); if(resp == null || (error != null && error.getTypeCode() == "3")) { throw new Exception(); } //Process Results if(error == null){ //DOTS Phone Exchange Results } //Process Errors else{ //DOTS Phone Exchange 2 Error Results }
Phone Exchange PHP Code Snippet
// Set these values per web service <as needed>
$params['phoneNumber'] = $PhoneNumber;
$params['LicenseKey'] = $LicenseKey;
$soapClient = new SoapClient($wsdlUrl, array( "trace" => 1 ));
$result = $soapClient->GetExchangeInfo($params);
if (!isset($result->GetExchangeInfoResult->Error))
{
foreach($result->GetExchangeInfoResult->ExchangeInfoResults->ExchangeInfo as $k=>$v)
{
if(is_a($v, "stdClass"))
{
foreach($v as $k2=>$v2)
{
echo "$k2,$v2";
}
continue;
}
echo "$k,$v";
}
} else {
foreach($result->GetExchangeInfoResult->Error as $k=>$v) {
echo "$k,$v";
}
}
// Set these values per web service <as needed>
$wsdlUrl = "https://trial.serviceobjects.com/pe2/soap.svc?wsdl";
$params['phoneNumber'] = $PhoneNumber;
$params['LicenseKey'] = $LicenseKey;
$soapClient = new SoapClient($wsdlUrl, array( "trace" => 1 ));
$result = $soapClient->GetExchangeInfo($params);
if (!isset($result->GetExchangeInfoResult->Error))
{
foreach($result->GetExchangeInfoResult->ExchangeInfoResults->ExchangeInfo as $k=>$v)
{
if(is_a($v, "stdClass"))
{
foreach($v as $k2=>$v2)
{
echo "$k2,$v2";
}
continue;
}
echo "$k,$v";
}
} else {
foreach($result->GetExchangeInfoResult->Error as $k=>$v) {
echo "$k,$v";
}
}
// Set these values per web service <as needed> $wsdlUrl = "https://trial.serviceobjects.com/pe2/soap.svc?wsdl"; $params['phoneNumber'] = $PhoneNumber; $params['LicenseKey'] = $LicenseKey; $soapClient = new SoapClient($wsdlUrl, array( "trace" => 1 )); $result = $soapClient->GetExchangeInfo($params); if (!isset($result->GetExchangeInfoResult->Error)) { foreach($result->GetExchangeInfoResult->ExchangeInfoResults->ExchangeInfo as $k=>$v) { if(is_a($v, "stdClass")) { foreach($v as $k2=>$v2) { echo "$k2,$v2"; } continue; } echo "$k,$v"; } } else { foreach($result->GetExchangeInfoResult->Error as $k=>$v) { echo "$k,$v"; } }
Phone Exchange 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
@pe2response = :get_exchange_info_response
@pe2result = :get_exchange_info_result
@pe2results = :exchange_info_results
@pe2info = :exchange_info
@pe2portedinfo = :ported_info
@pe2error = :error
#Set Primary and Backup URLs here as needed
dotsPE2Primary = "https://trial.serviceobjects.com/pe2/soap.svc?wsdl"
dotsPE2Backup = "https://trial.serviceobjects.com/pe2/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: dotsPE2Primary )
#Calls the operation with given inptus and converts response to a hash.
response = client.call(:get_exchange_info, 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: dotsPE2Backup )
#Sets the response to the backclient call to the operation and converts response to a hash.
response = backupclient.call(:get_exchange_info, 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
#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
@pe2response = :get_exchange_info_response
@pe2result = :get_exchange_info_result
@pe2results = :exchange_info_results
@pe2info = :exchange_info
@pe2portedinfo = :ported_info
@pe2error = :error
#Set Primary and Backup URLs here as needed
dotsPE2Primary = "https://trial.serviceobjects.com/pe2/soap.svc?wsdl"
dotsPE2Backup = "https://trial.serviceobjects.com/pe2/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: dotsPE2Primary )
#Calls the operation with given inptus and converts response to a hash.
response = client.call(:get_exchange_info, 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: dotsPE2Backup )
#Sets the response to the backclient call to the operation and converts response to a hash.
response = backupclient.call(:get_exchange_info, 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
#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 @pe2response = :get_exchange_info_response @pe2result = :get_exchange_info_result @pe2results = :exchange_info_results @pe2info = :exchange_info @pe2portedinfo = :ported_info @pe2error = :error #Set Primary and Backup URLs here as needed dotsPE2Primary = "https://trial.serviceobjects.com/pe2/soap.svc?wsdl" dotsPE2Backup = "https://trial.serviceobjects.com/pe2/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: dotsPE2Primary ) #Calls the operation with given inptus and converts response to a hash. response = client.call(:get_exchange_info, 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: dotsPE2Backup ) #Sets the response to the backclient call to the operation and converts response to a hash. response = backupclient.call(:get_exchange_info, 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
Phone Exchange 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/pe2/soap.svc?wsdl'
backupURL = 'https://trial.serviceobjects.com/pe2/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.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)
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/pe2/soap.svc?wsdl'
backupURL = 'https://trial.serviceobjects.com/pe2/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.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)
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/pe2/soap.svc?wsdl' backupURL = 'https://trial.serviceobjects.com/pe2/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.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)
Phone Exchange 2 ColdFusion Code Snippet
<!--Makes Request to web service --->
<cfscript>
try
{
if (isDefined("form.Action") AND Action neq "")
{
wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/pe2/soap.svc?wsdl");
outputs = wsresponse.getExchangeInfo("#PhoneNumber#", "#LicenseKey#");
}
}
catch(any Exception){
try
{
if (isDefined("form.Action") AND Action neq "")
{
wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/pe2/soap.svc?wsdl");
outputs = wsresponse.getExchangeInfo("#PhoneNumber#", "#LicenseKey#");
}
}
catch(any Exception) {
writeoutput("An Error Has Occured. Please Reload and try again");
}
}
</cfscript>
<!--Makes Request to web service --->
<cfscript>
try
{
if (isDefined("form.Action") AND Action neq "")
{
wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/pe2/soap.svc?wsdl");
outputs = wsresponse.getExchangeInfo("#PhoneNumber#", "#LicenseKey#");
}
}
catch(any Exception){
try
{
if (isDefined("form.Action") AND Action neq "")
{
wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/pe2/soap.svc?wsdl");
outputs = wsresponse.getExchangeInfo("#PhoneNumber#", "#LicenseKey#");
}
}
catch(any Exception) {
writeoutput("An Error Has Occured. Please Reload and try again");
}
}
</cfscript>
<!--Makes Request to web service ---> <cfscript> try { if (isDefined("form.Action") AND Action neq "") { wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/pe2/soap.svc?wsdl"); outputs = wsresponse.getExchangeInfo("#PhoneNumber#", "#LicenseKey#"); } } catch(any Exception){ try { if (isDefined("form.Action") AND Action neq "") { wsresponse = CreateObject("webservice", "https://trial.serviceobjects.com/pe2/soap.svc?wsdl"); outputs = wsresponse.getExchangeInfo("#PhoneNumber#", "#LicenseKey#"); } } catch(any Exception) { writeoutput("An Error Has Occured. Please Reload and try again"); } } </cfscript>
Phone Exchange 2 VB Code Snippet
Try
Dim ws As New PE2.PhoneExchange2Client
Dim response As PE2.ExchangeInfoResponse
response = ws.GetExchangeInfo(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 PE2.PhoneExchange2Client
Dim response As PE2.ExchangeInfoResponse
response = wsbackup.GetExchangeInfo(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
Try
Dim ws As New PE2.PhoneExchange2Client
Dim response As PE2.ExchangeInfoResponse
response = ws.GetExchangeInfo(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 PE2.PhoneExchange2Client
Dim response As PE2.ExchangeInfoResponse
response = wsbackup.GetExchangeInfo(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
Try Dim ws As New PE2.PhoneExchange2Client Dim response As PE2.ExchangeInfoResponse response = ws.GetExchangeInfo(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 PE2.PhoneExchange2Client Dim response As PE2.ExchangeInfoResponse response = wsbackup.GetExchangeInfo(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
Phone Exchange 2 Apex Code Snippet
wwwServiceobjectsCom.ExchangeInfoResponse result;
try{
wwwServiceobjectsCom.ServiceObjects_IPhoneExchange client = new wwwServiceobjectsCom.ServiceObjects_IPhoneExchange();
result = client.GetExchangeInfo([PhoneNumber], [LicenseKey]);
}
catch(Exception ex){
//If the first request failed try the failover endpoint
wwwServiceobjectsCom.ServiceObjects_IPhoneExchange backupClient = new wwwServiceobjectsCom.ServiceObjects_IPhoneExchange();
//The backup environment will be provided to you upon purchasing a production license key
backupClient.endpoint_x = 'https://trial.serviceobjects.com/PE2/soap.svc/soap';
result = backupClient.GetExchangeInfo([PhoneNumber], [LicenseKey]);
}
wwwServiceobjectsCom.ExchangeInfoResponse result;
try{
wwwServiceobjectsCom.ServiceObjects_IPhoneExchange client = new wwwServiceobjectsCom.ServiceObjects_IPhoneExchange();
result = client.GetExchangeInfo([PhoneNumber], [LicenseKey]);
}
catch(Exception ex){
//If the first request failed try the failover endpoint
wwwServiceobjectsCom.ServiceObjects_IPhoneExchange backupClient = new wwwServiceobjectsCom.ServiceObjects_IPhoneExchange();
//The backup environment will be provided to you upon purchasing a production license key
backupClient.endpoint_x = 'https://trial.serviceobjects.com/PE2/soap.svc/soap';
result = backupClient.GetExchangeInfo([PhoneNumber], [LicenseKey]);
}
wwwServiceobjectsCom.ExchangeInfoResponse result; try{ wwwServiceobjectsCom.ServiceObjects_IPhoneExchange client = new wwwServiceobjectsCom.ServiceObjects_IPhoneExchange(); result = client.GetExchangeInfo([PhoneNumber], [LicenseKey]); } catch(Exception ex){ //If the first request failed try the failover endpoint wwwServiceobjectsCom.ServiceObjects_IPhoneExchange backupClient = new wwwServiceobjectsCom.ServiceObjects_IPhoneExchange(); //The backup environment will be provided to you upon purchasing a production license key backupClient.endpoint_x = 'https://trial.serviceobjects.com/PE2/soap.svc/soap'; result = backupClient.GetExchangeInfo([PhoneNumber], [LicenseKey]); }
Phone Exchange 2 TSQL Code Snippet
'<s:Body>' +
'<PhoneNumber>' + @phonenumber + '</PhoneNumber>' +
'<LicenseKey>' + @key + '</LicenseKey>' +
'</GetExchangeInfo>' +
'</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/PE2/api.svc/PhoneExchangeSoap', 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/IPhoneExchange2/GetExchangeInfo"'
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/PE2/api.svc/PhoneExchangeSoap', 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/IPhoneExchange2/GetExchangeInfo"'
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="https://schemas.xmlsoap.org/soap/envelope/">' +
'<s:Body>' +
'<GetExchangeInfo xmlns="https://www.serviceobjects.com">' +
'<PhoneNumber>' + @phonenumber + '</PhoneNumber>' +
'<LicenseKey>' + @key + '</LicenseKey>' +
'</GetExchangeInfo>' +
'</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/PE2/api.svc/PhoneExchangeSoap', 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/IPhoneExchange2/GetExchangeInfo"'
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/PE2/api.svc/PhoneExchangeSoap', 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/IPhoneExchange2/GetExchangeInfo"'
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="https://schemas.xmlsoap.org/soap/envelope/">' + '<s:Body>' + '<GetExchangeInfo xmlns="https://www.serviceobjects.com">' + '<PhoneNumber>' + @phonenumber + '</PhoneNumber>' + '<LicenseKey>' + @key + '</LicenseKey>' + '</GetExchangeInfo>' + '</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/PE2/api.svc/PhoneExchangeSoap', 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/IPhoneExchange2/GetExchangeInfo"' 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/PE2/api.svc/PhoneExchangeSoap', 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/IPhoneExchange2/GetExchangeInfo"' 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