WSDL

以前做项目时梳理的WDSL基础,原本记录在老博客上,现在迁移过来,参考在线W3CSchool。

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

1. WSDL 文档

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

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

实例如下:

View Code
<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绑定提供消息格式和协议细节,如下:

View Code
 <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>

在myeclipse 8.6下利用JAX-WS发布web service服务

A. 服务端建立一个web service工程;

B. 建立一个客户端工程,并导入WSDL;工程中会自动生成相应的代理类;

C.客户端通过调用代理类完成对web service的调用:

SayHelloService sv = new SayHelloService();
SayHelloDelegate dl = sv.getSayHelloPort();

 

 

 

posted @ 2013-04-02 21:16  Fredric_2013  阅读(297)  评论(0编辑  收藏  举报