Project

General

Profile

SipXCAPApi » History » Revision 2

Revision 1 (Adrian Georgescu, 03/12/2009 07:48 PM) → Revision 2/8 (Oliver Bril, 03/31/2009 03:35 PM)

= XCAP API = 

 [[TOC(WikiStart, Sip*, depth=3)]] 
 XCAP protocol allows a client to read, write, and modify application configuration data stored in XML format on a server. XCAP maps XML document sub-trees and element attributes to HTTP URIs, so that these components can be directly accessed by clients using HTTP protocol. An XCAP server is used by XCAP clients to store data like buddy lists and presence policy in combination with a SIP Presence server that supports PUBLISH, SUBSCRIBE and NOTIFY methods to provide a complete SIP SIMPLE solution. 

 XCAP client is implemented by [http://devel.ag-projects.com/cgi-bin/darcsweb.cgi?r=python-xcaplib;a=summary python-xcaplib]. The library provides {{{xcaplib.client.XCAPClient}}} class which is an HTTP client with an interface better suited for XCAP servers. The library also provides 
 a version of XCAPClient ({{{xcaplib.green.XCAPClient}}}) built on top of eventlet, which may be used in twisted reactor. 

 Here a few examples on how to use {{{XCAPClient}}}: 
 {{{ 
 client = XCAPClient(xcap_root, xcap_user_id, password=password) 
 document = file('examples/resource-lists.xml').read() 

 # put the document on the server 
 client.put('resource-lists', document) 

 # read the document from the server 
 got = client.get('resource-lists') 

 # get a specific element within a document 
 element = client.get('resource-lists', '/resource-lists/list/entry/display-name') 

 # get an attribute: 
 res = client.get('resource-lists', '/resource-lists/list/entry/@uri') 

 # replace an element conditionally, based on the etag 
 client.put('resource-lists', '<entry uri="sip:bob@example.com"><display-name>The Bob</display-name></entry>', '/resource-lists/list/entry[@uri="sip:bob@example.com"]', etag=stored_etag) 

 # delete an element 
 client.delete('resource-lists', node_selector, etag=res.etag) 
 }}}