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.jb51.cc/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.jb51.cc/service/hello_soap_12.php/>
  </wsdl:service>

</wsdl:description>

在这个WSDL 2.0示例文档中,

  • Web服务helloService使用端点helloEndpoint定义,它的访问地址是:http://www.jb51.cc/service/hello_soap_12.php
  • 端点helloEndpoint链接到绑定helloBinding
  • 绑定helloBinding是通过HTTP上的SOAP 1.2通信协议定义的。
  • 绑定helloBinding链接到接口helloInterface
  • 接口helloInterface由一个操作Hello定义的,该操作需要输入消息元素和输出消息元素。
  • 每个元素Hello/HelloResponse都由Types部分中包含的XML模式定义。