You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sems/doc
Stefan Sayer 35ce8253ce
more documentation about adminpin etc
17 years ago
..
figures figures on SEMS usage 19 years ago
CHANGELOG updated 17 years ago
COMPILING support for inband dtmf detector from spandsp lib (www.soft-switch.org) 18 years ago
COPYING added GPL notice in README (look, Olle, its not THAT difficult to find any more) 17 years ago
Configure-Sems-OpenSER-HOWTO removed some obsolete notes 17 years ago
Configure-Sems-Ser-HOWTO added warning on top of ser+sems howto 17 years ago
Makefile train ride doxygen documentation 19 years ago
Readme.ann_b2b yet more documentation... 19 years ago
Readme.announce_transfer changed name of the param header to reflect changes in the code. 19 years ago
Readme.announcement
Readme.annrecorder support for uid (UserID) / did (DomainID) in voicemail/voicebox/annrecorder 17 years ago
Readme.auth_b2b take account optionally from config file (overrides P-App-Param) 17 years ago
Readme.call_timer call timer b2bua application 18 years ago
Readme.callback updated doc 18 years ago
Readme.click2dial Added two new plugins: 19 years ago
Readme.conf_auth added readme for conf_auth with example auth server 19 years ago
Readme.conference * Introduced max_participants conference.conf variable. 18 years ago
Readme.diameter_client moved Readme files to doc/ folder 18 years ago
Readme.early_announce early media announcement with call continuation in b2b mode option 18 years ago
Readme.echo test commit 19 years ago
Readme.iLBC added readme 19 years ago
Readme.ivr updated ivr doc and quick reference 18 years ago
Readme.mailbox yet more documentation... 19 years ago
Readme.monitoring setExpiration function. Using this together with garbage collector log, 17 years ago
Readme.mp3plugin updated doc 19 years ago
Readme.msg_storage moved Readme files to doc/ folder 18 years ago
Readme.pin_collect changed name of the param header to reflect changes in the code. 19 years ago
Readme.py_sems yet more documentation... 19 years ago
Readme.reg_agent added module to register at SIP registrar (using registrar_client) 19 years ago
Readme.registrar_client added module to register at SIP registrar (using registrar_client) 19 years ago
Readme.sw_prepaid_sip Added two new plugins: 19 years ago
Readme.uac_auth documentation for uac_auth 19 years ago
Readme.voicebox support for uid (UserID) / did (DomainID) in voicemail/voicebox/annrecorder 17 years ago
Readme.voicemail support for uid (UserID) / did (DomainID) in voicemail/voicebox/annrecorder 17 years ago
Readme.webconference more documentation about adminpin etc 17 years ago
Readme.xmlrpc2di added MT note 18 years ago
WHATSNEW_0.10 updated doc 17 years ago
doc_applications.h added missing apps to documentation 17 years ago
doc_componentmods.h added and restructured doc 17 years ago
doc_exampleapps.h added missing apps to documentation 17 years ago
doc_tutorialapps.h added and restructured doc 17 years ago
doc_zrtp.h added and restructured doc 17 years ago
doxyref.h added warning on top of ser+sems howto 17 years ago

Readme.xmlrpc2di

xmlrpc2di: DI call via XMLRPC

This module makes the Dynamic Invocation (DI) Interfaces exported 
by component modules accessible from XMLRPC. Additionaly the builtin 
methods calls, get_loglevel and set_loglevel are implemented (like in the 
stats UDP server). 

Additionally, it can be used as client to access XMLRPC servers. Applications
can use the DI function newConnection to add a new server entry, and sendRequest
to send a request. If sendRequest is executed, an active server is selected from 
the list and used to send the request. If sending the request failes, the server
is put inactive for a (configurable) while, and only then retried.

This module uses the XmlRpc++ library (http://xmlrpcpp.sourceforge.net/).
In order to compile it, the xmlrpc library is needed; install it by 
make install-xmlrpcpp, or by hand:
cd apps/examples/xmlrpc2di 
wget http://switch.dl.sourceforge.net/sourceforge/xmlrpcpp/xmlrpc++0.7.tar.gz 
&& tar xzvf xmlrpc++0.7.tar.gz

A small patch set needs to be applied as well:
patch -p0 < xmlrpcpp07_sems.patch

If xmlrpcpp is extracted to a different directory, the path in
the Makefile needs to be adapted. If your xmlrpc++ installation has the
SSL for xmlrpc client option, you may need to add -DHAVE_XMLRPCPP_SSL 
to module_cflags due to some ambiguity in the header.

The XMLRPC server can be configured to run as single threaded server (if
one request is executed, the next ones have to wait), or a multi-threaded server 
with a thread pool, in which case the callers only have to wait if there are 
as many requests served in parallel as threads. Note that it is a good idea to 
implement DI functions thread-safe, as they may be called from different threads
in SEMS anyway.

Configuration parameters
------------------------

  function         default    description
 +---------------------------------------
  xmlrpc_port      8090       port to bind XMLRPC server to

  export_di        yes        enable 'di' function (see below)

  direct_export    none       search these interfaces for methods 
                              to export

  run_server       yes        start an XMLRPC server

  server_retry_after 10       retry a failed server after n seconds

  multithreaded    yes        MT or default server
 
  threads          5          only in case of multithreaded

Using XMLRPC2DI client over DI
------------------------------

DI method "newConnection"
 arguments: 
    "ssis":   app_name, server, port, uri
 example: 
 -- snip --
  AmDynInvoke* xmlrpc2di;
  AmDynInvokeFactory* xfFactory = AmPlugIn::instance()->getFactory4Di("xmlrpc2di");
  if (NULL == xfFactory || 
      NULL == (xmlrpc2di = xfFactory->getInstance())){
    ERROR("could not get xmlrpc2di. please load the xmlrpc2di module\n");
    return;
  }

  AmArg cargs, cret;    
  cargs.push("conf_auth");
  cargs.push("192.168.0.1");
  cargs.push(8102);
  cargs.push("");
  xmlrpc2di->invoke("newConnection", cargs, cret);
 -- snip --
             
DI method "sendRequest"
 arguments: 
    "ssa":    app_name, method, args
 example: 
 -- snip --
    AmArg args, ret;    
    args.push("conf_auth");
    args.push("authPin");  // method name
    args.assertArray(3);
    args[2].push("fancy_parameter"); // some parameters
    args[2].push("1234");
    xmlrpc2di->invoke("sendRequest", args, ret);
    if (ret[0].asInt() == 0) {
     DBG("status %d, description %s, uri %s", 
	ret[2][0].asInt(), ret[2][1].asCStr(), ret[2][3].asCStr());
    }
 -- snip --


Exporting functions from a DI interface to XMLRPC
-------------------------------------------------
The xmlrpc2di module searches the interfaces configured by the 
'direct_export' configuration variable for functions to export
via XMLRPC. The interface must provide a function '_list' which 
should return a list of methods to export. These methods are 
exported as XMLRPC functions in two ways:
 <method name>
and
 <interface name>.<method name>

If the function <method name> already exists, only 
<interface name>.<method name> is exported.

As an example, lets set 
 direct_export=di_dial
in xmlrpc2di.conf, and have a look at 
examples/di_dial/DIDial.cpp:
...
    } else if(method == "_list"){ 
      ret.push(AmArg("dial"));
      ret.push(AmArg("dial_auth"));
      ret.push(AmArg("dial_pin"));
      ret.push(AmArg("help"));
    } else 
...

When SEMS starts and loads the xmlrpc2di module, the _list 
method of the di_dial interface is called, and the functions 
are exported: 
(23386) DEBUG: onLoad (XMLRPC2DI.cpp:67): direct_export interfaces: di_dial
(23386) DEBUG: onLoad (XMLRPC2DI.cpp:77): XMLRPC Server: Enabling builtin method 'di'.
(23386) DEBUG: XMLRPC2DIServer (XMLRPC2DI.cpp:99):  XMLRPC Server: enabled builtin method 'calls'
(23386) DEBUG: XMLRPC2DIServer (XMLRPC2DI.cpp:100): XMLRPC Server: enabled builtin method 'get_loglevel'
(23386) DEBUG: XMLRPC2DIServer (XMLRPC2DI.cpp:101): XMLRPC Server: enabled builtin method 'set_loglevel'
(23386) DEBUG: registerMethods (XMLRPC2DI.cpp:154): XMLRPC Server: adding method 'dial'
(23386) DEBUG: registerMethods (XMLRPC2DI.cpp:160): XMLRPC Server: adding method 'di_dial.dial'
(23386) DEBUG: registerMethods (XMLRPC2DI.cpp:154): XMLRPC Server: adding method 'dial_auth'
(23386) DEBUG: registerMethods (XMLRPC2DI.cpp:160): XMLRPC Server: adding method 'di_dial.dial_auth'
(23386) DEBUG: registerMethods (XMLRPC2DI.cpp:154): XMLRPC Server: adding method 'dial_pin'
(23386) DEBUG: registerMethods (XMLRPC2DI.cpp:160): XMLRPC Server: adding method 'di_dial.dial_pin'
(23386) DEBUG: registerMethods (XMLRPC2DI.cpp:154): XMLRPC Server: adding method 'help'
(23386) DEBUG: registerMethods (XMLRPC2DI.cpp:160): XMLRPC Server: adding method 'di_dial.help'
(23386) DEBUG: XMLRPC2DIServer (XMLRPC2DI.cpp:115): Initialized XMLRPC2DIServer with:
(23386) DEBUG: XMLRPC2DIServer (XMLRPC2DI.cpp:116):                           port = 8090

Now from e.g. python we can do the following:
 >>> from xmlrpclib import *
 >>> s = ServerProxy("http://127.0.0.1:8090")
 >>> s.help()
 ['dial <application> <user> <from> <to>', 'dial_auth <application> <user> <from> <to> <realm> <auth_user> <auth_pwd>', 'dial_pin <application> <dialout pin> <local_user> <to_user>']
 >>> s.di_dial.help()
 ['dial <application> <user> <from> <to>', 'dial_auth <application> <user> <from> <to> <realm> <auth_user> <auth_pwd>', 'dial_pin <application> <dialout pin> <local_user> <to_user>']

a.s.o.

XMLRPC server function 'di'
--------------------------
Using the function 'di' all methods of all interfaces can be executed 
without the interfaces needing to list the methods in the '_list' call.
The first parameter to 'di' is alway the factory name, the second the
function name. Further parameters to XMLRPC calls are converted to DI 
ArgArray structure, and result of DI calls are converted back to XMLRPC 
parameters. At the moment only string, int and double types are implemented
(no DateTime, struct, binary, ...).

The 'di' function can be disabled on the XMLRPC server by setting 
 export_di=no
in xmlrpc2di.conf. By default it is enabled.


Examples (that hopefully trigger some creativity in the reader ;) 
-----------------------------------------------------------------

Checking load, setting log level:
 from xmlrpclib import *
 server = ServerProxy("http://127.0.0.1:8090")
 print server.calls()
 print "Current log level is ", server.get_loglevel()
 server.set_loglevel(3)

Register fritz at iptel.org using registrar client over XMLRPC 
from python:

 from xmlrpclib import *
 server = ServerProxy("http://127.0.0.1:8090")
 server.di('registrar_client', 'createRegistration', 
     'iptel.org',  'fritz', 'Frotz', 
     'fritz', 'secretpass', '')

or, having set 
 direct_export=registrar_client
directly:
 from xmlrpclib import *
 server = ServerProxy("http://127.0.0.1:8090")
 server.createRegistration('iptel.org',  'fritz', 'Frotz', 
     'fritz', 'secretpass', '')


To call someone into webconference (supports authenticated dial-out) 
over an account at sparvoip.de using di_dial:
from xmlrpclib import *
server = ServerProxy("http://127.0.0.1:8090")
server.di('di_dial', 'dial_auth','webconference', 'roomname',
 'sip:myuser@sparvoip.de', 'sip:0049301234567@sparvoip.de',
 'sparvoip.de','myuser','passwd')