webservice wsdl文件標籤講解

<?xml version="1.0" encoding="utf8"?>
<wsdl:definitions targetNamespace="http://www.57market.com.cn/HelloService" 
	xmlns:soapenc12="http://www.w3.org/2003/05/soapencoding" 
	xmlns:tns="http://www.57market.com.cn/HelloService" 
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
	xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
	xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" 
	xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" 
	xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" 
	xmlns:soap12="http://www.w3.org/2003/05/soapenvelope">
	<!--
	 * type元素,定義了交換信息的數據格式。
	 * 爲了實現最大的互操作性(interoperability)和平臺中立性(neutrality),WSDL選用XML Schema DataTypes
	 * 簡稱XSD作爲標準類型系統,並將它作爲固有類型系統。
	 * 下面是數據定義部分,該部分定義了兩個元素,一個是sayHello,一個是sayHelloResponse:
	 * sayHello:定義了一個複雜類型,僅僅包含一個簡單的字符串,將來用來描述操作的參入傳入部分;
	 * sayHelloResponse:定義了一個複雜類型,僅僅包含一個簡單的字符串,將來用來描述操作的返回值;
	-->
    <wsdl:types>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" 
					elementFormDefault="qualified" targetNamespace="http://www.57market.com.cn/HelloService">
            <xsd:element name="sayHello">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element maxOccurs="1" minOccurs="1" name="in0" 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="out" nillable="true" type="xsd:string" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
    </wsdl:types>
	<!--
	* message元素指定XML數據類型組成消息的各個部分。message元素用於定義操作的輸入和輸出參數。
	* 該部分是信息格式的抽象定義:定義了兩個消息sayHelloResponse和sayHelloRequest:
	* sayHelloRequest:sayHello操作的請求消息格式,由一個消息片斷組成,名字爲parameters,
	* 元素是我們前面定義的types中的元素;
	* sayHelloResponse:sayHello操作的響應消息格式,由一個消息片斷組成,名字爲parameters,
	* 元素是我們前面定義 *的types中的元素;
	* 如果採用RPC樣式的消息傳遞,只需要將文檔中的element元素應以修改爲type即可。
	* message:用來定義消息的結構
	* part:指定引用types中定義的標籤部分
	-->
    <wsdl:message name="sayHelloRequest">
        <wsdl:part name="parameters" element="tns:sayHello" />
    </wsdl:message>
    <wsdl:message name="sayHelloResponse">
        <wsdl:part name="parameters" element="tns:sayHelloResponse" />
    </wsdl:message>
	<!--
	* portType元素中定義了Web服務的操作。操作定義了輸入和輸出數據流中可以出現的XML消息。
	* 一些抽象操作的集合。每個操作關聯一個輸入消息和一個輸出消息。
	* portType定義了服務的調用模式的類型,這裏包含一個操作sayHello方法,同時包含input和output表明
	* 該操作是一個請求/響應模式,請求消息是前面定義的sayHelloRequest,
	* 響應消息是前面定義的sayHelloResponse。input表示傳遞到Web服務的有效負載,
	* output: 消息表示傳遞給客戶的有效負載。
	* portType:用來定義服務端的SEI
	* 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元素描述特定服務接口的協議、數據格式、安全性和其它屬性。
	* 針對操作和portType中使用的消息指定實際的協議和數據格式規範。
	* binding: 用於定義SEI的實現類
	* type屬性:引用上面的<portType>
	* <soap:operation style="document" />綁定的數據是一個document(xml)
	* operation:用來定義實現的方法
	* <soap:operation style="document" />傳輸的是document(xml)
	* input:指定客戶端應用傳過來的數據
	* <soap:body use="literal" />:文本數據
	* output:指定服務器端返回客戶端的數據
	* <soap:body use="literal"/>:文本數據
	-->
    <wsdl:binding name="HelloServiceHttpBinding" type="tns:HelloServicePortType">
        <wsdlsoap: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元素。服務元素包含一組port元素。端口將端點與來自服務接口定義的binding元素關聯起來。
	* port指定一個綁定的地址,這樣定義一個通信的終端。
	* service:一個webservice的容器
	* name:屬性:它用以指定一個服務器端處理請求的入口(就是SEI的實現)
	* binding屬性:引用上面定義的<binding>
	* address:當前webservice的請求地址
	-->
    <wsdl:service name="HelloService">
        <wsdl:port name="HelloServiceHttpPort" binding="tns:HelloServiceHttpBinding">
            <soap:address location="http://localhost:8080/xfire/services/HelloService" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

發佈了169 篇原創文章 · 獲贊 62 · 訪問量 77萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章