<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='自定义名称'
targetNamespace='目标命名空间(WSDL所在地址)'
<!--tns自定义目标空间,下面会用到-->
xmlns:tns='目标命名空间(WSDL所在地址)'
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> 元素定义 web service 使用的数据类型,WSDL 使用 XML Schema 语法来定义数据类型,这里可以定义一些Schema不支持的类型-->
<types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="目标命名空间(WSDL所在地址)">
</xsd:schema>
</types> <!--
<message> 元素可定义每个消息的部件,以及相关联的数据类型。
请求-响应是最普通的操作类型,不过 WSDL 定义了四种类型:
One-way 此操作可接受消息,但不会返回响应。
Request-response 此操作可接受一个请求并会返回一个响应。(常用)
Solicit-response 此操作可发送一个请求,并会等待一个响应。
Notification 此操作可发送一条消息,但不会等待响应。
-->
<message name='请求消息名称(方法名+Request)'>
<part name="term" type="xsd:string"/>
</message> <message name='响应消息名称(方法名+Response)'>
<part name="value" type="xsd:string"/>
</message> <!--
<portType> 元素是最重要的 WSDL 元素。它可描述一个 web service、可被执行的操作,以及相关的消息。
它告诉你去哪个WebService的连接点,扮演了一个控制者。
-->
<portType name='执行的操作名称(binding的type与其对应)'>
<operation name='执行操作的方法'>
<input message='tns:*Request'/>
<output message='tns:*response'/>
</operation>
</portType> <!--<binding> 元素为每个端口定义消息格式和协议细节-->
<binding name='Binding的名称,与service的port名称对应' type='指向用于Binding的端口(tns(前缀):PortType名称)'>
<!--style:属性可取值 "rpc" 或 "document",ransport:属性定义了要使用的 SOAP 协议。在这个例子中我们使用 HTTP-->
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
<!--operation 元素定义了每个端口提供的操作符,对于每个操作,相应的 SOAP 行为都需要被定义-->
<operation name='GetCallDetailRecords'>
<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>包含一个或者多个port元素,每个port元素表示一个不同的Web服务-->
<service name='服务名称'>
<port name='Binding名称' binding='tns:Binding名称'>
<soap:address location='http://目标命名空间(WSDL所在地址)/service.php'/>
</port>
</service>
</definitions>

  2、在service目录下建立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/">
</xsd:schema>
</types> <message name='GetPhoneBookRequest'>
<part name="name" type="xsd:string"/>
</message> <message name='GetPhoneBookResponse'>
<part name="phonebookInfo" type="xsd:string"/>
</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>

  3、修改service.php

<?php
function GetPhoneBook($name){
$pbook="Zhangsan,13888888888,friend,8888@163.com";
return $pbook;
}
$server = new SoapServer("myphone.wsdl");
$server->addFunction("GetPhoneBook");
$server->handle ();
?>

  4.修改client.php

<?php
header('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());
}
?>

实例下载地址:https://files.cnblogs.com/files/weiyiyong/wsdl.rar  

本文参考:https://blog.csdn.net/rrr4578/article/details/24451943

soap 简单调用其他系统的函数的更多相关文章

  1. 使用Excel调用ABAP系统的函数

    效果:在excel里创建一个按钮,开发一些VB script,可以连接指定的ABAP系统并执行系统里的ABAP function module. 在这里例子里执行ABAP系统的函数TH_USER_LI ...

  2. 描述了say_hello函数的具体内容,调用zend_printf系统函数在php中打印字符串

    下载一个php的源代码包,这里使用的是php 4.0.5版,解压后会看到php的根目录下会有README.EXT_SKEL这样一个文件,打开详细阅读了一下,发现了一个非常好用的工具,这个工具可以帮你构 ...

  3. mfc 调用Windows的API函数实现同步异步串口通信(源码)

    在工业控制中,工控机(一般都基于Windows平台)经常需要与智能仪表通过串口进行通信.串口通信方便易行,应用广泛. 一般情况下,工控机和各智能仪表通过RS485总线进行通信.RS485的通信方式是半 ...

  4. Linux内核设计第三周——构造一个简单的Linux系统

    Linux内核设计第三周 ——构造一个简单的Linux系统 一.知识点总结 计算机三个法宝: 存储程序计算机 函数调用堆栈 中断 操作系统两把宝剑: 中断上下文的切换 进程上下文的切换 linux内核 ...

  5. 《Linux内核分析》第三周 构建一个简单的Linux系统MenuOS

    [刘蔚然 原创作品转载请注明出处 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000] WEEK THREE ...

  6. 第三节 构造一个简单的Linux系统MenuOS——20135203齐岳

    第三节 构造一个简单的Linux系统MenuOS By 20135203齐岳 Linux内核源代码 arch/ 支持不同cpu的源代码 Documentations/ 文档存储 init/ 内核启动相 ...

  7. Linux内核分析第三周学习总结:构造一个简单的Linux系统MenuOS

    韩玉琪 + 原创作品转载请注明出处 + <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 一.Linux内 ...

  8. 在C++中调用DLL中的函数 (2)

    应用程序使用DLL可以采用两种方式: 一种是隐式链接,另一种是显式链接.在使用DLL之前首先要知道DLL中函数的结构信息. Visual C++6.0在VC\bin目录下提供了一个名为Dumpbin. ...

  9. JAVA_用_JCO连接_SAP,实现调用SAP_的_RFC_函数(整理)(附一篇看起来比较全面的说明)(JCO报错信息)

    // 获取RFC返回的字段值 11 JCoParameterList exportParam = function.getExportParameterList(); 12 String exPara ...

随机推荐

  1. WPF TextBlock文子超出在最后加上省略号

    加上这个属性:TextTrimming="CharacterEllipsis" <TextBlock Text="{Binding filepaths}" ...

  2. ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot exe

    在Mysql集群中创建用户时.出现如下错误! mysql> create user 'testuse'@'localhost' identified by '111111'; ERROR 129 ...

  3. jquery mobile开发中页面跳转后js不执行的问题

    为了实现在移动设备上的无缝客户体验,jQueryMobile默认采用AJAX的方式载入一个目的链接页面.因此,当在浏览器中点击一个链接打一个新的页面时,jQueryMobile接收这个链接,通过AJA ...

  4. C# sqlserver winform

    //public static readonly string LocalSqlServer = System.Configuration.ConfigurationManager.AppSettin ...

  5. FreeMarker的空值运算符和逻辑运算符

    1.空值处理运算符 如果你在模板中使用了变量但是在代码中没有对变量赋值,那么运行生成时会抛出异常.但是有些时候,有的变量确实是null,怎么解决这个问题呢? 判断某变量是否存在:“??” 用法为:va ...

  6. web前端基本开发手册

    --------------------------------- 一.概况 1.1  WEB 标准 二.实现WEB标准 2.1  XHTML.CSS介绍 2.2  XHTML书写规范 2.2.1 X ...

  7. 2.HTML+CSS制作一闪一闪亮晶晶的星星(stars)

    效果地址:https://codepen.io/flyingliao/pen/NJxbdB?editors=1100 HTML code: <div class="stars" ...

  8. for循环、in、not in

    for循环可以遍历集合中任意一个元素 1 a = ["hello", "world", "dlrb"] 2 for b in a: 3 pr ...

  9. Spring注解之 Transactional

    @Transcational 用于事务回滚 @Transcational属性如下: 属性 类型 描述 value String 可选的限定描述符,制定使用的事务管理器 propogation enum ...

  10. Kubernetes的ConfigMap说明

    这篇博文,我们来说一说,关于在kubernetes的pod中自定义配置的问题. 我们知道,在几乎所有的应用开发中,都会涉及到配置文件的变更,比如说在web的程序中,需要连接数据库,缓存甚至是队列等等. ...