来源:http://trac.seagullproject.org/wiki/Integration/XmlRpc

创建和使用XML-RPC Web Services

介绍

By default Seagull provides and XML-RPC server which means you can serve any data that your persistence layer can access to a range of clients. By requiring HTTP authorisation over an SSL connection (supported by PEAR XML-RPC package) you can reliably supply data to a subset of clients only. Optionally you can use your Seagull installation to provide public web services in the style of PEAR, Yahoo, Google, etc.

设置客户端

/trunk/modules/default/classes/MaintenanceMgr.php 文件中108行的_checkLatestVersion()为使用Seagull XML-RPC web服务的例子。

设置服务端

服务端其实就是seagull/www/rpc/目录中的server.php文件,所有你可以通过.htaccess文件限制访问权限。

Seagull自带了RAD web服务工具,你可以用它快速简单地创建和发布XML-RPC服务。以/trunk/lib/SGL/XML/RPC/services目录中的内容为例来创建一个服务。要提供一个数据服务,最好的方法是:

 1. 创建数据的相关存取方法,查看[[http://trac.seagullproject.org/browser/trunk/modules/user/classes/DA_User.php|/trunk/modules/user/classes/DA_User.php]] 或[[http://trac.seagullproject.org/browser/trunk/modules/default/classes/DA_Default.php|/trunk/modules/default/classes/DA_Default.php]] 为例。
 2. 创建一个包含一个和文件名相同的函数的文件,并调用相关的数据存取方法,采用和这个文件[[http://trac.seagullproject.org/browser/trunk/lib/SGL/XML/RPC/services/determineLatestVersion.php|/trunk/lib/SGL/XML/RPC/services/determineLatestVersion.php]]

一样的命名规范。

 3. 按照XML-RPC的标准包装返回的数据,以上面文件为例
 4. 如果有需要可以设置存取限制,如在rpc目录中使用一个APACHE的.htaccess文件。
 
integration/xmlrpc.txt · 最后更改: 2010/05/30 00:21 (外部编辑)
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2