您好,欢迎访问一九零五行业门户网

WebService-php- 1(16)

最近看了挺多关于php中webservice的资料,感谢燕十八的分享,帮助了我构建服务端的过程。将学习笔记记录如下,其中包含燕十八的笔记。
webservice
1 快速了解webservice
通俗的说:按一定的xml格式,调用远程服务器的方法,且服务器按一定的格式返回xml内容.
一定的格式----soap(simple object access protocol )简单对象访问协议是在分散或分布式的环境中交换信息的简单的协议,是一个基于xml的协
议.
远程服务器 ---- 一般通过http协议来传递消息
总结: webservie == http协议 + soap格式的xml
例1:soap请求
post /webservices/mobilecodews.asmx http/1.1
host: webservice.webxml.com.cn
content-type: text/xml; charset=utf-8
content-length: 354
soapaction: http://webxml.com.cn/getmobilecodeinfo
2 php客户端请求webservice
修改php.ini
extension=php_soap.dll 前的;去掉.
并重启apache
php soapclient类可以用来请求webservice
$soap = new soapclient('http://webservice.webxml.com.cn/webservices/mobilecodews.asmx?wsdl');print_r($soap->getmobilecodeinfo( array('mobilecode'=>'13**********') ) );
array([0] => getmobilecodeinforesponse getmobilecodeinfo(getmobilecodeinfo $parameters)[1] => getdatabaseinforesponse getdatabaseinfo(getdatabaseinfo $parameters))array([0] => struct getmobilecodeinfo {string mobilecode;string userid;}[1] => struct getmobilecodeinforesponse {string getmobilecodeinforesult;}[2] => struct getdatabaseinfo {}[3] => struct getdatabaseinforesponse {arrayofstring getdatabaseinforesult;}[4] => struct arrayofstring {
string string;
}
// 调用方法print_r($soap->getmobilecodeinfo( array('mobilecode'=>'13426060134') ) );
返回结果
stdclass object ( [getmobilecodeinforesult] => 13*********:北京 北京 北京移动动感地带卡 )
3 搭建webservice服务器
wsdl是什么?
wsdl是webservice的规格说明书.

以上就介绍了webservice-php- 1(16),包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息