php WEBSERVICE
1、什麽是SOAP:
SOAP(简单对象访问协议)定义了客户机与服务器之间传递的消息。消息采用 XML 格式。SOAP 独立于平台、编程语言、网络和传输层。本文将讨论 HTTP 上的 SOAP。
2、什麽是WSDL
WSDL(Web 服务描述语言)是用于描述 Web 服务的基于 XML 的语言,描述内容包括服务的位置、格式、操作、参数和数据类型。
3、什麽是UDDI
UDDI(统一描述、发现和集成)是用 API 和 UDDI Registry 实现来提供在网络上存储和检索 Web 服务信息的方法。
PHP5中新增了内置的SOAP扩展,整體來説對SOAP的支持還是不錯的(有些文檔,包括早期的PHP官方文檔都說風險自負了,我是沒發現阿),如果是PHP4的話可以使用PEAR::SOAP和NuSOAP(這個確實不錯使用起來簡單)
安裝:在windows下將extension=php_soap.dll 打開即可
unix下是extension=php_soap.so
如果是原碼包安裝就在 configure後面加上 –enable-soap PHPsoap依赖于GNOMExml库,这个库必须使用2.5.4或更高版本。如果版本不够高,可以从 xmlsoft安装 libxml2
安裝好后得察看一下php.ini文件,設置
[soap]
; Enables or disables WSDL caching feature.
soap.wsdl_cache_enabled=1
; Sets the directory name where SOAP extension will put cache files.
soap.wsdl_cache_dir=”/tmp”
; (time to live) Sets the number of second while cached file will be used
; instead of original one.
soap.wsdl_cache_ttl=86400
phpsoap可以提供从WSDL中发现的方法和参数的数组,例如
<?php
$client = new SoapClient(http://192.168.20.23:8888/soap/webservice.wsdl);
$functions = $client->__getFunctions();
print_r($functions);
$types = $client->__getTypes();
print_r($types);
?>
這樣我們就知道這個webservice所給出的方法和參數了
