This page explains how you can use SOAP and XMLRPC Implementation.
It can be used within web-based or console applications, or for network services.
L'API de ScopServ vous laisse la possibilité d'ajouter ou d'enlever des informations de sa propre base de données, changer la valeur des champs, voir le contenu des différentes sections et plus.
Using Web Services
Log into ScopServ GUI as admin user, expand the Development menu and click on Telephony link.
The list of all supported implementations, request parameters, data type definition and methods list are available on the General menu.
On the Web Services menu, you will see detailled list of all settings that can be defined when using telephony_setExtension method.
All methods (functions) can be tested using Test Service directly from the ScopServ GUI.
Example #1 (SOAP and Ruby)
Here's a simple
Ruby program that calls a phone number and bridge it with an extension.
#!/usr/bin/env ruby
require 'soap/wsdlDriver'
require 'cgi'
WSDL_URL = "http://demo.scopserv.com/rpc.php?wsdl"
soap_client = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver
# Log SOAP request and response
soap_client.wiredump_file_base = "soap-log.txt"
# Place the phone call
response = soap_client.telephony_makeCall( "1001", "15145551212")
# Display reponse
puts response.result, " / ", response.message
Above, we use the SOAP WSDL-shema from demo site and call the telephony_makeCall method. The parameters we provide are: The Extension number (1001) and the destination Phone Number (15145551212).
Example #2 (XMLRPC and Perl)
Another example that calls a phone number but in
Perl language.
#!/usr/bin/perl -w
use strict;
use Frontier::Client;
my $server_url = 'http://demo.scopserv.com/rpc.php';
my $server = Frontier::Client->new('url' => $server_url);
my $result = $server->call('telephony_makeCall', '222@company', '18195551234');
if (${$result} == 1) {
print "Successfully originate call";
exit 0;
}
Using Frontier::Client library (CPAN), we call the telephony_makeCall method and bridge call between extension 222 on tenant 'company' and phone number 18195551212.
Example #3 (SOAP and PHP)
Yes, another example that calls a phone number but this time using
PHP.
<?php
// include the SOAP classes
require_once('nusoap.php');
// define parameter array (Extension and Phone Number)
$param = array(
'extension' => '555',
'phonenum' => '18005550000'
);
// define path to server application
$serverpath ='http://demo.scopserv.com/rpc.php';
// set username and password
$username = 'admin';
$password = 'CHANGE';
//define method namespace
$namespace="urn:horde";
// create client object
$client = new soapclient($serverpath);
// set Authentication credenticals
$client->setCredentials($username, $password);
// make the call
$res = $client->call('telephony_makeCall', $param, $namespace);
// if a fault occurred, output error info
if (isset($fault)) {
print "Error: ". $fault;
} else {
// otherwise output the result
print "The result is: $res\n";
}
// kill object
unset($client);
...
Example #4 (SOAP and PHP)
More complex example in
PHP language that allow to create a SIP extension, get settings and delete it.
#!/usr/bin/php
<?php
/* Configuration */
$user = 'admin'; // Authentication Username (CHANGE)
$pass = 'CHANGEME'; // Authentication Password (CHANGE)
$url = 'http://demo.scopserv.com/rpc.php'; // Remote SOAP server (CHANGE)
// Define Include Path for RPC library
ini_set('include_path', '/var/www/scopserv/framework');
// Include base library and RPC
require_once 'Horde/RPC.php';
// Get Command line Argument
$cmd = @$argv[1];
switch($cmd) {
case 'get':
// Get Setting/Config for user demouser
$method = 'telephony_getExtension';
$params = array('demouser');
break;
case 'del':
// Delete user demouser from Database
$method = 'telephony_deleteExtension';
$params = array('demouser');
break;
case 'set':
// Set infos for user demouser
$method = 'telephony_setExtension';
$params = array(
'demouser',
array(
'phone_type' => "sip",
'phone_extension' => "1305",
'phone_context' => "default",
'phone_fullname' => "John Doe",
'phone_desc' => "",
'phone_username' => "demouser",
'phone_password' => "52drpe85",
'phone_host' => array("0","0","0","0"),
'phone_vm' => 1,
'phone_usemwi' => 0,
'phone_vm_password' => "1977",
'phone_vm_skip' => 0,
'phone_vm_notify' => 1,
'phone_vm_email' => "john@acme.com",
'phone_vm_attach' => 1,
'phone_vm_delete' => 0,
'phone_nat' => 1,
'phone_canreinvite' => 0,
'phone_dtmfmode' => "rfc2833",
'phone_codec' => array("ulaw","g729", "speex"),
'phone_user_followme' => 0,
'phone_user_ivr' => 0,
'phone_maxtime' => 20,
'phone_language' => "fr",
'phone_moh' => "jazz",
'tenant_id' => "36"
)
);
break;
default:
print "Usage: rpc.php [set|get|del]\n";
exit;
break;
}
// Execute the SOAP request
$response = Horde_RPC::request('soap', $url, $method, $params,
array('namespace' => 'urn:horde',
'trace' => 20,
'timeout' => 20,
'user' => $user,
'pass' => $pass));
// Dump the raw response
echo "===value======\n";
var_dump($response);
echo "==============\n";
This sample use RPC library included on the
scopserv-framework package.