WSDL 中各个元素标签详解

<?xml version="1.0" encoding="UTF-8" ?>

<wsdl:definitions
targetNamespace=“http://com.liuxiang.xfireDemo/HelloService
xmlns:tns=“http://com.liuxiang.xfireDemo/HelloService
xmlns:wsdlsoap=“http://schemas.xmlsoap.org/wsdl/soap/
xmlns:soap12=“http://www.w3.org/2003/05/soap-envelope
xmlns:xsd=“http://www.w3.org/2001/XMLSchema
xmlns:soapenc11=“http://schemas.xmlsoap.org/soap/encoding/
xmlns:soapenc12=“http://www.w3.org/2003/05/soap-encoding
xmlns:soap11=“http://schemas.xmlsoap.org/soap/envelope/
xmlns:wsdl=“http://schemas.xmlsoap.org/wsdl/”>

<-- 整体的依赖关系是从下到上的一个过程 --> types: 定义数据类型 使用xml 中 schema约束来定义 整体: public String sayHello(String name) 接口 请求: String 传入参数:String类型 响应: String 返回类型String -->

           <wsdl:types>    
          <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"       
             attributeFormDefault="qualified" elementFormDefault="qualified"       
            targetNamespace="http://com.liuxiang.xfireDemo/HelloService">
       <xsd:element name="sayHello">
      <xsd:complexType>
        <xsd:sequence>
            <xsd:element maxOccurs="1" minOccurs="1" name="name" 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=“return” nillable=“true” type=“xsd:string” />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>

<-- message:使用types定义的类型,来定义整个消息的数据结构 part(组成): 指定引用types中的标签片段 message个数是接口的俩倍,一个接口对应一个请求和一个响应消息 -->

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

portType: 用来定义服务器端的SEI(接口) HelloServicePortType即:service层的接口名 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: 用于定义SEI的实现类 type:中tns引用portType标签,来找到他自己实现类的接口 operation:具体实现类中方法的操作 body:它请求和返回来的消息,会以文本(literal)的形式展现 绑定的数据是一个document(xml) input:指定客户端传过来的数据(参数) output:指定服务器端返回给客户端的数据 -->

<wsdl:binding name="HelloServiceHttpBinding" type="tns:HelloServicePortType">
   <wsdl soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
    <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: 服务器端的一个webService容器,(亦或者为一个工厂) ,来发布web服务 name: 用来指定客户端容器类(客户端的类从这里开始) port:用来指定一个服务器端处理请求的入口(SEI的实现类) address:当前webService的请求地址 -->

<wsdl:service name=“HelloService”>
<wsdl:port name=“HelloServiceHttpPort” binding=“tns:HelloServiceHttpBinding”>
<wsdlsoap:address location=“http://localhost:8080/xfire/services/HelloService” />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

猜你喜欢

转载自blog.csdn.net/weixin_43028416/article/details/88418147