WSDL 2.0文檔示例

以下是以XML格式表示WSDL 2.0 文檔的簡單示例,文件:hello_wsdl_20_soap.wsdl 的內容如下 -

<?xml version="1.0"?> 
<wsdl:description xmlns:wsdl="http://www.w3.org/ns/wsdl"
  xmlns:wsoap= "http://www.w3.org/ns/wsdl/soap"
  xmlns:hy="http://www.herongyang.com/Service/"
  targetNamespace="http://www.herongyang.com/Service/">

  <wsdl:documentation>
    Hello_WSDL_20_SOAP.wsdl
    Copyright (c) 2009 HerongYang.com, All Rights Reserved.
  </wsdl:documentation>

  <wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.yiibai.com/service/">
      <xsd:element name="Hello" type="xsd:string"/>    
      <xsd:element name="HelloResponse" type="xsd:string"/>    
    </xsd:schema>    
  </wsdl:types>

  <wsdl:interface name="helloInterface" >
    <wsdl:operation name="Hello" 
      pattern="http://www.w3.org/ns/wsdl/in-out" 
      style="http://www.w3.org/ns/wsdl/style/iri">
      <wsdl:input messageLabel="In" 
        element="hy:Hello" />
      <wsdl:output messageLabel="Out" 
        element="hy:HelloResponse" />
    </wsdl:operation>
  </wsdl:interface>

  <wsdl:binding name="helloBinding" 
    interface="hy:helloInterface"
    type="http://www.w3.org/ns/wsdl/soap"
    wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">
    <wsdl:operation ref="hy:Hello" 
      wsoap:mep="http://www.w3.org/2003/05/soap/mep/soap-response"/>
  </wsdl:binding>

  <wsdl:service name="helloService" 
    interface="hy:helloInterface">
    <wsdl:endpoint name="helloEndpoint" 
      binding="hy:helloBinding"
address="http://www.yiibai.com/service/hello_soap_12.php"/>
  </wsdl:service>

</wsdl:description>

在這個WSDL 2.0示例文檔中,

  • Web服務helloService使用端點helloEndpoint定義,它的訪問地址是:http://www.yiibai.com/service/hello\_soap\_12.php
  • 端點helloEndpoint鏈接到綁定helloBinding
  • 綁定helloBinding是通過HTTP上的SOAP 1.2通信協議定義的。
  • 綁定helloBinding鏈接到接口helloInterface
  • 接口helloInterface由一個操作Hello定義的,該操作需要輸入消息元素和輸出消息元素。
  • 每個元素Hello/HelloResponse都由Types部分中包含的XML模式定義。