WSDL

来源:互联网 发布:each遍历json对象二重 编辑:程序博客网 时间:2024/05/17 03:30

http://www.w3schools.com/wsdl/default.asp


WSDL (Web Services Description Language) is an XML-based language for describing Web services and how to access them.

WSDL is an XML document.  WSDL is used to describe Web services.  WSDL is also used to locate Web services.

It specifies the location of the service and the operations (or methods) the service exposes.

对于WSDL而言,它描述了相对它自己是本地的服务,以及服务暴露出来的operations或方法。


A WSDL document describes a web service using these major elements:

ElementDefines<types>The data types used by the web service<message>The messages used by the web service<portType>The operations performed by the web service<binding>The communication protocols used by the web service

除此以外,WSDL还可以包含一些扩展element。例如如何将多个web service的定义整个到一个WDSL中来。


<portType> element是最重要的WSDL element。它描述了这个web service可以做哪些操纵,以及这些操纵需要的输入参数(其实就是message)。

operation是用程序语言写成的,由web services暴露出来的,希望其他程序能够使用的功能。

<message> 在下面例子中我们将看到,message是operation的输入参数。


    <wsdl:portType name="ASAP"> //定义ASAP为port的名字
        <wsdl:operation name="GetUsers"> //一个叫GetUsers的operation
            <wsdl:documentation>
                <OperationSummary>GetUsers</OperationSummary>
                <InputParamters/>
            </wsdl:documentation>
            <wsdl:input wsaw:Action="http://ASAP.services.tfn.thomson.com/2010-03-01/GetUsers" name="GetUsersRequestMessage_V1"message="tns:GetUsersRequestMessage_V1"/>//这个GetUsers operation的输入参数就是这个message
            <wsdl:output wsaw:Action="http://ASAP.services.tfn.thomson.com/2010-03-01/ASAP/GetUsersResponse" name="GetUsersResponseMessage_V1"message="tns:GetUsersResponseMessage_V1"/>

//这个operation的response就是这个message
        </wsdl:operation>
    </wsdl:portType>

注意上面这两个message必须在前面的<message>中已经定义了。

<wsdl:message name="GetUsersRequestMessage_V1">
        <wsdl:part name="parameters" element="q3:GetUsersRequest" xmlns:q3="http://asap.schemas.tfn.thomsonreuters.com/Messages/Base/2010-03-01/"/>
    </wsdl:message>

The <types> element defines the data types that are used by the web service.

既然message是输入参数和输出结果,那么必然需要定义这些参数的数据类型。types element就是定义需要的数据类型,供message使用。

这里说的数据类型,不是指string,int这样的类型。而是定义的message的结构。查看type节点后就可以发现,其实它是import了很多XSD,也就是XML Schema。

The <binding> element defines the message format and protocol details for each port.


由此我们就得出了一个完整的逻辑链条:

web services暴露出来的功能就是operation。如果想使用这些功能,就需要向web services发送指定的message。

我们向web services发送的SOAP request 和SOAP response 就是上文的message。且message的结构也是web services规定好的。

message的结构是由type element中对应的XSD决定的。


A WSDL port describes the interfaces (legal operations) exposed by a web service.

The port defines the connection point to a web service. It can be compared to a function library (or a module, or a class) in a traditional programming language. Each operation can be compared to a function in a traditional programming language.

这里有几种不同的operation type。

最常见的就是reuqest-response。例如在上例的operation中,即由input也有output。这就是即有请求也有返回。

如果只有input,没有output,就是one-way operation。这就相当于那些只有输入,没有输出的函数。

Solicit-response operation是那种发送request后,需要等待response的方法。具体实现方法请参看更详细的资料。

最后一部分是Binding:

<wsdl:service name="ASAP">
        <wsdl:port name="Custom_UUID_ASAPService_V1" binding="i0:Custom_UUID_ASAPService_V1">
            <wsdl:documentation>
                <EndpointDescription/>
            </wsdl:documentation>
            <soap:address location="http://hpdq-paldljm03.dcmc-three.hpd.reuqaint.com/ASAPService/ASAPService_V1.svc"/>
        </wsdl:port>
    </wsdl:service>


Network services are described as a set of endpoints which operate on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services).

WSDL is extensible to allow description of endpoints and their messages regardless of what message formats or network protocols are used to communicate; typical bindings might be to SOAP 1.1, HTTP GET/POST, and MIME.

A WSDL endpoint is the http address for a service e.g http://example.com:18080/accountservice.













原创粉丝点击