基本的なWSDL構造の理解–(Webサービス記述言語)の説明
公開: 2020-08-24SOAPとRESTの呼び出しに関する私の以前の投稿を見たことがあるかもしれません。 現在、企業はRESTサービス呼び出しに移行していますが、それでも大多数の企業は依然としてSOAP overRESTを使用しています。 このチュートリアルでは、WSDL(Webサービス記述言語)の基本について説明します。
以下の質問のいずれかがある場合は、適切な場所にいます。
- Webサービス記述言語(WSDL)とは何ですか?
- WSDLチュートリアル
- Webサービス記述言語(WSDL)の説明
- WSDLの例–Webサービス記述言語
Webサービス記述言語(WSDL)
Java Web Development Worldでは、WSDLは、ドキュメント指向またはプロシージャ指向の情報を含むメッセージを操作するエンドポイントのセットとしてネットワークサービスを記述するためのXML形式です。
操作とメッセージは抽象的に記述され、エンドポイントを定義するために具体的なネットワークプロトコルとメッセージ形式にバインドされます。 関連する具体的なエンドポイントは、抽象的なエンドポイント(サービス)に結合されます。
WSDL
は拡張可能であり、通信に使用されるメッセージ形式やネットワークプロトコルに関係なく、エンドポイントとそのメッセージを記述できます。ただし、このドキュメントで説明されているバインディングは、SOAP 1.1、HTTP GET / POST、およびMIME。

別の人は読む必要があります:
- EclipseでサンプルWSDLを作成し、クライアントを生成します
- JAX-RSとJerseyを使用してJavaでRESTfulサービスを構築する方法(例)
言い換えると、WSDLドキュメントは、サービスをネットワークエンドポイントまたはports
のコレクションとして定義します。 WSDLでは、エンドポイントとメッセージの抽象的な定義は、具体的なネットワーク展開またはデータ形式のバインディングから分離されています。 これにより、抽象定義の再利用が可能になります。交換されるデータの抽象記述であるmessages
、および操作の抽象コレクションであるポートタイプです。
特定のポートタイプの具体的なプロトコルとデータ形式の仕様は、再利用可能なbinding
を構成します。 ポートは、ネットワークアドレスを再利用可能なバインディングに関連付けることによって定義され、ポートのコレクションはサービスを定義します。
したがって、WSDLドキュメントは、ネットワークサービスの定義で次の要素を使用します。
-
Types
–あるタイプシステム(XSD
など)を使用したデータタイプ定義のコンテナー。 -
Message
–通信されるデータの抽象的な型付きの定義。 -
Operation
–サービスによってサポートされるアクションの抽象的な説明。 -
Port Type
–1つ以上のエンドポイントでサポートされる操作の抽象的なセット。 -
Binding
–特定のポートタイプの具体的なプロトコルとデータ形式の仕様。 -
Port
–バインディングとネットワークアドレスの組み合わせとして定義された単一のエンドポイント。 -
Service
–関連するエンドポイントのコレクション。
エレメント | 説明 |
---|---|
<タイプ> | Webサービスで使用される(XMLスキーマ)データ型を定義します |
<メッセージ> | 各操作のデータ要素を定義します |
<portType> | 実行できる操作と関連するメッセージについて説明します。 |
<バインディング> | 各ポートタイプのプロトコルとデータ形式を定義します |
例:HTTPを介したSOAP1.1要求/応答
サンプルXMLWSDLドキュメント。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
<? xml version = "1.0" ?> < definitions name = "StockQuote" targetNamespace = "http://example.com/stockquote.wsdl" xmlns : tns = "http://example.com/stockquote.wsdl" xmlns : xsd1 = "http://example.com/stockquote.xsd" xmlns : soap = "http://schemas.xmlsoap.org/wsdl/soap/" xmlns = "http://schemas.xmlsoap.org/wsdl/" > < types > < schema targetNamespace = "http://example.com/stockquote.xsd" xmlns = "http://www.w3.org/2000/10/XMLSchema" > < element name = "TradePriceRequest" > < complexType > < all > < element name = "tickerSymbol" type = "string" / > < / all > < / complexType > < / element > < element name = "TradePrice" > < complexType > < all > < element name = "price" type = "float" / > < / all > < / complexType > < / element > < / schema > < / types > < message name = "GetLastTradePriceInput" > < part name = "body" element = "xsd1:TradePriceRequest" / > < / message > < message name = "GetLastTradePriceOutput" > < part name = "body" element = "xsd1:TradePrice" / > < / message > < portType name = "StockQuotePortType" > < operation name = "GetLastTradePrice" > < input message = "tns:GetLastTradePriceInput" / > < output message = "tns:GetLastTradePriceOutput" / > < / operation > < / portType > < binding name = "StockQuoteSoapBinding" type = "tns:StockQuotePortType" > < soap : binding style = "document" transport = "http://schemas.xmlsoap.org/soap/http" / > < operation name = "GetLastTradePrice" > < soap : operation soapAction = "http://example.com/GetLastTradePrice" / > < input > < soap : body use = "literal" / > < / input > < output > < soap : body use = "literal" / > < / output > < / operation > < / binding > < service name = "StockQuoteService" > < documentation > My first service < / documentation > < port name = "StockQuotePort" binding = "tns:StockQuoteBinding" > < soap : address location = "http://example.com/stockquote" / > < / port > < / service > < / definitions > |

SOAP 2.0 WSDLの例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
< ! -- Crunchify ' s example of WSDL 2.0 -- > <? xml version = "1.0" encoding = "UTF-8" ?> < definitions xmlns = "http://www.w3.org/ns/wsdl" xmlns : tns = "http://www.tmsws.com/wsdl20sample" xmlns : whttp = "http://schemas.xmlsoap.org/wsdl/http/" xmlns : wsoap = "http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace = "http://www.tmsws.com/wsdl20sample" > < ! -- Abstract type -- > < types > < xs : schema xmlns : xs = "http://www.w3.org/2001/XMLSchema" xmlns = "http://www.tmsws.com/wsdl20sample" targetNamespace = "http://crunchify.com/wsdl20" > < xs : element name = "request" > . . . add your code here . . . < / xs : element > < xs : element name = "response" > . . . add your code here . . . < / xs : element > < / xs : schema > < / types > < ! -- Abstract interfaces -- > < interface name = "CrunchifyItem" > < fault name = "ErrorDescription" element = "tns:response" / > < operation name = "Get" pattern = "http://www.w3.org/ns/wsdl/in-out" > < input messageLabel = "In" element = "tns:request" / > < output messageLabel = "Out" element = "tns:response" / > < / operation > < / interface > < ! -- Concrete Binding Over HTTP -- > < binding name = "HttpBinding" interface = "tns:CrunchifyItem" type = "http://www.w3.org/ns/wsdl/http" > < operation ref = "tns:Get" whttp : method = "GET" / > < / binding > < ! -- Concrete Binding with SOAP -- > < binding name = "SoapBinding" interface = "tns:CrunchifyItem" type = "http://www.w3.org/ns/wsdl/soap" wsoap : protocol = "http://www.w3.org/2003/05/soap/bindings/HTTP/" wsoap : mepDefault = "http://www.w3.org/2003/05/soap/mep/request-response" > < operation ref = "tns:Get" / > < / binding > < ! -- Web Service offering endpoints for both bindings -- > < service name = "ServiceOne" interface = "tns:CrunchifyItem" > < endpoint name = "HttpEndpoint" binding = "tns:HttpBinding" address = "http://www.example.com/rest/" / > < endpoint name = "SoapEndpoint" binding = "tns:SoapBinding" address = "http://crunchify.com/soap/" / > < / service > < / definitions > |
例で説明されたファクトリデザインパターン。

ご不明な点がございましたら、お気軽にお問い合わせください。