opensips开启mi_xmlrpc_ng模块启用http调用
2014 年 9 月 15 日 opensips开启mi_xmlrpc_ng模块启用http调用有7条评论
opensips开启mi_xmlrpc_ng模块启用http远程调用及参数传递,实例如下:
1.安装libxml2-dev及libmicrohttpd-dev
apt-get install libmicrohttpd-dev
apt-get install libxml2-dev
apt-get install libxml2-dev
2.编译httpd模块和mi_xmlrpc_ng模块
通过make menuconfig命令,选择模块httpd、mi_xmlrpc_ng并编译。
3.更新/etc/opensips.cfg配置文件,增加类似如下内容
loadmodule "httpd.so"
modparam("httpd", "ip", "192.168.163.50")
modparam("httpd", "port", 8000)
modparam("httpd", "buf_size", 524288)
modparam("httpd", "post_buf_size", 40960)
loadmodule "mi_xmlrpc_ng.so"
modparam("mi_xmlrpc_ng", "mi_xmlrpc_ng_root", "xmlrpc")
modparam("httpd", "ip", "192.168.163.50")
modparam("httpd", "port", 8000)
modparam("httpd", "buf_size", 524288)
modparam("httpd", "post_buf_size", 40960)
loadmodule "mi_xmlrpc_ng.so"
modparam("mi_xmlrpc_ng", "mi_xmlrpc_ng_root", "xmlrpc")
4.重启opensips服务,并通过一个简单的curl.sh脚本测试
opensipsctl restart
curl 192.168.163.50:8000/xmlrpc -H "Host: 192.168.163.50" -H "User-Agent:My xmlrpc UA" -H "Content-Type: text/xml" -X POST -d "<?xml version='1.0'?>
<methodCall>
<methodName>get_statistics</methodName>
<params>
<param>
<value><string>net:</string></value>
</param>
<param>
<value><string>uri:</string></value>
</param>
</params>
</methodCall>"
<methodCall>
<methodName>get_statistics</methodName>
<params>
<param>
<value><string>net:</string></value>
</param>
<param>
<value><string>uri:</string></value>
</param>
</params>
</methodCall>"
其中methodName为mi接口名称,papams为mi接口的参数列表
返回类似如下内容
ty@ty-desktop:~$ bash curl.sh
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
<param><value><string>net:waiting_udp:: 0
net:waiting_tcp:: 0
uri:positive checks:: 0
uri:negative_checks:: 0
</string></value></param>
</params>
</methodResponse>
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
<param><value><string>net:waiting_udp:: 0
net:waiting_tcp:: 0
uri:positive checks:: 0
uri:negative_checks:: 0
</string></value></param>
</params>
</methodResponse>
脚本paste地址 https://notes.xdty.org/pvdegdg2e
参考链接
http://www.opensips.org/html/docs/modules/devel/httpd.html
http://www.opensips.org/html/docs/modules/devel/mi_xmlrpc_ng.html
评论:7