(三)基于PHP——复杂的WSDL的创建(WSDL篇)
来源:互联网 发布:网络暴力的微电影 编辑:程序博客网 时间:2024/06/04 20:05
转载请注明出处:http://blog.csdn.net/cwt0408/article/details/6952936
(谢谢合作!)
调用数组内容:
1、修改service.php
<?phpclass PhoneBookInfo{public $name,$number,$relationship,$email;public function __construct($pname,$pnumber,$prelationship,$pemail){$this->name=$pname;$this->number=$pnumber;$this->relationship=$prelationship;$this->email=$pemail;}}/*可以在这里调用数据库,下面是测试数据*/function GetPhoneBook($inname){$pinfo=array();$pinfo[]=new PhoneBookInfo('zhangsan','13333333333','friend','3333@163.com');$pinfo[]=new PhoneBookInfo( 'lisi', '13444444444', 'friend', '4444@163.com' ); $pinfo[]=new PhoneBookInfo( 'wangwu', '135555555555', 'friend', '5555@163.com' ); return $pinfo;}$server = new SoapServer("myphone.wsdl");$server->addFunction("GetPhoneBook");$server->handle (); ?>
2、client.php
<?phpheader('Content-Type:text/html;charset=utf-8');$client = new SoapClient("http://www.mysoapservice.cn/service.php?WSDL" , array('trace'=>true));var_dump($client->__getTypes());try { $response = $client->GetPhoneBook('zhang'); var_dump($response);}catch (SoapFault $sf){ var_dump($sf); print ($client->__getLastRequest()); print ($client->__getLastResponse());}?>3、关键修改myphone.wsdl
<?xml version ='1.0' encoding ='UTF-8' ?> <definitions name='phonebook' targetNamespace='http://www.mysoapservice.cn/' xmlns:tns='http://www.mysoapservice.cn/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' xmlns='http://schemas.xmlsoap.org/wsdl/'> <types> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.mysoapservice.cn/" xmlns:Q1="soapenc"> <xsd:complexType name="PhoneBookInfoArray"> <xsd:complexContent> <xsd:restriction base="soapenc:Array"> <xsd:attribute ref="sopenc:arrayType" wsdl:arrayType="tns:PhoneBookInfo[]"/> </xsd:restriction> </xsd:complexContent> </xsd:complexType> <xsd:complexType name="PhoneBookInfo"> <xsd:all> <xsd:element name="name" type="xsd:string"></xsd:element> <xsd:element name="number" type="xsd:string"></xsd:element> <xsd:element name="relationship" type="xsd:string"></xsd:element> <xsd:element name="email" type="xsd:string"></xsd:element> </xsd:all> </xsd:complexType> </xsd:schema> </types> <message name='GetPhoneBookRequest'> <part name="inname" type="xsd:string"/></message> <message name='GetPhoneBookResponse'> <part name="phonebookInfo" type="xsd:PhoneBookInfoArray"/></message><portType name='PhoneBookToEveryOneProt'> <operation name='GetPhoneBook'> <input message='tns:GetPhoneBookRequest'/> <output message='tns:GetPhoneBookResponse'/> </operation></portType><binding name='PhoneBookSOAP' type='tns:PhoneBookToEveryOneProt'> <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/> <operation name='GetPhoneBook'> <soap:operation soapAction='http://www.cwtservice.cn/newOperation/'/> <input> <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> </input> <output> <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> </output> </operation> </binding><service name='PhoneBookService'> <port name='PhoneBookSOAP' binding='tns:PhoneBookSOAP'> <soap:address location='http://www.mysoapservice.cn/service.php'/> </port> </service> </definitions>对比修改地方:
测试结果:
另外需要注意的地方:
如果遇到I/O错误:
1、在php.ini中打开extension=php_curl.dll
2、copy: libeay32.dll、ssleay32.dll到system32下
这两个dll网上都有下载!我就不传了!
- (三)基于PHP——复杂的WSDL的创建(WSDL篇)
- (三)基于PHP——复杂的WSDL的创建(WSDL篇)
- (二)基于PHP——简单的WSDL的创建(WSDL篇)
- (二)基于PHP——简单的WSDL的创建(WSDL篇)
- (一)基于PHP——WSDL的创建(NON-WSDL篇)
- (一)基于PHP——WSDL的创建(NON-WSDL篇)
- 基于PHP——简单的WSDL的创建(WSDL篇)
- 简单的WSDL的创建(WSDL)-php
- WSDL的详解笔记(三)
- Eclipse创建WSDL+AXIS2 (三)
- WebService—wsdl的简单介绍(未完)
- soap基于契约优先WSDL的开发
- 基于wsdl 文件的webService接口开发
- IOS -- 基于WebService WSDL 的请求
- 基于wsdl的测试数据自动生成技术
- php学习之道:php中soap的使用实例以及生成WSDL文件,提供自动生成WSDL文件的类库——SoapDiscovery.class.php类
- WSDL WebService的创建和使用实例
- WSDL WebService的创建和使用实例
- 七种qsort排序法(附模板)
- 使用 jQuery dataTables - 2 四种数据来源
- 用了union all时如何用order by newid()?
- Android Your project contains error(s), please fix them before running your application.
- sap bo 生产收货的跟生产订单关联.txt
- (三)基于PHP——复杂的WSDL的创建(WSDL篇)
- SQLite在字符串比较中的大小写问题
- 万维网操作系统---空间意义
- 您可能需要将当前数据库的兼容级别设置为更高的值,以启用此功能。有关存储过程 sp_dbcmptlevel 的信息,请参见帮助。
- 入职4个月体会
- 快递涨价淘宝的未日来临 电商的出路
- C++ 关键字
- 工厂方法模式
- 传球游戏