电脑安全

您当前的位置:主页 > 电脑安全 >

php soap 实例-网络编程

来源:[db:来源]标题:   宋体    编辑:电脑技术全能网 时间:2019-09-20 06:24

原标题:php soap 实例-网络编程
   Server端+Client端+WSDL申明:很简略!!!!!!参考了以下:先建Server,而后应用wsdl东西来天生wsdl,我用的是zend development environment,在zde中的tools中的wsdl generator wizard 第一页是名字,和输入地点(输入后间接挪从前就OK)第二页是类和地点,类挑上勾,URL那边添server谁人文件的地点第三页 finish别忘了拷谁人wsdl从前...记得server援用的谁人类文件里不要有输入.一共有两个须要添地点的处所一个是wsdl中的描写http://127.0.0.1/test/CulculatorServer.php一个是client中的衔接http://127.0.0.1/test/Culculator.wsd类文件<?php/*** @name Culculator.php* @date Fri Jan 25 12:43:40 CST 2008* @copyright 马永占(MyZ)* @author 马永占(MyZ) * @link http://blog.111cn.net/mayongzhan/*/class Culculator{ /** * 乞降 * * @param float $x * @param float $y * @return float */ public function add($x, $y) { return $x + $y; }}?>Server<?php/*** @name CulculatorServer.php* @date Fri Jan 25 12:44:04 CST 2008* @copyright 马永占(MyZ)* @author 马永占(MyZ) * @link http://blog.111cn.net/mayongzhan/*/include(''./Culculator.php'');$server = new SoapServer(''./Culculator.wsdl''); $server->setClass(''Culculator'');$server->handle(); ?>Client<?php /*** @name CulculatorClient.php* @date Fri Jan 25 12:43:54 CST 2008* @copyright 马永占(MyZ)* @author 马永占(MyZ) * @link http://blog.111cn.net/mayongzhan/*/$soap = new SoapClient(''http://127.0.0.1/test/Culculator.wsdl''); echo $soap->add(1, 2);?>WSDL<?xml version=''1.0'' encoding=''UTF-8''?><!-- WSDL file generated by Zend Studio. --><definitions name="math" targetNamespace="urn:math" xmlns:typens="urn:math" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <message name="add"> <part name="x" type="xsd:float"/> <part name="y" type="xsd:float"/> </message> <message name="addResponse"> <part name="addReturn" type="xsd:float"/> </message> <portType name="CulculatorPortType"> <operation name="add"> <documentation> 乞降 </documentation> <input message="typens:add"/> <output message="typens:addResponse"/> </operation> </portType> <binding name="CulculatorBinding" type="typens:CulculatorPortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="add"> <soap:operation soapAction="urn:CulculatorAction"/> <input> <soap:body namespace="urn:math" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output> <soap:body namespace="urn:math" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding> <service name="mathService"> <port name="CulculatorPort" binding="typens:CulculatorBinding"> <soap:address location="http://127.0.0.1/test/CulculatorServer.php"/> </port> </service></definitions>

上一篇:php常用正则表达精品-网络编程

下一篇:没有了