你的位置:首页 > 软件开发 > Java > 一个完整的WSDL文档及各标签详解

一个完整的WSDL文档及各标签详解

发布时间:2016-02-28 12:00:19
<?<wsdl:definitions targetNamespace="http://www.57market.com.cn/HelloService" http://www.w3.org/2003/05/soapencoding" h ...

<?

<wsdl:definitions targetNamespace="http://www.57market.com.cn/HelloService" http://www.w3.org/2003/05/soapencoding" http://www.57market.com.cn/HelloService" http://schemas." http://www.w3.org/2001/" http://schemas." http://schemas." http://schemas." http://www.w3.org/2003/05/soapenvelope">

 

/**

 * type元素,定义了交换信息的数据格式。

 * 为了实现最大的互操作性(interoperability)和平台中立性(neutrality),WSDL选用

 * 简称XSD作为标准类型系统,并将它作为固有类型系统。

 * 下面是数据定义部分,该部分定义了两个元素,一个是sayHello,一个是sayHelloResponse:

 * sayHello:定义了一个复杂类型,仅仅包含一个简单的字符串,将来用来描述操作的参入传入部分;

 * sayHelloResponse:定义了一个复杂类型,仅仅包含一个简单的字符串,将来用来描述操作的返回值;

 */

<wsdl:types>

<xsd:schema http://www.w3.org/2001/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.57market.com.cn/HelloService">

       

       <xsd:element name="sayHello">

  <xsd:complexType>

<xsd:sequence>

  <xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />

  </xsd:sequence>

  </xsd:complexType>

</xsd:element>

 

<xsd:element name="sayHelloResponse">

<xsd:complexType>

 <xsd:sequence>

  <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string" />

  </xsd:sequence>

     </xsd:complexType>

  </xsd:element>

 

  </xsd:schema>

  </wsdl:types>

 

/**

 * message元素指定

 * 该部分是信息格式的抽象定义:定义了两个消息sayHelloResponse和sayHelloRequest:

 * sayHelloRequest:sayHello操作的请求消息格式,由一个消息片断组成,名字为parameters,

 * 元素是我们前面定义的 types中的元素;

 * sayHelloResponse:sayHello操作的响应消息格式,由一个消息片断组成,名字为parameters,

 * 元素是我们前面定义 *的types中的元素;

 * 如果采用RPC样式的消息传递,只需要将文档中的element元素应以修改为type即可。

*message:用來定義消息的結構

*part:指定引用types中定義的標籤片斷

 */

<wsdl:message name="sayHelloRequest">

     <wsdl:part name="parameters" element="tns:sayHello" />

 </wsdl:message>

 

<wsdl:message name="sayHelloResponse">

     <wsdl:part name="parameters" element="tns:sayHelloResponse" />

 </wsdl:message>

 

/**

 * portType元素中定义了Web服务的操作。操作定义了输入和输出数据流中可以出现的

 * 一些抽象操作的集合。每个操作关联一个输入消息和一个输出消息。

 * portType定义了服务的调用模式的类型,这里包含一个操作sayHello方法,同时包含input和output表明

 * 该操作是一个 请求/响应模式,请求消息是前面定义的sayHelloRequest,

 * 响应消息是前面定义的 sayHelloResponse。input表示传递到Web服务的有效负载,

 * output消息表示传递给客户的有效负载。

*portType:用來定義服務端的SEI

*operation:用來指定SEI中的處理請求的方法

*input:指定客戶端應用傳過來的數據,會引用上面的而定義的<message>

*output:指定服務端返回給客戶端的數據,會引用上面的而定義的<message>

 */

<wsdl:portType name="HelloServicePortType">

<wsdl:operation name="sayHello">

  <wsdl:input name="sayHelloRequest" message="tns:sayHelloRequest" />

  <wsdl:output name="sayHelloResponse" message="tns:sayHelloResponse" />

  </wsdl:operation>

  </wsdl:portType>

 

/**

 * binding 元素描述特定服务接口的协议、数据格式、安全性和其它属性。

 * 针对操作和portType中使用的消息指定实际的协议和数据格式规范。

*binding:用於定義SEI的實現類

*type屬性:引用上面的<portType>

*<soap:operation /> 綁定的數據是一個document(

*operation:用來定義實現的方法

*<soap:operation /> 傳輸的是document(

*input:指定客戶端應用傳過來的數據

*<soap:body use="literal" />:文本數據

*output:指定服務器端返回客戶端的數據

*<soap:body use="literal"/>:文本數據

 */

<wsdl:binding name="HelloServiceHttpBinding" type="tns:HelloServicePortType">

 

  <wsdlsoap:binding transport="http://schemas." />

<wsdl:operation name="sayHello">

  <wsdlsoap:operation soapAction="" />

<wsdl:input name="sayHelloRequest">

  <wsdlsoap:body use="literal" />

  </wsdl:input>

<wsdl:output name="sayHelloResponse">

  <wsdlsoap:body use="literal" />

  </wsdl:output>

  </wsdl:operation>

 

</wsdl:binding>

 

 

/**

 * service元素。服务元素包含一组port元素。端口将端点与来自服务接口定义的binding 元素关联起来。

 * port指定一个绑定的地址,这样定义一个通信的终端。

 *service:一個webservice的容器

 *name:屬性:它用以指定一個服務器端處理請求的入口(就是SEI的實現)

 * binding屬性:引用上面定義的<binding>

 *address:當前webservice的請求地址

 */

<wsdl:service name="HelloService">

      <wsdl:port name="HelloServiceHttpPort"binding="tns:HelloServiceHttpBinding">

    <soap:address location="http://localhost:8080/xfire/services/HelloService" />

  </wsdl:port>

 </wsdl:service>

 

</wsdl:definitions>

 


原标题:一个完整的WSDL文档及各标签详解

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录