当前位置: 首页 > 教程 > WSDL >

WSDL <service>元素

精华
小牛编辑
114浏览
2023-03-14

WSDL <service>元素定义Web服务支持的端口。 对于每个支持的协议,都有一个<port>元素。 service元素是端口的集合。

  • Web服务客户端可以从服务元素中学习以下内容 -
    • 在哪里访问该服务?
    • 通过哪个端口访问Web服务?
    • 如何定义通信消息?
  • service元素包含一个文档元素,用于提供人类可读的文档。

下面是示例章节中的一段代码 -

<service name = "Hello_Service">
   <documentation>WSDL File for HelloService</documentation>
   <port binding = "tns:Hello_Binding" name = "Hello_Port">
      <soap:address
         location = "http://www.examples.com/SayHello/">
   </port>
</service>

port元素的绑定属性将服务的地址与Web服务中定义的绑定元素相关联。 在这个例子中,它绑定的是Hello_Binding

<binding name =" Hello_Binding" type = "tns:Hello_PortType">
   <soap:binding style = "rpc"
      transport = "http://schemas.xmlsoap.org/soap/http"/>
   <operation name = "sayHello">
      <soap:operation soapAction = "sayHello"/>

      <input>
         <soap:body
            encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
            namespace = "urn:examples:helloservice" use = "encoded"/>
      </input>

      <output>
         <soap:body
            encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
            namespace = "urn:examples:helloservice" use = "encoded"/>
      </output>
   </operation>
</binding>