WSDL(Web Service Description Language)Web服務描寫語言
################################################################################
適用于描寫WebService的文檔格式
下面例子是為了輸入1個字符串name,返回1個SayHello的操作。
<?xml version="1.0" encoding="UTF⑻" ?>
<wsdl:definitions
targetNamespace="http://com.liuxiang.xfireDemo/HelloService"-------------------DEFINITIONS:WSDL文檔根元素,提供命名空間
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/">
<wsdl:types>-------------------------------------------------------------------------------------TYPE:數(shù)據(jù)類型定義的容器,TYPE定義了兩個元
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
素,1個是sayHello,1個是sayHelloResp
attributeFormDefault="qualified" elementFormDefault="qualified"
onse。
targetNamespace="http://com.liuxiang.xfireDemo/HelloService">
<xsd:element name="sayHello">----------------------------------------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">---------------------------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>
<wsdl:message name="sayHelloResponse">----------------------------------------------MESSAGE:通訊消息的數(shù)據(jù)結構的抽象化定義,描
<wsdl:part name="parameters" element="tns:sayHelloResponse" />
述了Web服務使用消息的有效負載,
</wsdl:message>
還可描寫輸出或接受消息的有效負載
<wsdl:message name="sayHelloRequest">
,其中ELEMENT對應TYPE中的NAME。定義元
<wsdl:part name="parameters" element="tns:sayHello" />
素的方式取決于使用RPC樣式或文檔樣式,此處
</wsdl:message>
為文檔樣式
<wsdl:portType name="HelloServicePortType">------------------------------------------PORTTYPE:對某個訪問入口點類型所支持的操
<wsdl:operation name="sayHello">
作的抽象集合,1個portType可定義多
<wsdl:input name="sayHelloRequest"
個operation,1個operation可看作1
message="tns:sayHelloRequest" />
個方法,要求消息是MESSAGE定義的
<wsdl:output name="sayHelloResponse"
sayHelloRequest,相應消息是
message="tns:sayHelloResponse" />
sayHelloResponse,同時包括input
</wsdl:operation>
/output表明這是1個要求/響應模式,
</wsdl:portType>
input表示傳遞到Web服務的有效負
載,output表示傳遞到客戶的有效負
載.此處TNS為DEFINITIONS中所聲
明。
<wsdl:binding name="HelloServiceHttpBinding"--------------------------------------------BINDING:特定端口類型的具體協(xié)議和數(shù)據(jù)格式規(guī)
type="tns:HelloServicePortType">
范的綁定,binding將1個抽象porType映
<wsdlsoap:binding style="document"
射到1組具體協(xié)議(SOAP/HTTP),消息傳
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>
<wsdl:service name="HelloService">----------------------------------------------------------SERVICE:相干服務訪問點的集合,1個service元
<wsdl:port name="HelloServiceHttpPort"
素包括多個不同的port,每一個port表示
binding="tns:HelloServiceHttpBinding">
不同的Web服務,此例子中提供給訪
<wsdlsoap:address
問你的地址為:http://localhost:8080/xf.
location="http://localhost:8080/xfire/services/HelloService" />
.....
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
IMPORT:可讓當前WSDL文檔中援用其他WSDL文檔中指定命名空間中的元素,通經(jīng)常使用于WSDL模塊化。
<wsdl:import namespace="http://xxx.xxx.xxx/xxx/xxx" location="http://xxx.xxx.xxx/xxx/xxx.wsdl"/>
namespace屬性:必須與所導入文件的targetNameSpace名稱相同.
location屬性:指向wsdl文件的路徑,不能為空.
附WSDL文檔結構圖-------
以上這些就是基本的1些要點,,,如果有誤,請各位大爺批評指正,,,