SOAP简单例子
2011-11-11 09:04
337 查看
简介:这是SOAP简单例子的详细页面,介绍了和php,有关的知识、技巧、经验,和一些php源码等。
class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=339598' scrolling='no'>
soap_client.php
soap_server.php
math.wsdl (可以通过zend studio生成)
爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具
http://biancheng.dnbcw.info/php/339598.html pageNo:7
class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=339598' scrolling='no'>
soap_client.php
<?php $client = new SoapClient('http://www.phptest.com/soap/soap_server.php?WSDL'); //$client = new SoapClient('http://localhost/php/soap/math.wsdl'); try { $result = $client->div(10, 2); // will cause a Soap Fault if divide by zero print "The answer is: $result"; } catch(SoapFault $e) { print "Sorry an error was caught executing your request: {$e->getMessage()}"; } ?>
soap_server.php
<?php class math { public function add($a, $b) { return $a + $b; } public function div($a, $b) { if($b == 0) { throw new SoapFault(-1, "Cannot divide by zero!"); } return $a / $b; } } $server = new SoapServer('math.wsdl', array('soap_version' => SOAP_1_2)); $server->setClass("math"); $server->handle(); ?>
math.wsdl (可以通过zend studio生成)
<?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="a" type="xsd:integer"/> <part name="b" type="xsd:integer"/> </message> <message name="addResponse"> <part name="addReturn" type="xsd:integer"/> </message> <message name="div"> <part name="a" type="xsd:integer"/> <part name="b" type="xsd:integer"/> </message> <message name="divResponse"> <part name="divReturn" type="xsd:double"/> </message> <portType name="mathPortType"> <documentation> A simple math utility class </documentation> <operation name="add"> <documentation> Add two integers together </documentation> <input message="typens:add"/> <output message="typens:addResponse"/> </operation> <operation name="div"> <documentation> Div two integers from each other </documentation> <input message="typens:div"/> <output message="typens:divResponse"/> </operation> </portType> <binding name="mathBinding" type="typens:mathPortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="add"> <soap:operation soapAction="urn:mathAction"/> <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> <operation name="div"> <soap:operation soapAction="urn:mathAction"/> <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="mathPort" binding="typens:mathBinding"> <soap:address location="http://www.phptest.com/soap/soap_server.php"/> </port> </service> </definitions>
爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具
http://biancheng.dnbcw.info/php/339598.html pageNo:7
相关文章推荐
- 一个简单的WebService实现例子,SOAP安全验证
- 一个最简单的SOAP客户端与服务端测试实例(主要是该例子一个类中写了多个方法)
- soap 简单的例子
- Linux下,使用C/C++编写"静态链接库"的一个简单例子
- activeMQ学习之一(简单例子介绍,含spring结合)
- 一个简单的Hibernate例子!
- webwork一个简单的例子
- 170411、java Socket通信的简单例子(UDP)
- log4j 简单例子
- 阿里路由框架--ARouter最简单例子
- 《我的第一本c++书》学习笔记:STL的一个简单例子
- java JMS 之 ActiveMQ 简单例子
- c#.net下简单的Ajax例子——Ajax.dll (转)
- 【Boost】boost库中thread多线程详解7——wait与timed_wait简单例子
- Java简单的回调例子
- TCP 客户端和服务端交互简单例子
- 用Boost::spirit库写C++的源代码解析器(一) 一个简单的例子:解析enum的解析器雏形
- delphi调用C#写的web服务例子-----------(重点 InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioDocument);)
- 一个简单的Ajax例子
- Lane-学习OpenGL(1)-七个简单例子