<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-128  評(píng)論-55  文章-5  trackbacks-0

     

     

    WSDL樣式詳解

    Web 服務(wù)是通過WSDL文檔來描述的。WSDL綁定描述了如何把服務(wù)綁定到消息傳遞協(xié)議(特別是SOAP消息傳遞協(xié)議)。WSDL SOAP綁定style描述了服務(wù)調(diào)用方式,即遠(yuǎn)程過程調(diào)用rpc (Remote Procedure Call)方式或文檔document方式。use定義了類型是編碼encoded 方式還是文字literal方式。

    創(chuàng)建綁定時(shí),可以選擇 document 樣式或 rpc樣式。二者均具有自己的優(yōu)點(diǎn)和缺點(diǎn)。使用 rpc樣式時(shí),要執(zhí)行的方法的名稱同時(shí)也是有效負(fù)載的根元素的名稱。

    WSDL調(diào)用服務(wù)提供了6種樣式:

    1rpc/encoded

    2rpc/literal

    3document /encoded

    4document /literal

    5document/literal/wrapped

    6document/encoded/wrapped

     

    1.       rpc/encoded樣式

    SOAP消息定義實(shí)際類型信息。

    WSDL 文檔樣例:

    <wsdl:types>

     <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

             targetNamespace="http://org.apache.axis2/xsd"

             elementFormDefault="unqualified"

             attributeFormDefault="unqualified">

    ...

     </xs:schema>

    </wsdl:types>

    <wsdl:message name="createNewAdRequest">

     <wsdl:part name="content" type="xsd:string" />

     <wsdl:part name="endDate" type="xsd:string" />

    </wsdl:message>

    ...

    <wsdl:portType name="ClassifiedServicePortType">

     <wsdl:operation name="createNewAd">

        <wsdl:input message="tns:createNewAdRequest" />

        <wsdl:output message="tns:createNewAdResponse" />

     </wsdl:operation>

    ...

    </wsdl:portType>

    <wsdl:binding name="ClassifiedServiceBinding"

     type="tns:ClassifiedServicePortType">

     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />

     <wsdl:operation name="createNewAd">

        <soap:operation soapAction="createNewAd" style="rpc"/>

        <wsdl:input>

          <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"

     namespace="http://ws.apache.org/axis2"/>

        </wsdl:input>

        <wsdl:output>

          <soap:body use="literal" namespace="http://ws.apache.org/axis2" />

        </wsdl:output>

     </wsdl:operation>

    ...

    </wsdl:binding>

    ...

    SOAP請(qǐng)求報(bào)文樣例:

    <env:Envelope  xmlns:env="http://schemas.xmlSOAP.org/SOAP/envelope/"

           xmlns:xsd="http://www.w3.org/2001/XMLSchema"

           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <env:Body>

         <req: createNewAd  xmlns:req="http://daily-moon.com/classifieds/">

             <req:content xsi:type="xs:string">Vintage 1963 T-Bird...</req:content>

             <req:endDate xsi:type="xs:string">4/30/07</req:endDate>

         </req: createNewAd >

       </env:Body>

    </env:Envelope>

    優(yōu)點(diǎn):

    l        WSDL 基本達(dá)到了盡可能地簡單易懂的要求。

    l        操作名出現(xiàn)在消息中,這樣接收者就可以很輕松地把消息發(fā)送到方法的實(shí)現(xiàn)。

    缺點(diǎn):

    l        類型編碼信息(比如 xsi:type="xsd:int" )通常就是降低吞吐量性能的開銷。

    l        不能簡單地檢驗(yàn)此消息的有效性,因?yàn)橹挥?/span> <req:content xsi:type="xs:string">Vintage 1963 T-Bird...</req:content> 行包含在 Schema 中定義的內(nèi)容;其余的 soap:body 內(nèi)容都來自 WSDL 定義。

    2.       rpc/literal樣式

    WSDL樣例:

    ...

    <wsdl:types>

     <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

             targetNamespace="http://org.apache.axis2/xsd"

             elementFormDefault="unqualified"

             attributeFormDefault="unqualified">

    ...

     </xs:schema>

    </wsdl:types>

    <wsdl:message name="createNewAdRequest">

     <wsdl:part name="content" type="xsd:string"/>

     <wsdl:part name="endDate "type="xsd:string"/>

    </wsdl:message>

    ...

    <wsdl:portType name="ClassifiedServicePortType">

     <wsdl:operation name="createNewAd">

        <wsdl:input message="tns:createNewAdRequest" />

        <wsdl:output message="tns:createNewAdResponseMessage" />

     </wsdl:operation>

    ...

    </wsdl:portType>

    ...

    <wsdl:binding name="ClassifiedServiceBinding" type="tns:ClassifiedServicePortType">

     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />

     <wsdl:operation name="createNewAd">

        <soap:operation soapAction="createNewAd" style="rpc"/>

        <wsdl:input>

          <soap:body use="literal" namespace="http://ws.apache.org/axis2"/>

        </wsdl:input>

        <wsdl:output>

          <soap:body use="literal" namespace="http://ws.apache.org/axis2" />

        </wsdl:output>

     </wsdl:operation>

    ...

    </wsdl:binding>

    ...

    SOAP請(qǐng)求報(bào)文樣例:

    <env:Envelope

           xmlns:env="http://schemas.xmlSOAP.org/SOAP/envelope/"

           xmlns:xsd="http://www.w3.org/2001/XMLSchema"

           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <env:Body>

        <req: createNewAd  xmlns:req="http://daily-moon.com/classifieds/">

           <req:content>Vintage 1963 T-Bird</req:content>

           <req:endDate>4/30/2007</req:endDate>

        </req: createNewAd >

      </env:Body>

    </env:Envelope>

    優(yōu)點(diǎn):

    l        WSDL 還是基本達(dá)到了盡可能地簡單易懂的要求。

    l        操作名仍然出現(xiàn)在消息中。

    l        去掉了類型編碼。

    缺點(diǎn):

    l        仍然不能簡單地檢驗(yàn)此消息的有效性。因?yàn)橹挥?/span> < req:content > <req:endDate>行中包含定義在 Schema 中的內(nèi)容;soap:body 內(nèi)容的其余部分來自于 WSDL 定義。

    3.       document/encoded樣式

    此種方式很少使用。

    WSDL樣例:

    ...

    <wsdl:types>

     <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

             targetNamespace="http://org.apache.axis2/xsd"

             elementFormDefault="unqualified"

             attributeFormDefault="unqualified">

    ...

        <xs:element type="xs:string" name="content" />

        <xs:element type="xs:string" name="endDate" />

    ...

     </xs:schema>

    </wsdl:types>

    <wsdl:message name="createNewAdRequestMessage">

     <wsdl:part name="part1" element="ns1:content" />

     <wsdl:part name="part2" element="ns1:endDate" />

    </wsdl:message>

    ...

    <wsdl:portType name="ClassifiedServicePortType">

     <wsdl:operation name="createNewAd">

        <wsdl:input message="tns:createNewAdRequestMessage" />

        <wsdl:output message="tns:createNewAdResponseMessage" />

     </wsdl:operation>

    ...

    </wsdl:portType>

    ...

    <wsdl:binding name="ClassifiedServiceBinding" type="tns:ClassifiedServicePortType">

     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />

     <wsdl:operation name="createNewAd">

        <soap:operation soapAction="createNewAd" style="document" />

        <wsdl:input>

          <soap:body use="encoded" />

        </wsdl:input>

        <wsdl:output>

          <soap:body use=" encoded" />

        </wsdl:output>

     </wsdl:operation>

    ...

    </wsdl:binding>

    SOAP請(qǐng)求報(bào)文樣例:

    <env:Envelope  xmlns:env="http://schemas.xmlSOAP.org/SOAP/envelope/"

           xmlns:xsd="http://www.w3.org/2001/XMLSchema"

           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <env:Body>

           <req:content xsi:type="xs:string">Vintage 1963 T-Bird</req:content>

           <req:endDate xsi:type="xs:string">4/30/07</req:endDate>

     </env:Body>

    </env:Envelope>

    4.       document/literal樣式

    WSDL樣例:

    ...

    <wsdl:types>

     <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

             targetNamespace="http://org.apache.axis2/xsd"

             elementFormDefault="unqualified"

             attributeFormDefault="unqualified">

    ...

        <xs:element type="xs:string" name="content" />

        <xs:element type="xs:string" name="endDate" />

    ...

     </xs:schema>

    </wsdl:types>

    <wsdl:message name="createNewAdRequestMessage">

     <wsdl:part name="part1" element="ns1:content" />

     <wsdl:part name="part2" element="ns1:endDate" />

    </wsdl:message>

    ...

    <wsdl:portType name="ClassifiedServicePortType">

     <wsdl:operation name="createNewAd">

        <wsdl:input message="tns:createNewAdRequestMessage" />

        <wsdl:output message="tns:createNewAdResponseMessage" />

     </wsdl:operation>

    ...

    </wsdl:portType>

    ...

    <wsdl:binding name="ClassifiedServiceBinding" type="tns:ClassifiedServicePortType">

     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />

     <wsdl:operation name="createNewAd">

        <soap:operation soapAction="createNewAd" style="document" />

        <wsdl:input>

          <soap:body use="literal" />

        </wsdl:input>

        <wsdl:output>

          <soap:body use="literal" />

        </wsdl:output>

     </wsdl:operation>

    ...

    </wsdl:binding>

    SOAP請(qǐng)求報(bào)文樣例:

    <env:Envelope

           xmlns:env="http://schemas.xmlSOAP.org/SOAP/envelope/"

           xmlns:xsd="http://www.w3.org/2001/XMLSchema"

           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <env:Body>

           <req:content>Vintage 1963 T-Bird...</req:content>

           <req:endDate>4/30/07</req:endDate>

    </env:Body>

    </env:Envelope>

    優(yōu)點(diǎn):

    l        沒有編碼信息

    l        可以在最后用任何 XML 檢驗(yàn)器檢驗(yàn)此消息的有效性。 soap:body中每項(xiàng)內(nèi)容都定義在 Schema 中。

    缺點(diǎn):

    l        SOAP 消息中缺少操作名。而如果沒有操作名,發(fā)送就可能比較困難,并且有時(shí)變得不可能。

    5.       document/literal/wrapped樣式

    WSDL樣例:

    ...

    <wsdl:types>

     <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

             targetNamespace="http://org.apache.axis2/xsd"

             elementFormDefault="unqualified"

             attributeFormDefault="unqualified">

    ...

        <xs:element name="createNewAdRequest">

          <xs:complexType>

            <xs:sequence>

              <xs:element type="xs:string" name="content" />

              <xs:element type="xs:string" name="endDate" />

            </xs:sequence>

          </xs:complexType>

        </xs:element>

    ...

     </xs:schema>

    </wsdl:types>

    <wsdl:message name="createNewAdRequestMessage">

     <wsdl:part name="part1" element="ns1:createNewAdRequest" />

    </wsdl:message>

    ...

    <wsdl:portType name="ClassifiedServicePortType">

     <wsdl:operation name="createNewAd">

        <wsdl:input message="tns:createNewAdRequestMessage" />

        <wsdl:output message="tns:createNewAdResponseMessage" />

     </wsdl:operation>

    ...

    </wsdl:portType>

    ...

    <wsdl:binding name="ClassifiedServiceBinding" type="tns:ClassifiedServicePortType">

     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />

     <wsdl:operation name="createNewAd">

        <soap:operation soapAction="createNewAd" style="document"/>

        <wsdl:input>

          <soap:body use="literal" namespace="http://ws.apache.org/axis2" />

        </wsdl:input>

        <wsdl:output>

          <soap:body use="literal" namespace="http://ws.apache.org/axis2" />

        </wsdl:output>

     </wsdl:operation>

    ...

    </wsdl:binding>

    ...

    SOAP請(qǐng)求報(bào)文樣例:

    <env:Envelope  xmlns:env="http://schemas.xmlSOAP.org/SOAP/envelope/"

           xmlns:xsd="http://www.w3.org/2001/XMLSchema"

           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <env:Body>

        <req:createNewAdRequest  xmlns:req="http://daily-moon.com/classifieds/">

             <req:content>Vintage 1963 T-Bird...</req:content>

             <req:endDate>4/30/07</req:endDate>

         </req:createNewAdRequest>

      </env:Body>

    </env:Envelope>

    注意此時(shí)SOAP Body中第一個(gè)元素的名稱并不是操作的名稱,而是Schema中的元素的名稱。此時(shí)Schema中的元素的名稱可以與操作名相同,也可以不同。如果取相同則是一種將操作名放入SOAP消息的巧妙方式。

    SOAP 消息看起來非常類似于 RPC/literal SOAP 消息。您可能會(huì)說,它看起來與 RPC/literal SOAP 消息是完全一樣的,不過,這兩種消息之間存在著微妙的區(qū)別。在 RPC/literal SOAP 消息中, <soap:body> 下的< req:createNewAd> 根元素是操作的名稱。在document/literal/wrapped SOAP 消息中, < req:createNewAdRequest > 子句是單個(gè)輸入消息的組成部分引用的元素的名稱。

    document/literal/wrapped樣式的特征有:

    l        輸入消息只有一個(gè)組成部分。

    l        該部分就是一個(gè)元素。

    l        該元素有與操作相同的名稱。

    l        該元素的復(fù)雜類型沒有屬性。

    優(yōu)點(diǎn):

    l        沒有編碼信息。

    l        出現(xiàn)在 soap:body 中的每項(xiàng)內(nèi)容都是由 Schema 定義的,可以很容易地檢驗(yàn)此消息的有效性。

    l        方法名又出現(xiàn)在 SOAP 消息中。

    缺點(diǎn):

    l        WSDL 較為復(fù)雜。

    6.       document/encoded/wrapped樣式

    此種方式很少使用

    WSDL樣例:

    ...

    <wsdl:types>

     <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

             targetNamespace="http://org.apache.axis2/xsd"

             elementFormDefault="unqualified"

             attributeFormDefault="unqualified">

    ...

        <xs:element name="createNewAdRequest">

          <xs:complexType>

            <xs:sequence>

              <xs:element type="xs:string" name="content" />

              <xs:element type="xs:string" name="endDate" />

            </xs:sequence>

          </xs:complexType>

        </xs:element>

    ...

     </xs:schema>

    </wsdl:types>

    <wsdl:message name="createNewAdRequestMessage">

     <wsdl:part name="part1" element="ns1:createNewAdRequest" />

    </wsdl:message>

    ...

    <wsdl:portType name="ClassifiedServicePortType">

     <wsdl:operation name="createNewAd">

       <wsdl:input message="tns:createNewAdRequestMessage" />

        <wsdl:output message="tns:createNewAdResponseMessage" />

     </wsdl:operation>

    ...

    </wsdl:portType>

    ...

    <wsdl:binding name="ClassifiedServiceBinding" type="tns:ClassifiedServicePortType">

     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />

     <wsdl:operation name="createNewAd">

        <soap:operation soapAction="createNewAd" style="document"/>

        <wsdl:input>

          <soap:body use="encoded" namespace="http://ws.apache.org/axis2" />

        </wsdl:input>

        <wsdl:output>

          <soap:body use="encoded" namespace="http://ws.apache.org/axis2" />

        </wsdl:output>

     </wsdl:operation>

    ...

    </wsdl:binding>

    ...

    SOAP請(qǐng)求報(bào)文樣例:

    <env:Envelope  xmlns:env="http://schemas.xmlSOAP.org/SOAP/envelope/"

           xmlns:xsd="http://www.w3.org/2001/XMLSchema"

           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

      <env:Body>

         <req:createNewAdRequest  xmlns:req="http://daily-moon.com/classifieds/">

             <req:content xsi:type="xs:string">Vintage 1963 T-Bird...</req:content>

             <req:endDate xsi:type="xs:string">4/30/07</req:endDate>

         </req:createNewAdRequest>

       </env:Body>

    </env:Envelope>

    附錄:WSDL1.1規(guī)范中的SOAP Binding 信息( 對(duì)其中關(guān)鍵部分進(jìn)行了中文翻譯 )

    SOAP Binding

    WSDL includes a binding for SOAP 1.1 endpoints, which supports the specification of the following protocol specific information:

    • An indication that a binding is bound to the SOAP 1.1 protocol
    • A way of specifying an address for a SOAP endpoint.
    • The URI for the SOAPAction HTTP header for the HTTP binding of SOAP
    • A list of definitions for Headers that are transmitted as part of the SOAP Envelope

    This binding grammar it is not an exhaustive specification since the set of SOAP bindings is evolving. Nothing precludes additional SOAP bindings to be derived from portions of this grammar. For example:

    • SOAP bindings that do not employ a URI addressing scheme may substitute another addressing scheme by replacing the soap:address element defined in section 3.8.
    • SOAP bindings that do not require a SOAPAction omit the soapAction attribute defined in section 3.4.

    3.1 SOAP Examples

    In the following example, a SubscribeToQuotes SOAP 1.1 one-way message is sent to a StockQuote service via a SMTP binding. The request takes a ticker symbol of type string, and includes a header defining the subscription URI.

    Example 3. SOAP binding of one-way operation over SMTP using a SOAP Header

    <?xml version="1.0"?>
    <definitions name="StockQuote"
              targetNamespace="http://example.com/stockquote.wsdl"
              xmlns:tns="http://example.com/stockquote.wsdl"
              xmlns:xsd1="http://example.com/stockquote.xsd"
              xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
              xmlns="http://schemas.xmlsoap.org/wsdl/">
     
        <message name="SubscribeToQuotes">
            <part name="body" element="xsd1:SubscribeToQuotes"/>
            <part name="subscribeheader" element="xsd1:SubscriptionHeader"/>
        </message>
     
        <portType name="StockQuotePortType">
            <operation name="SubscribeToQuotes">
               <input message="tns:SubscribeToQuotes"/>
            </operation>
        </portType>
     
        <binding name="StockQuoteSoap" type="tns:StockQuotePortType">
            <soap:binding style="document" transport="http://example.com/smtp"/>
            <operation name="SubscribeToQuotes">
               <input message="tns:SubscribeToQuotes">
                   <soap:body parts="body" use="literal"/>
                   <soap:header message="tns:SubscribeToQuotes" part="subscribeheader" use="literal"/>
               </input>
            </operation>
        </binding>
     
        <service name="StockQuoteService">
            <port name="StockQuotePort" binding="tns:StockQuoteSoap">
               <soap:address location="mailto:subscribe@example.com"/>
            </port>
        </service>
     
        <types>
            <schema targetNamespace="http://example.com/stockquote.xsd"
                   xmlns="http://www.w3.org/2000/10/XMLSchema">
               <element name="SubscribeToQuotes">
                   <complexType>
                       <all>
                           <element name="tickerSymbol" type="string"/>
                       </all>
                   </complexType>
               </element>
               <element name="SubscriptionHeader" type="uriReference"/>
            </schema>
        </types>
    </definitions>

    This example describes that a GetTradePrice SOAP 1.1 request may be sent to a StockQuote service via the SOAP 1.1 HTTP binding. The request takes a ticker symbol of type string, a time of type timeInstant, and returns the price as a float in the SOAP response.

    Example 4. SOAP binding of request-response RPC operation over HTTP

    <?xml version="1.0"?>
    <definitions name="StockQuote"
              targetNamespace="http://example.com/stockquote.wsdl"
              xmlns:tns="http://example.com/stockquote.wsdl"
              xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
              xmlns:xsd1="http://example.com/stockquote.xsd"
              xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
              xmlns="http://schemas.xmlsoap.org/wsdl/">
     
        <message name="GetTradePriceInput">
            <part name="tickerSymbol" element="xsd:string"/>
            <part name="time" element="xsd:timeInstant"/>
        </message>
     
        <message name="GetTradePriceOutput">
            <part name="result" type="xsd:float"/>
        </message>
     
        <portType name="StockQuotePortType">
            <operation name="GetTradePrice">
               <input message="tns:GetTradePriceInput"/>
               <output message="tns:GetTradePriceOutput"/>
            </operation>
        </portType>
     
        <binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">
            <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
            <operation name="GetTradePrice">
               <soap:operation soapAction="http://example.com/GetTradePrice"/>
               <input>
                   <soap:body use="encoded" namespace="http://example.com/stockquote"
                              encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
               </input>
               <output>
                   <soap:body use="encoded" namespace="http://example.com/stockquote"
                             encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
               </output>
            </operation>>
        </binding>
     
        <service name="StockQuoteService">
            <documentation>My first service</documentation>
            <port name="StockQuotePort" binding="tns:StockQuoteBinding">
               <soap:address location="http://example.com/stockquote"/>
            </port>
        </service>
    </definitions>

    This example describes that a GetTradePrices SOAP 1.1 request may be sent to a StockQuote service via the SOAP 1.1 HTTP binding. The request takes a stock quote symbol string, an application defined TimePeriod structure containing a start and end time and returns an array of stock prices recorded by the service within that period of time, as well as the frequency at which they were recorded as the SOAP response.  The RPC signature that corresponds to this service has in parameters tickerSymbol and timePeriod followed by the output parameter frequency, and returns an array of floats.

    Example 5. SOAP binding of request-response RPC operation over HTTP

    <?xml version="1.0"?>
    <definitions name="StockQuote"
     
    targetNamespace="http://example.com/stockquote.wsdl"
              xmlns:tns="http://example.com/stockquote.wsdl"
              xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
              xmlns:xsd1="http://example.com/stockquote/schema"
              xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
              xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
              xmlns="http://schemas.xmlsoap.org/wsdl/">
     
        <types>
           <schema targetNamespace="http://example.com/stockquote/schema"
                  xmlns="http://www.w3.org/2000/10/XMLSchema">
               <complexType name="TimePeriod">
                  <all>
                      <element name="startTime" type="xsd:timeInstant"/>
                      <element name="endTime" type="xsd:timeInstant"/>
                  </all>
               </complexType>
               <complexType name="ArrayOfFloat">
                  <complexContent>
                      <restriction base="soapenc:Array">
                          <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:float[]"/>
                      </restriction>
                  </complexContent>
               </complexType>
           </schema>
        </types>
     
        <message name="GetTradePricesInput">
            <part name="tickerSymbol" element="xsd:string"/>
            <part name="timePeriod" element="xsd1:TimePeriod"/>
        </message>
     
        <message name="GetTradePricesOutput">
            <part name="result" type="xsd1:ArrayOfFloat"/>
            <part name="frequency" type="xsd:float"/>
        </message>
     
        <portType name="StockQuotePortType">
            <operation name="GetLastTradePrice" parameterOrder="tickerSymbol timePeriod frequency">
               <input message="tns:GetTradePricesInput"/>
               <output message="tns:GetTradePricesOutput"/>
            </operation>
        </portType>
     
        <binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">
            <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
            <operation name="GetTradePrices">
               <soap:operation soapAction="http://example.com/GetTradePrices"/>
               <input>
                   <soap:body use="encoded" namespace="http://example.com/stockquote"
                              encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
               </input>
               <output>
                   <soap:body use="encoded" namespace="http://example.com/stockquote"
                              encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
               </output>
            </operation>>
        </binding>
     
        <service name="StockQuoteService">
            <documentation>My first service</documentation>
            <port name="StockQuotePort" binding="tns:StockQuoteBinding">
               <soap:address location="http://example.com/stockquote"/>
            </port>
        </service>
    </definitions>

     

    3.2 How the SOAP Binding Extends WSDL

    The SOAP Binding extends WSDL with the following extension elements:

    <definitions .... >
        <binding .... >
            <soap:binding style="rpc|document" transport="uri">
            <operation .... >
               <soap:operation soapAction="uri"? style="rpc|document"?>?
               <input>
                   <soap:body parts="nmtokens"? use="literal|encoded"
                              encodingStyle="uri-list"? namespace="uri"?>
                   <soap:header message="qname" part="nmtoken" use="literal|encoded"
                                encodingStyle="uri-list"? namespace="uri"?>*
                     <soap:headerfault message="qname" part="nmtoken" use="literal|encoded"
                                       encodingStyle="uri-list"? namespace="uri"?/>*
                   <soap:header>                                
               </input>
               <output>
                   <soap:body parts="nmtokens"? use="literal|encoded"
                              encodingStyle="uri-list"? namespace="uri"?>
                   <soap:header message="qname" part="nmtoken" use="literal|encoded"
                                encodingStyle="uri-list"? namespace="uri"?>*
                     <soap:headerfault message="qname" part="nmtoken" use="literal|encoded"
                                       encodingStyle="uri-list"? namespace="uri"?/>*
                   <soap:header>                                
               </output>
               <fault>*
                   <soap:fault name="nmtoken" use="literal|encoded"
                               encodingStyle="uri-list"? namespace="uri"?>
                </fault>
            </operation>
        </binding>
     
        <port .... >
            <soap:address location="uri"/> 
        </port>
    </definitions>

    Each extension element of the SOAP binding is covered in subsequent sections.

    3.3 soap:binding

    The purpose of the SOAP binding element is to signify that the binding is bound to the SOAP protocol format: Envelope, Header and Body. This element makes no claims as to the encoding or format of the message (e.g. that it necessarily follows section 5 of the SOAP 1.1 specification).

    The soap:binding element MUST be present when using the SOAP binding.

    <definitions .... >
        <binding .... >
            <soap:binding transport="uri"? style="rpc|document"?>
        </binding>
    </definitions>

    The value of the style attribute is the default for the style attribute for each contained operation. If the style attribute is omitted, it is assumed to be "document". See section 3.4 for more information on the semantics of style.

    The value of the required transport attribute indicates which transport of SOAP this binding corresponds to. The URI value http://schemas.xmlsoap.org/soap/http corresponds to the HTTP binding in the SOAP specification. Other URIs may be used here to indicate other transports (such as SMTP, FTP, etc.).

    3.4 soap:operation

    The soap:operation element provides information for the operation as a whole.

    <definitions .... >
        <binding .... >
            <operation .... >
               <soap:operation soapAction="uri"? style="rpc|document"?>?
            </operation>
        </binding>
    </definitions>

    The style attribute indicates whether the operation is RPC-oriented (messages containing parameters and return values) or document-oriented (message containing document(s)). This information may be used to select an appropriate programming model. The value of this attribute also affects the way in which the Body of the SOAP message is constructed, as explained in Section 3.5 below. If the attribute is not specified, it defaults to the value specified in the soap:binding element. If the soap:binding element does not specify a style, it is assumed to be "document".

    The soapAction attribute specifies the value of the SOAPAction header for this operation. This URI value should be used directly as the value for the SOAPAction header; no attempt should be made to make a relative URI value absolute when making the request. For the HTTP protocol binding of SOAP, this is value required (it has no default value). For other SOAP protocol bindings, it MUST NOT be specified, and the soap:operation element MAY be omitted.

    3.5 soap:body

    The soap:body element specifies how the message parts appear inside the SOAP Body element.

    soap:body元素說明了message元素中的part部分如何出現(xiàn)在SOAP Body元素中。

    The parts of a message may either be abstract type definitions, or concrete schema definitions. If abstract definitions, the types are serialized according to some set of rules defined by an encoding style. Each encoding style is identified using a list of URIs, as in the SOAP specification. Since some encoding styles such as the SOAP Encoding (http://schemas.xmlsoap.org/soap/encoding/) allow variation in the message format for a given set of abstract types, it is up to the reader of the message to understand all the format variations: "reader makes right". To avoid having to support all variations, a message may be defined concretely and then indicate it’s original encoding style (if any) as a hint. In this case, the writer of the message must conform exactly to the specified schema: "writer makes right".

    Message中的part部分可以是抽象類型定義,也可以是具體的schema定義。如果是抽象定義,那么類型將根據(jù)一種encoding style所定義的一些規(guī)則進(jìn)行序列化。每一種encoding style通過一系列的URIs來指定,如SOAP規(guī)范中所展示的。由于一些encoding styles,如SOAP Encoding (http://schemas.xmlsoap.org/soap/encoding/),允許variation(變化)出現(xiàn)在給定抽象類型的消息格式中,因此,將由消息的閱讀者來理解所有的variation(變化)的格式:"reader makes right"。為了避免支持所有的variation(變化),一個(gè)消息可以被具體定義,并根據(jù)提示指出它的原始encoding style,在這種情況下消息的書寫者將將嚴(yán)格遵守schema規(guī)范:"writer makes right"。

    The soap:body binding element provides information on how to assemble the different message parts inside the Body element of the SOAP message. The soap:body element is used in both RPC-oriented and document-oriented messages, but the style of the enclosing operation has important effects on how the Body section is structured:

    • If the operation style is rpc each part is a parameter or a return value and appears inside a wrapper element within the body (following Section 7.1 of the SOAP specification). The wrapper element is named identically to the operation name and its namespace is the value of the namespace attribute. Each message part (parameter) appears under the wrapper, represented by an accessor named identically to the corresponding parameter of the call. Parts are arranged in the same order as the parameters of the call.
    • If the operation style is document there are no additional wrappers, and the message parts appear directly under the SOAP Body element.

    soap:body binding元素提供了信息用于組合不同的message partsSOAP消息的Body元素中。soap:body元素可以使用RPC-oriented document-oriented類型的消息,但不同的封裝形式對(duì)于Body部分的構(gòu)造有重要的影響:

    • 如果是RPC style,message中的每個(gè)part將作為是一個(gè)參數(shù)或者一個(gè)返回值,由一個(gè)wrapper element進(jìn)行封裝,放入到SOAP Body中。此wrapper element的名稱將同 WSDL中的對(duì)應(yīng)operation的名稱一樣,其namespace將由綁定信息(soap:body)中的namespace屬性決定。每一個(gè)出現(xiàn)在wrapper element中的message part同所對(duì)應(yīng)的調(diào)用中的參數(shù)名稱一樣。并且Parts將安調(diào)用中的參數(shù)順序編排。
    • 如果是document style,那么將沒有額外的wrapper elementmessage parts將直接出現(xiàn)在SOAP Body元素中。

    The same mechanisms are used to define the content of the Body and parameter accessor elements.

    <definitions .... >
        <binding .... >
            <operation .... >
               <input>
                   <soap:body parts="nmtokens"? use="literal|encoded"?
                              encodingStyle="uri-list"? namespace="uri"?>
               </input>
               <output>
                   <soap:body parts="nmtokens"? use="literal|encoded"?
                              encodingStyle="uri-list"? namespace="uri"?>
               </output>
            </operation>
        </binding>
    </definitions>

    The optional parts attribute of type nmtokens indicates which parts appear somewhere within the SOAP Body portion of the message (other parts of a message may appear in other portions of the message such as when SOAP is used in conjunction with the multipart/related MIME binding). If the parts attribute is omitted, then all parts defined by the message are assumed to be included in the SOAP Body portion.

    The required use attribute indicates whether the message parts are encoded using some encoding rules, or whether the parts define the concrete schema of the message.

    所必須的use屬性指明了message parts是通過某些編碼規(guī)則進(jìn)行編碼的,或者由消息的具體schema進(jìn)行定義的。

    If use is encoded, then each message part references an abstract type using the type attribute. These abstract types are used to produce a concrete message by applying an encoding specified by the encodingStyle attribute. The part names, types and value of the namespace attribute are all inputs to the encoding, although the namespace attribute only applies to content not explicitly defined by the abstract types. If the referenced encoding style allows variations in it’s format (such as the SOAP encoding does), then all variations MUST be supported ("reader makes right").

    If use is literal, then each part references a concrete schema definition using either the element or type attribute. In the first case, the element referenced by the part will appear directly under the Body element (for document style bindings) or under an accessor element named after the message part (in rpc style). In the second, the type referenced by the part becomes the schema type of the enclosing element (Body for document style or part accessor element for rpc style). For an example that illustrates defining the contents of a composite Body using a type, see section 2.3.1.  The value of the encodingStyle attribute MAY be used when the use is encoded to indicate that the concrete format was derived using a particular encoding (such as the SOAP encoding), but that only the specified variation is supported ("writer makes right").

    如果use屬性值為encoded,那么每個(gè)message part將通過type屬性指定一個(gè)抽象類型。通過encodingStyle屬性所表示的編碼規(guī)范,這些抽象類型將用于構(gòu)造一個(gè)具體的消息。part names, types a以及 value of the namespace attribute將作為編碼的輸入,其中的namespace attribute僅僅在內(nèi)容中被應(yīng)用,沒有被abstract types顯式定義。如果所指定的encoding style允許variations(變化)它的格式,那么所有的variations(變化)都將被支持。

    如果use屬性值為literal,那么每個(gè)message part將通過element或者type屬性指向一個(gè)具體的schema定義。在第一種情況下,part中的element 所指向的內(nèi)容將直接位于Body元素下(對(duì)于document style bindings),或者位于Body元素下的wrapper element元素中(對(duì)于rpc style)。在第二種情況下,part中的type所指向的內(nèi)容將作為其所對(duì)應(yīng)元素的schema類型。

    The value of the encodingStyle attribute is a list of URIs, each separated by a single space. The URI's represent encodings used within the message, in order from most restrictive to least restrictive (exactly like the encodingStyle attribute defined in the SOAP specification).

    encodingStyle屬性的值是一個(gè)URIs列表,由單個(gè)空格隔開。這些URIs代表著消息的編碼類型,按照限制的從強(qiáng)到弱排序。

    3.6 soap:fault

    The soap:fault element specifies the contents of the contents of the SOAP Fault Details element. It is patterned after the soap:body element (see section 3.5).

    <definitions .... >
        <binding .... >
            <operation .... >
               <fault>*
                   <soap:fault name="nmtoken" use="literal|encoded"
                                     encodingStyle="uri-list"? namespace="uri"?>
               </fault>
            </operation>
        </binding>
    </definitions>

    The name attribute relates the soap:fault to the wsdl:fault defined for the operation.

    The fault message MUST have a single part. The use, encodingStyle and namespace attributes are all used in the same way as with soap:body (see section 3.5), only style="document" is assumed since faults do not contain parameters.

    3.7 soap:header and soap:headerfault

    The soap:header and soap:headerfault elements allows header to be defined that are transmitted inside the Header element of the SOAP Envelope. It is patterned after the soap:body element (see section 3.5).

    It is not necessary to exhaustively list all headers that appear in the SOAP Envelope using soap:header. For example, extensions (see section 2.1.3) to WSDL may imply specific headers should be added to the actual payload and it is not required to list those headers here.

    <definitions .... >
        <binding .... >
            <operation .... >
               <input>
                 <soap:header message="qname" part="nmtoken" use="literal|encoded"
                              encodingStyle="uri-list"? namespace="uri"?>*
                   <soap:headerfault message="qname" part="nmtoken" use="literal|encoded"
                                     encodingStyle="uri-list"? namespace="uri"?/>*
                 <soap:header>                                
               </input>
               <output>
                   <soap:header message="qname" part="nmtoken" use="literal|encoded"
                                encodingStyle="uri-list"? namespace="uri"?>*
                     <soap:headerfault message="qname" part="nmtoken" use="literal|encoded"
                                       encodingStyle="uri-list"? namespace="uri"?/>*
                   <soap:header>                               
               </output>
            </operation>
        </binding>
    </definitions>

    The use, encodingStyle and namespace attributes are all used in the same way as with soap:body (see section 3.5), only style="document" is assumed since headers do not contain parameters.

    Together, the message attribute (of type QName) and the part attribute (of type nmtoken) reference the message part that defines the header type. The schema referenced by the part MAY include definitions for the soap:actor and soap:mustUnderstand attributes if use="literal", but MUST NOT if use="encoded". The referenced message need not be the same as the message that defines the SOAP Body.

    The optional headerfault elements which appear inside soap:header and have the same syntax as soap:header) allows specification of the header type(s) that are used to transmit error information pertaining to the header defined by the soap:header. The SOAP specification states that errors pertaining to headers must be returned in headers, and this mechanism allows specification of the format of such headers.

    3.8 soap:address

    The SOAP address binding is used to give a port an address (a URI). A port using the SOAP binding MUST specify exactly one address. The URI scheme specified for the address must correspond to the transport specified by the soap:binding.

    <definitions .... >
        <port .... >
            <binding .... >
               <soap:address location="uri"/> 
            </binding>
        </port>
    </definitions>


    Author: orangelizq
    email: orangelizq@163.com

    歡迎大家訪問我的個(gè)人網(wǎng)站 萌萌的IT人
    posted on 2008-04-22 23:02 桔子汁 閱讀(17449) 評(píng)論(1)  編輯  收藏 所屬分類: Web Service

    評(píng)論:
    # re: WSDL樣式詳解[未登錄] 2008-04-23 22:13 | Gavin
    寫的不錯(cuò)
    WSDL定義的太麻煩了

    愿意的話,可以認(rèn)識(shí)一下,我做UDDI方面的開發(fā)
    msn:guangquanzhang#hotmail.com
    gtalk: guangquanzhang#gmail.com
    yahoo: javafuns.csdn#yahoo.com  回復(fù)  更多評(píng)論
      
    主站蜘蛛池模板: 手机在线免费视频| a级片免费在线观看| 欧美a级成人网站免费| 亚洲三级在线播放| 18禁网站免费无遮挡无码中文 | 两个人看的www免费| 亚洲色WWW成人永久网址| 久久免费观看视频| 午夜亚洲www湿好大| 99在线观看免费视频| 亚洲av专区无码观看精品天堂| 最新欧洲大片免费在线 | 亚洲日本乱码一区二区在线二产线 | 亚洲日韩VA无码中文字幕 | 日韩毛片免费无码无毒视频观看| 亚洲人成伊人成综合网久久| 久久精品a一国产成人免费网站 | 久久精品国产亚洲网站| 免费精品无码AV片在线观看| 亚洲人配人种jizz| 亚洲M码 欧洲S码SSS222| 国产成人免费AV在线播放 | 亚洲爆乳AAA无码专区| 亚洲精品视频免费| 99爱视频99爱在线观看免费| 国产亚洲精品VA片在线播放| 亚洲AⅤ优女AV综合久久久| 天黑黑影院在线观看视频高清免费| 中文字幕亚洲精品资源网| 成年女人毛片免费播放视频m| 一级A毛片免费观看久久精品 | 亚洲高清免费在线观看| 亚洲国产精品久久久久秋霞小| 亚洲最大AV网站在线观看| 亚洲成人在线免费观看| 美女视频黄视大全视频免费的| 久久亚洲精品国产精品黑人| 午夜视频在线观看免费完整版| 久久一区二区免费播放| 亚洲AV一二三区成人影片| 亚洲色偷偷狠狠综合网|