wsdl分析學習

<pre name="code" class="html"><?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://server.hw.demo/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="HelloWorldImplService" targetNamespace="http://server.hw.demo/">
	<wsdl:types>
		<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://server.hw.demo/" elementFormDefault="unqualified" targetNamespace="http://server.hw.demo/" version="1.0">
			<!--
            types部分是schema,schema是用來定義xml規則的,請求消息和響應消息都是xml,實際上
             這裏就是用來定義soap消息的請求和響應的,下面的sayHi來自命令空間xmlns:tns="http://server.hw.demo/"
             而這個命令空間就是targetNamespace="http://server.hw.demo/",這個複合類型的定義是自己定義給自己同
             一個schema文件使用的,如參數arg0沒有定義最大出現次數則表示出現1次。
            請求部分如下:
		    <sayHi>
				<arg0>string</arg0>
            </sayHi>
            響應部分如下:
            <sayHiResponse><return>string</return></sayHiResponse>
			-->
			<xs:element name="sayHi" type="tns:sayHi"/>
			<xs:element name="sayHiResponse" type="tns:sayHiResponse"/>
			<xs:complexType name="sayHi">
				<xs:sequence>
					<xs:element minOccurs="0" name="arg0" type="xs:string"/>
				</xs:sequence>
			</xs:complexType>
			<xs:complexType name="sayHiResponse">
				<xs:sequence>
					<xs:element minOccurs="0" name="return" type="xs:string"/>
				</xs:sequence>
			</xs:complexType>
		</xs:schema>
	</wsdl:types>
	<!--
     這個是消息,表示我們發一個消息有二部分組成,一個是請求消息、一個響應消息
     wsdl:part表示sayHi這個請求消息由tns:sayHi組成,也就是上面的那個schema定義的。
     所以message是用來定義消息的結構,part表示指定引用types部分定義的消息片段。
     -->
	<wsdl:message name="sayHi">
		<wsdl:part element="tns:sayHi" name="parameters">
    </wsdl:part>
	</wsdl:message>
	<wsdl:message name="sayHiResponse">
		<wsdl:part element="tns:sayHiResponse" name="parameters">
    </wsdl:part>
	</wsdl:message>
	<!--
    protType:表示服務端的SEI,也就是一個接口
    operation:表示這個接口的方法
    input:表示該方法的請求消息,會引用上面定義的message部分
    output:表示該方法的響應數據,同樣會引用上面的message部分
     -->
	<wsdl:portType name="HelloWorld">
		<wsdl:operation name="sayHi">
			<wsdl:input message="tns:sayHi" name="sayHi">
    </wsdl:input>
			<wsdl:output message="tns:sayHiResponse" name="sayHiResponse">
    </wsdl:output>
		</wsdl:operation>
	</wsdl:portType>
	
	<!--			   
     定義SEI的實現,其實上面是基於接口的定義,現在纔開始談到接口的實現,實現的是哪個接口呢?通過type
     屬性來指定,引用上面的type。
     binding:用於定義SEI的實現
      type屬性:引用上面的<portType>
     <soap:binding style="document":綁定數據的一個document(xml)
     operation:用來定義實現的方法,   
     <soap:operation soapAction="" style="document"/>傳輸的是document(xml)
     input:指定客戶端傳過來的數據
     <soap:body use="literal"/>:文本數據
    -->
	<wsdl:binding name="HelloWorldImplServiceSoapBinding" type="tns:HelloWorld">
		<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
		<wsdl:operation name="sayHi">
			<soap:operation soapAction="" style="document"/>
			<wsdl:input name="sayHi">
				<soap:body use="literal"/>
			</wsdl:input>
			<wsdl:output name="sayHiResponse">
				<soap:body use="literal"/>
			</wsdl:output>
		</wsdl:operation>
	</wsdl:binding>
	<!--
     service:表示一個webservice容器
      <wsdl:service name="HelloWorldImplService">中的name表示:它用來指定客戶端容器類,
    port:表示服務端一個SEI的實現
    binding:引用上面的<binding>
    address:當前webservice的請求地址
    -->
	<wsdl:service name="HelloWorldImplService">
		<wsdl:port binding="tns:HelloWorldImplServiceSoapBinding" name="HelloWorldImplPort">
			<soap:address location="http://127.0.0.1:9000/helloWorld"/>
		</wsdl:port>
	</wsdl:service>
</wsdl:definitions>

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章