webserver 两种模式
PHP 使用soap有两种方式。 一、用wsdl文件 服务器端。 <?php class service { public function HelloWorld() { return "Hello"; } public function Add($a,$b) { return $a+$b; } } $server=new SoapServer('soap.wsdl',array('soap_version' => SOAP_1_2)); $server->setClass("service"); $server->handle(); ?> 资源描述文件,可以用工具(zend studio)生成。其实就是一个xml文件。 <?xml version="1.0" encoding="UTF-8"?> <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost/interface/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="soap" targetnamespace="http://localhost/interface/"> <types> <schema targetnamespace="http://localhost/interface/"> <element name="HelloWorld"> <complextype> <sequence> <element name="in" type="xsd:string"></element> </sequence> </complextype> </element> <element name="HelloWorldResponse"> <complextype> <sequence> <element name="out" type="xsd:string"></element> </sequence> </complextype> </element> <element name="Add"> <complextype> <sequence> <element name="in" type="xsd:int"></element> </sequence> </complextype> </element> <element name="AddResponse"> <complextype> <sequence> <element name="out" type="xsd:int"></element> </sequence> </complextype> </element> </schema> </types> <message name="AddRequest"> <part name="a" type="xsd:int"></part> <part name="b" type="xsd:int"></part> </message> <message name="AddResponse"> <part name="c" type="xsd:int"></part> </message> <porttype name="TestSoap"> <operation name="Add"> <input message="tns:AddRequest"> <output message="tns:AddResponse"></output> </operation> </porttype> <binding name="soapSOAP" type="tns:TestSoap"> <binding style="document" transport="http://schemas.xmlsoap.org/soap/http"></binding> <operation name="Add"> <operation soapaction="http://localhost/interface/Add"></operation> <input> <output> <body use="literal" namespace="http://localhost/interface/"></body> </output> </operation> </binding> <service name="TestSoap"> <port binding="tns:soapSOAP" name="soapSOAP"> <address location="http://localhost/interface/myservice.php"></address> </port> </service> </definitions> 客户端调用 <?php $soap = new SoapClient('http://localhost/interface/soap.wsdl'); echo $soap->Add(1,2); ?> 二、不用wsdl文件 服务器端 <?php class service { public function HelloWorld() { return "Hello"; } public function Add($a,$b) { return $a+$b; } } $server=new SoapServer(null,array('uri' => "abcd")); $server->setClass("service"); $server->handle(); ?> 客户端 <?php try{ $soap = new SoapClient(null,array( "location" => "http://localhost/interface/soap.php", "uri" => "abcd", //资源描述符服务器和客户端必须对应 "style" => SOAP_RPC, "use" => SOAP_ENCODED )); echo $soap->Add(1,2); }catch(Exction $e){ echo print_r($e->getMessage(),true); } ?>
版权声明:本文为博主原创文章,未经博主允许不得转载。
以上就介绍了webserver 两种模式,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

Laravel使用其直观的闪存方法简化了处理临时会话数据。这非常适合在您的应用程序中显示简短的消息,警报或通知。 默认情况下,数据仅针对后续请求: $请求 -

PHP客户端URL(curl)扩展是开发人员的强大工具,可以与远程服务器和REST API无缝交互。通过利用Libcurl(备受尊敬的多协议文件传输库),PHP curl促进了有效的执行

Laravel 提供简洁的 HTTP 响应模拟语法,简化了 HTTP 交互测试。这种方法显着减少了代码冗余,同时使您的测试模拟更直观。 基本实现提供了多种响应类型快捷方式: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

您是否想为客户最紧迫的问题提供实时的即时解决方案? 实时聊天使您可以与客户进行实时对话,并立即解决他们的问题。它允许您为您的自定义提供更快的服务

文章讨论了PHP 5.3中引入的PHP中的晚期静态结合(LSB),从而允许静态方法的运行时分辨率调用以获得更灵活的继承。 LSB的实用应用和潜在的触摸

使用PHP的cURL库发送JSON数据在PHP开发中,经常需要与外部API进行交互,其中一种常见的方式是使用cURL库发送POST�...
