- WSDL 元素
- WSDL - <definitions>
- WSDL - <types>
- WSDL - <message>
- WSDL - <portType>
- WSDL - <binding>
- WSDL - <ports>
- WSDL - <service>
- WSDL 實用資源
- WSDL - 快速指南
- WSDL - 實用資源
- WSDL - 討論
WSDL - <portType> 元素
<portType> 元素將多個訊息元素結合起來,形成一個完整的單向或一個往返操作。
例如,<portType> 可以將一個請求與一個響應訊息結合成一個單一的請求/響應操作。這在 SOAP 服務中最常使用。一個 portType 可以定義多個操作。
讓我們從 WSDL 示例章節中獲取一段程式碼 -
<portType name = "Hello_PortType">
<operation name = "sayHello">
<input message = "tns:SayHelloRequest"/>
<output message = "tns:SayHelloResponse"/>
</operation>
</portType>
portType 元素定義了一個被稱為 sayHello 的單個操作。
操作由一條輸入訊息 SayHelloRequest 和一條
輸出訊息 SayHelloResponse 組成。
操作模式
WSDL 支援四種基本操作模式 -
單向
服務接收一條訊息。因此,操作只有一個 input 元素。單向操作的語法是 -
<wsdl:definitions .... >
<wsdl:portType .... > *
<wsdl:operation name = "nmtoken">
<wsdl:input name = "nmtoken"? message = "qname"/>
</wsdl:operation>
</wsdl:portType >
</wsdl:definitions>
請求響應
服務接收一條訊息併發送一個響應。因此,操作有一個 input 元素,隨後是一個 output 元素。為了封裝錯誤,還可以指定一個可選的 fault 元素。請求響應操作的語法是 -
<wsdl:definitions .... >
<wsdl:portType .... > *
<wsdl:operation name = "nmtoken" parameterOrder = "nmtokens">
<wsdl:input name = "nmtoken"? message = "qname"/>
<wsdl:output name = "nmtoken"? message = "qname"/>
<wsdl:fault name = "nmtoken" message = "qname"/>*
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
請求響應
服務傳送一條訊息並接收一個響應。因此,操作有一個 output 元素,隨後是一個 input 元素。為了封裝錯誤,還可以指定一個可選的 fault 元素。請求響應操作的語法是 -
<wsdl:definitions .... >
<wsdl:portType .... > *
<wsdl:operation name = "nmtoken" parameterOrder = "nmtokens">
<wsdl:output name = "nmtoken"? message = "qname"/>
<wsdl:input name = "nmtoken"? message = "qname"/>
<wsdl:fault name = "nmtoken" message = "qname"/>*
</wsdl:operation>
</wsdl:portType >
</wsdl:definitions>
通知
服務傳送一條訊息。因此,操作只有一個 output 元素。以下是通知操作的語法 -
<wsdl:definitions .... >
<wsdl:portType .... > *
<wsdl:operation name = "nmtoken">
<wsdl:output name = "nmtoken"? message = "qname"/>
</wsdl:operation>
</wsdl:portType>
</wsdl:definitions>
廣告