WebService—wsdl的簡單介紹(未完)
WSDL簡介
WSDL,Web Services Description Language,Web Service的描述語言,是一種介面定義語言,用於描述Web Service的介面資訊等。(描述Web服務和說明如何與Web服務通訊的XML語言。為使用者提供詳細的介面說明書。)
WSDL元素
WSDL有五大元素,分別是types,message,portType,binding和service。
types:用來定義訪問的型別
message:SOAP Message
portType:指明伺服器的介面,並且通過operation繫結相應的in和out訊息(in:引數, out:返回值)
binding:指定傳遞訊息所使用的格式
service:指定服務所釋出的名稱
下方為 程式碼優先 生成的wsdl檔案:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://service.zttc.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://service.zttc.org/" name="MyServiceImplService">
<!-- types:用來定義訪問的型別 -->
<types>
<xsd:schema>
<xsd:import namespace="http://service.zttc.org/" schemaLocation="http://localhost:8887/ns?xsd=1"></xsd:import>
</xsd:schema>
</types>
<!-- message:SOAP Message,訊息體 -->
<message name="minus">
<part name="parameters" element="tns:minus"></part>
</message>
<message name="minusResponse">
<part name="parameters" element="tns:minusResponse"></part>
</message>
<message name="login">
<part name="parameters" element="tns:login"></part>
</message>
<message name="loginResponse">
<part name="parameters" element="tns:loginResponse"></part>
</message>
<message name="add">
<part name="parameters" element="tns:add"></part>
</message>
<message name="addResponse">
<part name="parameters" element="tns:addResponse"></part>
</message>
<!-- portType:埠型別,指明伺服器的介面 -->
<portType name="IMyService">
<!-- 並且通過operation繫結相應的in和out訊息(in:引數, out:返回值)-->
<!-- operation,操作,對服務所支援的操作進行抽象描述 -->
<operation name="minus">
<input wsam:Action="http://service.zttc.org/IMyService/minusRequest" message="tns:minus"></input>
<output wsam:Action="http://service.zttc.org/IMyService/minusResponse" message="tns:minusResponse"></output>
</operation>
<operation name="login">
<input wsam:Action="http://service.zttc.org/IMyService/loginRequest" message="tns:login"></input>
<output wsam:Action="http://service.zttc.org/IMyService/loginResponse" message="tns:loginResponse"></output>
</operation>
<operation name="add">
<input wsam:Action="http://service.zttc.org/IMyService/addRequest" message="tns:add"></input>
<output wsam:Action="http://service.zttc.org/IMyService/addResponse" message="tns:addResponse"></output>
</operation>
</portType>
<!-- binding:使用的通訊協議,指定傳遞訊息所使用的格式 -->
<binding name="MyServiceImplPortBinding" type="tns:IMyService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
<operation name="minus">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal"></soap:body>
</input>
<output>
<soap:body use="literal"></soap:body>
</output>
</operation>
<operation name="login">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal"></soap:body>
</input>
<output>
<soap:body use="literal"></soap:body>
</output>
</operation>
<operation name="add">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal"></soap:body>
</input>
<output>
<soap:body use="literal"></soap:body>
</output>
</operation>
</binding>
<!-- service:指定服務所釋出的名稱 -->
<service name="MyServiceImplService">
<!-- 定義為繫結和網路地址組合的單個端點 -->
<port name="MyServiceImplPort" binding="tns:MyServiceImplPortBinding">
<soap:address location="http://localhost:8887/ns"></soap:address>
</port>
</service>
</definitions>
下方為 契約優先,手動編寫的wsdl檔案:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.example.org/mywsdl/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="MyServiceImplService"
targetNamespace="http://www.example.org/mywsdl/">
<!-- types:用來定義訪問的型別 -->
<wsdl:types>
<xsd:schema targetNamespace="http://www.example.org/mywsdl/">
<xsd:element name="plus" type="tns:plus" />
<xsd:element name="plusResponse" type="tns:plusResponse" />
<xsd:element name="minus" type="tns:minus" />
<xsd:element name="minusResponse" type="tns:minusResponse" />
<xsd:element name="licenseInfo" type="xsd:string" />
<xsd:complexType name="plus">
<xsd:sequence>
<xsd:element name="a" type="xsd:int" />
<xsd:element name="b" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="plusResponse">
<xsd:sequence>
<xsd:element name="plusResult" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="minus">
<xsd:sequence>
<xsd:element name="num1" type="xsd:int" />
<xsd:element name="num2" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="minusResponse">
<xsd:sequence>
<xsd:element name="minusResult" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
<!-- message:SOAP Message,訊息體 -->
<wsdl:message name="plus">
<wsdl:part name="plus" element="tns:plus" />
</wsdl:message>
<wsdl:message name="plusResponse">
<wsdl:part name="plusResponse" element="tns:plusResponse" />
</wsdl:message>
<wsdl:message name="minus">
<wsdl:part name="minus" element="tns:minus" />
</wsdl:message>
<wsdl:message name="minusResponse">
<wsdl:part name="minusResponse" element="tns:minusResponse" />
</wsdl:message>
<wsdl:message name="licenseInfo">
<wsdl:part name="licenseInfo" element="tns:licenseInfo" />
</wsdl:message>
<!-- portType:埠型別,指明伺服器的介面 -->
<wsdl:portType name="IMyService">
<!-- 並且通過operation繫結相應的in和out訊息(in:引數, out:返回值)-->
<wsdl:operation name="plus">
<wsdl:input message="tns:plus" />
<wsdl:output message="tns:plusResponse" />
</wsdl:operation>
<wsdl:operation name="minus">
<wsdl:input message="tns:minus" />
<wsdl:output message="tns:minusResponse" />
</wsdl:operation>
</wsdl:portType>
<!-- binding:使用的通訊協議,指定傳遞訊息所使用的格式 -->
<wsdl:binding name="myServiceSOAP" type="tns:IMyService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="plus">
<wsdl:input>
<soap:body use="literal"/>
<soap:header use="literal" part="licenseInfo" message="tns:licenseInfo" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="minus">
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<!-- service:指定服務所釋出的名稱 -->
<wsdl:service name="MyServiceImplService">
<wsdl:port binding="tns:myServiceSOAP" name="MyServiceImplPort">
<soap:address location="http://localhost:8989/ms"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
相關文章
- SAAJ API 介紹(未完)API
- (文摘)徹底理解webservice SOAP WSDLWeb
- Webpack 的簡單介紹Web
- Promise的簡單介紹Promise
- CFRunloopObserverRef 的簡單介紹OOPServer
- cxf WebService設定wsdl中soapAction的值Web
- SVG簡單介紹SVG
- HTML簡單介紹HTML
- ActiveMQ簡單介紹MQ
- HTML 簡單介紹HTML
- JavaScript 簡單介紹JavaScript
- CSS 簡單介紹CSS
- SCSS 簡單介紹CSS
- UICollectionView 簡單介紹UIView
- css簡單介紹CSS
- webservice快速入門-SOAP和WSDL(三)Web
- SpringMvc的簡單介紹SpringMVC
- javascript的this用法簡單介紹JavaScript
- noscript的作用簡單介紹
- Redux的簡單概念介紹Redux
- ORACLE SEQUENCE的簡單介紹Oracle
- OFBIZ webservice簡介Web
- RPC簡單介紹RPC
- spark簡單介紹(一)Spark
- Flutter key簡單介紹Flutter
- Python簡單介紹Python
- <svg>元素簡單介紹SVG
- Git_簡單介紹Git
- JSON簡單介紹JSON
- 簡單介紹克隆 JavaScriptJavaScript
- 簡單介紹 ldd 命令
- javascript物件簡單介紹JavaScript物件
- CSS OOCSS簡單介紹CSS
- CSS SMACSS簡單介紹CSSMac
- CSS BEM簡單介紹CSS
- javascript this指向簡單介紹JavaScript
- javascript加密簡單介紹JavaScript加密
- nodejs簡單介紹NodeJS