WSDL笔记

参考W3C在线教程

wsdl (web service description language):web服务描述语言

1. wsdl文档

wsdl文档主要通过下面这些主要元素描述某个webservice:

  • <portType> web service执行的操作
  • <message>  web service使用的消息
  • <types>       web service使用的数据类型
  • <binding>    web service使用的通信协议

例如:

<wsdl:portType name="TraditionalSimplifiedWebServiceSoap">
<wsdl:operation name="toSimplifiedChinese">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<br /><h3>繁体字转换为简体字</h3><p>输入参数:sText = 字符串; 返回数据:字符串。
</p><br /></wsdl:documentation>
  <wsdl:input message="tns:toSimplifiedChineseSoapIn" />
  <wsdl:output message="tns:toSimplifiedChineseSoapOut" />
  </wsdl:operation>
<wsdl:operation name="toTraditionalChinese">
  <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<br /><h3>简体字转换为繁体字</h3><p>输入参数:sText = 字符串; 返回数据:字符串。
</p><br /></wsdl:documentation>
  <wsdl:input message="tns:toTraditionalChineseSoapIn" />
  <wsdl:output message="tns:toTraditionalChineseSoapOut" />
  </wsdl:operation>
  </wsdl:portType>

2. wsdl端口

wsdl端口描述一个web service可被执行的操作,也就是业务功能。

wsdl端口具备四种操作类型:

  • One-way:此操作接受消息,但不返回相应;
  • Request-response:此操作接受消息,并返回一个相应;
  • Solicit-response:此操作可发送一个请求,并等待返回一个相应;
  • Notification:此操作可发送一条消息,但不接收相应;
3. wsdl绑定

wsdl 绑定为web service提供消息格式和协议细节,例如:

- <wsdl:binding name="TraditionalSimplifiedWebServiceSoap12" type="tns:TraditionalSimplifiedWebServiceSoap">

  <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="toSimplifiedChinese">
  <soap12:operation soapAction="http://webxml.com.cn/toSimplifiedChinese" style="document" />
- <wsdl:input>
  <soap12:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap12:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
- <wsdl:operation name="toTraditionalChinese">
  <soap12:operation soapAction="http://webxml.com.cn/toTraditionalChinese" style="document" />
- <wsdl:input>
  <soap12:body use="literal" />
  </wsdl:input>
- <wsdl:output>
  <soap12:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>

总结:

本质上web service是一种异构的远程调用机制,通过soap(http+xml)的通信机制实现调用。

wsdl则描述了这种功能,就像是c语言的头文件申明了函数,知道函数体是什么、入参和出参又是什么。

仅此而已。。


原文地址:https://www.cnblogs.com/fredric/p/2378366.html