WSDL - <service> 元素



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

  • Web 服务客户端可以从 service 元素中了解以下信息:

    • 访问服务的位置
    • 访问 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>
广告