安装完OpenXcap就要进行测试了,我选择了一个比较简单的方法,使用python-xcaplib这个客户端进行测试
如果配置好了源就直接用apt-get install python-xcaplib,不然就需要下载tar包,然后用python脚本编译安装。
安装好以后需要将tar包中的config.ini.sample文件改名为config.ini并且按照服务端的config.ini进行修改
并且在examples文件夹中有一些xml文件可以供之后的测试使用
例如我的服务端配置如下:
- ;
- ; Configuration file for OpenXCAP
- ;
- ; Copyright (c) 2007-2008 AG Projects
- ; http://ag-projects.com
- [Server]
- ; IP address and port to listen for requests
- ; 0.0.0.0 means any address of this host
- address = 0.0.0.0
- port = 80
- ; The XCAP Root URI; must not contain any port number. If it has the 'https' scheme,
- ; the server will listen for requests in TLS mode.
- ; Insert more "root=" lines here to create aliases for XCAP root.
- ; The LAST 'root=' line sets the primary XCAP root, which will be
- ; used when generating xcap-diff.
- ; There's no way to find out which XCAP root a document belongs to,
- ; as such information is not stored in the database.
- root = http://192.168.100.30/xcap-root
- ; The backend to be used for storage and authentication. Current supported
- ; values are Database and OpenSER. OpenSER backend inherits all the settings
- ; from the Database backend but performs extra actions related to the
- ; integration with OpenSER for which it read the settings from [OpenSER]
- ; section
- backend = Database
- ; Validate XCAP documents against XML schemas
- document_validation = Yes
- [Logging]
- ; directory where to put log files, default is /var/log/openxcap
- ; if empty, like in the following line, logs will be printed to stdout
- ;directory=
- ; The following log_* parameters control what information is logged for which errors.
- ; Their format is comma-separated list of HTTP error codes that should enable the feature
- ; currently implemented: log_request_headers, log_response_body, log_stacktrace
- ; Some examples:
- ; * log stack trace for 500 Internal Error only (default)
- ;log_stacktrace=500
- ; * log stack trace (if available) for any error
- ;log_stacktrace=any
- ; * log responses sent to the client for 400 and 409 errors (default is none)
- ;log_response_body=400,409
- ; * log headers sent by the client for 401 errors (default is none)
- ;log_request_headers=401
- [Authentication]
- ; The HTTP authentication type, this can be either 'basic' or 'digest'.
- ; If you're using TLS, it's better to choose 'basic' because the data is encrypted anyway.
- type = basic
- ; Specify if the passwords are stored as plain text - Yes
- ; or in a hashed format MD5('username:domain:password') - No
- cleartext_passwords = Yes
- ; The default authentication realm
- default_realm = 192.168.100.30
- ; A list of trusted peers from where XCAP requests are accepted without HTTP authentication
- ; e.g. trusted_peers = 10.0.0.0/24, 192.168.0.1
- trusted_peers = 192.168.100.30/192.168.100.26/127.0.0.1
- [TLS]
- ; Location of X509 certificate and private key that identify this server. The path is
- ; relative to /etc/openxcap, or it can be given as an absolute path.
- ; Server X509 certificate
- certificate = tls/server.crt
- ; Server X509 private key
- private_key = tls/server.key
- [Database]
- ; The database connection URI for the datase with subscriber accounts
- authentication_db_uri = mysql://root:root@127.0.0.1/openxcap
- ; The database connection URI for the database that stores the XCAP documents
- storage_db_uri = mysql://root:root@127.0.0.1/openxcap
- ; Authentication and storage tables
- subscriber_table = subscriber
- xcap_table = xcap
- [OpenSER]
- ; The address and port of the xml-rpc management interface
- xmlrpc_url = http://192.168.100.30:8080
- ; Publish xcap-diff event via OpenSER management interface
- ; enable_publish_xcapdiff = yes
那么客户端就需要设置为:
- # rename this file to 'config.ini' and copy it in ~/.sipclient/ directory
- # this will be the default account used by xcapclient
- [Account]
- sip_address = alice@192.168.100.30
- password = 123
- xcap_root = http://192.168.100.30/xcap-root
- # this will be used when -a bob command-line switch is provided
- [Account_bob]
- sip_address = bob@192.168.100.30
- password = 123
- xcap_root = http://192.168.100.30/xcap-root
现在执行一下
xcapclient --app xcap-caps get 命令就可以看到回复了
值得一说的是老外的论坛就是好,本来服务端的端口默认设置是443,一直都是连不上,提问以后半小时就有了解决方法,将端口设置为80
需要注意的是那些IP都是根据我自己测试用的机器的IP配置的
不过现在面临的问题是本机通过客户端可以连接,但是从别的机器写的httpclient请求总是报错:
2008-12-15 16:26:44 org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
信息: basic authentication scheme selected
2008-12-15 16:26:44 org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallenge
HTTP/1.1 401 Unauthorized
信息: No credentials available for BASIC '192.168.100.26'@192.168.100.30:80
<html><head><title>Unauthorized</title></head><body><h1>Unauthorized</h1><p>You are not authorized to access this resource.</p></body></html>
本地写的代码仍需测试,看来还有不少东西需要解决