この邦訳は、私 SUGAI, Manabu が私的な勉強のために作成したものです。訳文の正確さは保証できません。この翻訳には誤りが含まれます。この点をご理解頂いた上でご利用下さい。本邦訳は依然改稿中であり、決定稿ではありません。
正式なものはあくまでも W3C の英語版だけですので、 特に技術的な利用においては、 W3C の原典を参照してください。
<<BACK | last modified: 24th/Dec./2007 | Translated by SUGAI, Manabu.
本文書の正誤表を参照されたい。規範的修正を含むことがある。
本文書は他にも以下の非規範的フォーマットで入手可能である: PDF, PostScript, XML, and plain text。
また、翻訳版も参照可能である。
Copyright © W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
本文書は、WSDL 2.0仕様 (Web Services Description Language (WSDL) Version 2.0 Part 1: Core Language [WSDL 2.0 Core], Web Services Description Language (WSDL) Version 2.0 Part 2: Adjuncts [WSDL 2.0 Adjuncts])に対する便覧である。 この言語の主な機能に対する技術的導入を、より簡便に少なくしたいと思う読者向けに意図されている。
この入門は、WSDL 2.0利用の出発点となることだけを意図されており、この言語の全ての機能を記述しているわけではない。読者は、より洗練された機能や技術を使いこなそうと思うのであれば、WSDL 2.0仕様を調べることが期待されている。
最後に、本入門は、非規範的である。WSDL 2.0の要求事項と禁止事項に関するあらゆる具体的な疑問については、WSDL 2.0仕様を参照すべきである。
本セクションは本文書の原版が公開された当時のステータスを記述している。他の文書が本文書に取って代わっている可能性もある。現在W3Cで公開されている文書の一覧および、本技術文書の最新版は、http://www.w3.org/TR/のW3C technical reports indexで得られる。
これは、W3Cメンバおよび他の利害関係団体によるレビューを経た、Web Services Description Language (WSDL) Version 2.0 Part 0: Primerに対するW3C勧告である。 Web Services Description作業部会によって、W3C Web Services Activityの一部として作成された。
本文書に対するコメントは、公開メーリングリストpublic-ws-desc-comments@w3.org (public archive)へ送っていただきたい。
この作業部会では、実装レポートに沿ったテストスィートをリリースしている。 本文書の前の版に対する差分を目立たせた版が入手可能である。
本文書は、W3Cメンバ、ソフトウェア開発者、他のW3Cグループおよび関係団体によってレビューされ、ディレクタによってW3C勧告として承認された。 これは安定的な文書であり、他の文書で引用したり、参照資料として用いても良い。勧告策定におけるW3Cの役割は、その仕様に対する関心を引き出し、広範な展開を促進することである。このことによって、Webの機能性と相互運用性を高めることになる。
本文書は、改定されたW3C特許ポリシー移行手続きによる24 January 2002 CPP (Current Patent Practice)で管理されている。 W3Cでは、各グループの要素成果物と関連して作成された公的な特許のリストをメンテナンスしている; それらのページは特許の公開に対する指示も含んでいる。この仕様に関するEssential Claim(s)を含んでいる特許に関する知識を持っていると主張する者は、W3C特許ポリシーの第6章に従い、情報を公開しなければならない。
1. 導入
1.1 前提条件
1.2 本入門の構成
1.3 URIとIRIの利用
1.4 表記上の慣習
2. WSDL 2.0の基本
2.1 始めに: The GreatH
Hotelの例
2.1.1 シナリオ例: The GreatH Hotel予約Service
2.1.2 WSDL 2.0 ターゲット名前空間の定義
2.1.2.1
例の説明
2.1.3 メッセージ型の定義
2.1.3.1
例の説明
2.1.4 インタフェース定義
2.1.4.1
例の説明
2.1.5 バインディング定義
2.1.5.1
例の説明
2.1.6 サービス定義
2.1.6.1
例の説明
2.1.7 サービスの文書化
2.1.7.1
例の説明
2.2 WSDL
2.0インフォセット、スキーマ、コンポネント・モデル
2.2.1 WSDL 2.0インフォセット
2.2.2 WSDL 2.0スキーマ
2.2.2.1
WSDL 2.要素順序
2.2.3 WSDL 2.0コンポネント・モデル
2.2.3.1
WSDL 2.0インポートおよびインクルード
2.3 メッセージ・タイプの詳細
2.3.1 インラインXMLスキーマ
2.3.2 XMLスキーマのインポート
2.3.3 インポートおよびインクルードのメカニズムの要約
2.4 インタフェースの詳細
2.4.1 インタフェース・シンタックス
2.4.2 インタフェースの継承
2.4.3 インタフェースのフォルト
2.4.4 インタフェースのオペレーション
2.4.4.1
オペレーションの属性
2.4.4.2
メッセージ参照のオペレーション
2.4.4.2.1
messageLabel属性
2.4.4.2.2
element属性
2.4.4.2.3
Multiple infault or outfault Elements
2.4.4.3
Understanding Message Exchange
Patterns (MEPs)
2.5 バインディングの詳細
2.5.1 Syntax Summary for Bindings
2.5.2 Reusable Bindings
2.5.3 Binding Faults
2.5.4 Binding Operations
2.5.5 The SOAP Binding Extension
2.5.5.1
Explanation of
Example
2.5.6 The HTTP Binding Extension
2.5.6.1
例の説明 (Explanation of Example)
2.5.7 HTTP GET Versus POST: Which to Use?
3. 発展的話題I: インポート・メカニズム
3.1 Importing
WSDL
3.2 Importing
Schemas
3.2.1 Schemas in Imported Documents
3.2.2 Multiple Inline Schemas in One Document
3.2.3 The schemaLocation Attribute
3.2.3.1
Using the id Attribute to Identify Inline
Schemas
4. 発展的話題II: 拡張可能性および定義済み拡張
4.1 Extensibility
4.1.1 Optional Versus Required
Extensions
4.2 Defining New MEPs
4.2.1 Confirmed Challenge
4.3 RPC Style
5. 発展的話題III: その他
5.1 Enabling
Easy Message Dispatch
5.2 Web Service
Versioning
5.2.1 Compatible Evolution
5.2.2 Big Bang
5.2.3 Evolving a Service
5.2.4 Combined Approaches
5.2.5 Examples of Versioning and
Extending a Service
5.2.5.1
Additional Optional Elements Added in Content
5.2.5.2
Additional Optional Elements Added to a Header
5.2.5.3
Additional Mandatory Elements in Content
5.2.5.4
Additional Optional Operation Added to
Interface
5.2.5.5
Additional Mandatory Operation Added to
Interface
5.2.5.6
Indicating Incompatibility by Changing the
Endpoint URI
5.2.5.7
Indicating Incompatibility by Changing the SOAP
Action
5.2.5.8
Indicating Incompatibility by Changing the
Element Content
5.3 他のWebサービスを参照するWebサービスメッセージの記述
5.3.1 予約詳細Webサービス
5.3.2 予約リストWebサービス
5.3.3 HTTP転送を用いた予約詳細Webサービス
5.3.4 HTTP GETを用いた予約リストWebサービス
5.4 同一サービスに対する複数のインタフェース
5.5 RDFとセマンティックWebに対するマッピング
5.5.1 WSDL 2.0におけるRDF表現
5.6 URIsに関する補足
5.6.1 XML
NamespacesとSchemaのLocations
5.6.2 相対URIs
5.6.3 一時URIsの生成
6. リファレンス
6.1 規範的リファレンス
6.2 非規範的リファレンス
A. 謝辞 (非規範的)
本入門では、読者は次の前提知識を持っていることを想定する:
XML(Extensible Markup Language (XML) 1.0 [XML 1.0]とXML Information Set [XML Information Set])およびXML名前空間 (Namespaces in XML [XML Namespaces])についての習熟;
XMLスキーマ(XML Schema Part 1: Structures [XML Schema Structures] XML Schema Part 2: Datatypes [XML Schema Datatypes])についてのある程度の習熟;
Webサービス、クライアント、Webサービス記述の目的と機能などの、Webサービスのコンセプトについての習熟(基本的なWebサービスのコンセプトに関する説明は、次の場所を参照: Web Services Architecture [WS Architecture] Section 1.4およびWeb Services Glossary [WS Glossary] glossary。しかしながら、Web Services Architectureの文書では、本入門における「client」、「Web service」の代わりに、より正確な用語である「requester agent」、「provider agent」が遣われていることに注意して欲しい。)
WSDLに関する事前の経験は、まったくないことを想定している。
第2節では、ホテルの予約サービスを含む仮説的なユースケースから始める。ここでは、このサービスを記述するWSDL 2.0の簡単な例の開発を通して、ステプ・バイ・ステップで進める:
types要素は、このサービスが送受信するメッセージの種類を記述する。
interface要素は、このWebサービスが提供する抽象機能がなんであるのかを記述する。
binding要素は、このサービスにどのようにアクセスするかを記述する。
service要素は、このサービスにどこでアクセスするかを記述する。
例を提示した後は、WSDL 2.0のインフォセット、スキーマ、コンポネントモデルの導入へ移る。 ここでは、メッセージタイプ、インタフェース、バインディング、サービスを定義するための、より詳細な情報を提供する。
第3節では、極めて詳細なWSDL 2.0インポーティング・メカニズムを説明する。
第4節では、WSDL 2.0の拡張可能性および、さまざまな定義済み拡張について話題にする。
第5節では、さまざまな話題に触れる。中には、WSDL 2.0のスコープから外れるものもあるが、WSDL 2.0文書記述やWSDL 2.0仕様の実装に役立つであろう、有意義なバックグラウンドとベスト・プラクティスのガイダンスを提供できるだろう。
WSDL 2.0のコア仕様は、Internationalized Resource Identifiers、すなわちIRIs [IETF RFC 3987]をサポートしている。 IRIsはURIsのスーパーセットで、国際化 (internationalization)サポートが追加されている。 URIのシンタックス[IETF RFC 3986]では、英数字の大文字と小文字、欧州の数字、および幾つかの記号を含む、僅かな文字の集合だけを許可している。IRIsでは、言語スクリプトのより幅広い文字の利用を許している。
単純化のために、本入門全体を通して、例ではURIsだけを使っている。 もし、IRIsの利用に関してもっと学びたいと思うのであれば、W3C Internationalization Activityに用意されているペーパーを読むことを勧める。
本文書では、幾つかのXML名前空間を用いている。それらのうちの幾つかのものは標準で定義されており、幾つかはアプリケーション固有である。 名前空間を名付ける一般的形式"http://greath.example.com/..."が表現するのは、アプリケーションまたは文脈に依存したURIs [IETF RFC 3986]である。また、名前空間の接頭辞の選択はいかなるものであれ恣意的であり、意味的な重要性はない([XML Information Set]参照)。
[WSDL 2.0 Core]におけるXMLシンタックス・サマリの規則に従って、この入門でも、WSDL 2.0文書のXML文法を記述するために、非公式なシンタックスを利用する:
シンタックスはXMLの実例として提示するが、値は値の代わりに値の型を指す。
次のような文字が要素や属性の後ろに追加される:"?" (0 or 1), "*" (0 or more), "+" (1 or more).
要素名が"…"で終了しているものは、文脈上無関係な要素/属性が省略されていることを指す。
このセクションでは、仮説的なホテル予約サービスの記述を通して、WSDL 2.0で使われる基本的なコンセプトを導入する。 我々は単純なシナリオから始めて、後で、より高度なWSDL 2.0機能の利用方法を説明するために、更なる要求を追加する。
ホテルGreatH(架空のホテル)は、離れ小島にある。 従来は、空き室予約の提供は、ファックスと電話に頼っていた。 GreatHホテルの設備と価格が競合相手の提示するものより良かったとしても、その競合相手の方がGreatHよりも多くの顧客を得ていることにHreatHでは気付いていた。 調査の後、この理由は、競合相手がWebサービスを提供しているためであることを知った。このサービスのおかげで、旅行代理店の予約システムはインターネット経由で直接空き室予約できるようになっていた。 今回、GreatHは我々を雇い、次の機能を持つ予約Webサービスを構築することにした:
CheckAvailability。空室があるか確認するために、クライアントはチェックイン予定日、チェックアウト予定日、ルームタイプを指定しなければならない。このWebサービスは、そのような部屋が予約可能であれば宿泊料金(USドルの浮動小数点数)を返し、もしなければ宿泊料金として0を返す。もし、何れかの入力データが不正であれば、このサービスはエラーを返さなければならない。つまり、このサービスは、checkAvailabilityメッセージを受け取り、checkAvailabilityResponseまたはinvalidDataFaultメッセージを返す。
MakeReservation。実際に予約するために、クライアントは、名前、住所、クレジット・カード情報を提供しなければならない。そして、予約が成功したら、サービスは予約確認番号を返す。サービスは、クレジットカード番号、または他のデータ・フィールドが不正であれば、エラーメッセージを返す。つまり、サービスはmakeReservationメッセージを受け取って、makeReservationResponseまたはinvalidCreditCardFaultメッセージを返す。
我々は、後で、トランザクションと安全な転送をサポートする完全なシステムを構築する必要があることを知っているが、最初は、最小機能だけを実装することにする。実際、我々の最初の例を単純化するために、CheckAvailabilityオペレーションだけを実装することにする。
後続の幾つかのセクションでは、要求されたWebサービスを記述するためのWSDL 2.0文書を開発するプロセスを通して、ステップ・バイ・ステップで進めていく。しかしながら、完全な例を見るまで待てない方々のために、これから作成されるWSDL 2.0文書をここに挙げておく。
例2-1. GreatH WebサービスのためのWSDL 2.0文書(最初の例)
<?xml version="1.0" encoding="utf-8" ?>
<description
xmlns="http://www.w3.org/ns/wsdl"
targetNamespace= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc"
xmlns:wsoap= "http://www.w3.org/ns/wsdl/soap"
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsdlx= "http://www.w3.org/ns/wsdl-extensions">
<documentation>
この文書はGreatHサービスについて記述している。
このサービスを利用するための、追加のアプリケーションレベルの要求 --
WSDL 2.0で記述できる範囲以上のもの -- は、次のURIで得られる:
http://greath.example.com/2004/reservation-documentation.html
</documentation>
<types>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://greath.example.com/2004/schemas/resSvc"
xmlns="http://greath.example.com/2004/schemas/resSvc">
<xs:element name="checkAvailability" type="tCheckAvailability"/>
<xs:complexType name="tCheckAvailability">
<xs:sequence>
<xs:element name="checkInDate" type="xs:date"/>
<xs:element name="checkOutDate" type="xs:date"/>
<xs:element name="roomType" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="checkAvailabilityResponse" type="xs:double"/>
<xs:element name="invalidDataError" type="xs:string"/>
</xs:schema>
</types>
<interface name = "reservationInterface" >
<fault name = "invalidDataFault"
element = "ghns:invalidDataError"/>
<operation name="opCheckAvailability"
pattern="http://www.w3.org/ns/wsdl/in-out"
style="http://www.w3.org/ns/wsdl/style/iri"
wsdlx:safe = "true">
<input messageLabel="In"
element="ghns:checkAvailability" />
<output messageLabel="Out"
element="ghns:checkAvailabilityResponse" />
<outfault ref="tns:invalidDataFault" messageLabel="Out"/>
</operation>
</interface>
<binding name="reservationSOAPBinding"
interface="tns:reservationInterface"
type="http://www.w3.org/ns/wsdl/soap"
wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">
<fault ref="tns:invalidDataFault"
wsoap:code="soap:Sender"/>
<operation ref="tns:opCheckAvailability"
wsoap:mep="http://www.w3.org/2003/05/soap/mep/soap-response"/>
</binding>
<service name="reservationService"
interface="tns:reservationInterface">
<endpoint name="reservationEndpoint"
binding="tns:reservationSOAPBinding"
address ="http://greath.example.com/2004/reservation"/>
</service>
</description>
我々のWSDL 2.0文書を書く前に、我々はそのためのWSDL 2.0ターゲット名前空間URIを決定する必要がある。WSDL 2.0のターゲット名前空間は、XMLスキーマのターゲット名前空間に似ている。 われわれのWSDL 2.0文書で定義される、インタフェース、バインディング、およびサービスの名前は、WSDL 2.0ターゲット名前空間と結び付けられる。つまり、別のWSDL 2.0ターゲット名前空間の類似した名前とは区別できる。(このことは、WSDL 2.0の、インポートやインタフェース継承メカニズムを使うときに、重要となる。)
WSDL 2.0ターゲット名前空間の値は、絶対URIでなければならない。さらに、そのWSDL 2.0ターゲット名前空間を記述に使うWebサービスを記述するWSDL 2.0文書を参照可能 (dereferenceable)であるべきである。例えば、GreatHのオーナーは、このURIからそのWSDL 2.0文書を得られるようにしておくべきである。(そしてもし、WSDL 2.0記述が複数の文書に分割されているのであれば、WSDL 2.0ターゲット名前空間はサービス記述に必要な全てのWSDL 2.0文書をインクルードするマスター文書を解決すべきである。)しかし、この参照可能 (dereferenceable)なURIに対する絶対的な要求はなく、WSDL 2.0処理系はそれが参照可能 (dereferenceable)であることに頼ってはならない。
この勧告は循環的に聞こえるかもしれないが、クライアントはWSDL 2.0文書をどこから得ても良いことを記憶しておいて欲しい -- そこは正規のソースである必要はない。しかし、WSDL 2.0ターゲット名前空間URIを参照 (dereferencing)することで、ユーザは正規なバージョンを得られるべきである。GreatHがそのサービスのオーナーとなるので、WSDL 2.0ターゲット名前空間URIはGreatH Webサイトか、その制御下にある場所を参照すべきである。
一度、我々がWSDL 2.0ターゲット名前空間URIを決定したら、我々のWSDL 2.0文書は、次の空のシェルから始めることができる。
<?xml version="1.0" encoding="utf-8" ?>
<description
xmlns="http://www.w3.org/ns/wsdl"
targetNamespace= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc"
. . . >
. . .
</description>
<description全てのWSDL 2.0文書は、最上位要素としてdescription要素を持つ。
これは単に、そのWSDL 2.0文書の残りの部分のコンテナとして働き、その文書を通して利用される名前空間の宣言に使われる。
xmlns="http://www.w3.org/ns/wsdl"これがWSDL
2.0自身のXML名前空間である。我々は、これに対する接頭辞を定義しないことによって、この例のデフォルト名前空間として割り当てた。
言い換えると、この例に現れる接頭辞のないあらゆる要素は、WSDL 2.0要素であると期待される(例えばdescription要素。)
targetNamespace="http://greath.example.com/2004/wsdl/resSvc"ここでは、先に述べたGreatH予約サービスのために我々が選択したWSDL 2.0ターゲット名前空間を定義している。 これが実際のXML名前空間宣言ではないことに注意して欲しい。 より正確には、これはXML Schemaターゲット名前空間と類似した目的を持つWSDL 2.0属性である。
xmlns:tns="http://greath.example.com/2004/wsdl/resSvc"これが、我々のGreatHサービス記述で使うための実際のXML名前空間宣言である。 このURIが、先ほどtargetNamespace属性の値として指定したものと同じであることに注意して欲しい。
こうすることによって、我々は後に、GreatHサービスのWSDL 2.0ターゲット名前空間を参照するために、Qnameの中でtns:接頭辞を使えるようになる。(QNameに関する詳細は、[XML Namespaces]第3章Qualified
Namesを参照。)
これで、我々はGreatHサービスを記述し始めることができる。
我々は、GreatHサービスがメッセージを送受信することを知っている。 サービスの記述の良い出発点は、サービスが用いるメッセージ型を定義することである。 そのために我々はXML Schemaを用いる。WSDL 2.0処理系は最低限XML Schemaをサポートしているものであるからである。 しかしながら、WSDL 2.0は他のスキーマ記述言語の利用を禁止しているわけではない。
WSDL 2.0では、メッセージ型をWSDL 2.0文書内で直接定義できる。定義場所はdescription要素の子要素であるtypes要素内である。
(あとで我々は、XML Schemaのimportメカニズムを使って、いかにして別々の文書で型定義を提供できるかを見ることになる。)
次のスキーマでは、我々が必要なcheckAvailability、checkAvailabilityResponseおよびinvalidDataErrorメッセージ型を定義している。
WSDL 2.0では、全ての正常およびフォルト・メッセージの型は、最上位レベルで単一の要素として定義されていなければならない(もちろん、各々の要素はその内部に任意の量の内部構造を持ってよい)。 つまり、メッセージ型は、複数の要素の連続や他の複合的な型から直接構成されてはならない。
<?xml version="1.0" encoding="utf-8" ?>
<description
xmlns="http://www.w3.org/ns/wsdl"
targetNamespace= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc"
. . . >
...
<types>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://greath.example.com/2004/schemas/resSvc"
xmlns="http://greath.example.com/2004/schemas/resSvc">
<xs:element name="checkAvailability" type="tCheckAvailability"/>
<xs:complexType name="tCheckAvailability">
<xs:sequence>
<xs:element name="checkInDate" type="xs:date"/>
<xs:element name="checkOutDate" type="xs:date"/>
<xs:element name="roomType" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="checkAvailabilityResponse" type="xs:double"/>
<xs:element name="invalidDataError" type="xs:string"/>
</xs:schema>
</types>
. . .
</description>
xmlns:ghns =
"http://greath.example.com/2004/schemas/resSvc"我々は別の名前空間宣言を追加した。ghns名前空間接頭辞は、(あとでインタフェースを定義するときに)我々のメッセージ型を定義するXML
Schemaターゲット名前空間を参照できるようにする。つまり、我々が指定したURIは、XML
Schema型のターゲット名前空間として定義するURI(次を参照)と同じでなければならない -- WSDL
2.0文書自身のターゲット名前空間ではない。
targetNamespace="http://greath.example.com/2004/schemas/resSvc"これがXML Schemaターゲット名前空間である。これは、GreatH予約サービスのために作ったものである。checkAvailability、checkAvailabilityResponseおよびinvalidDataError要素名は、このXML
Schemaターゲット名前空間と結び付けられる。
checkAvailability、checkAvailabilityResponseおよびinvalidDataErrorこれらは、我々が用いるメッセージ型である。先ほど説明したように、これらがXML要素となるように定義されていることに注意して欲しい。
我々は幾つかの型を定義してきたが、我々はまだどれがWebサービスで使われるメッセージ型なのかを示していない。次の節ではそれをやってみよう。
WSDL 2.0では、Webサービスの抽象機能の記述を、その機能が提供される具象的な方法と場所の詳細から分離できる。 こうして分離することによって、Webサービスとそれを記述するWSDL 2.0文書のライフサイクルにおいて、異なるレベルの再利用性と配布作業を促進する。
WSDL 2.0 interfaceは、抽象オペレーションの集合として、Webサービスの抽象インタフェースを定義し、各々のオペレーションは、クライアントとサービスの間の単純なやりとりを表現する。
各々のオペレーションが指定するのは、サービスがそのオペレーションの一部として送受信できるメッセージの型である。
各々のオペレーションは、メッセージ交換のパターンも指定する。このパターンは、関連するメッセージがパーティー間で転送されるシーケンスを示している。
例えば、in-outパターン(WSDL 2.0定義済み拡張 [WSDL 2.0 Adjuncts]第2.2.3節In-Out参照)は、もしクライアントがメッセージinをサービスに送ったら、サービスはクライアントにoutをメッセージとして送り返すか(正常ケースの場合)、フォルト・メッセージをクライアントに送り返す(異常ケースの場合)ことを示している。
我々は、より詳細なメッセージ交換パターンを、2.4.4.3
メッセージ交換パターン(Message Exchange Patterns (MEPs))の理解で説明する。
GreatHサービスのために、我々は(まず)単一のオペレーションopCheckAvailabilityを含んだインタフェースを定義する。これは、typesの節で定義したcheckAvailabilityとcheckAvailabilityResponseメッセージ型を用いる。
我々はこのオペレーションのためにin-outパターンを用いる。これが、単純な応答-要求型のやり取りを表現する最も自然なものだからである。我々はこれの代わりに(例えば)、in-onlyとout-onlyを用いた別々のオペレーションを定義することもできる(WSDL
2.0定義済み拡張 [WSDL 2.0 Adjuncts]第2.2.1節In-Onlyと第2.2.5節Out-Only参照)。しかし、それはクライアントにとっては複雑なだけの作業になる可能性がある。クライアント開発者に、応答-要求の組として二つのオペレーションを一緒に使うべきであることを、別途指示しなければならなくなるだろうからだ。
正常な入力と出力のメッセージに加えて、我々はエラー・イベントで使いたいフォルト・メッセージも指定する必要がある。WSDL
2.0は、オペレーションを横断してフォルトの再利用を促進するために、フォルト・メッセージはinterface要素内で宣言できる。もしフォルトが発生したら、そのオペレーションのメッセージ交換パターンで指定された、どのメッセージ・シーケンスであっても、終了する。
<?xml version="1.0" encoding="utf-8" ?>
<description
xmlns="http://www.w3.org/ns/wsdl"
targetNamespace= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc"
. . .
xmlns:wsdlx="http://www.w3.org/ns/wsdl-extensions">
. . .
<types>
...
</types>
<interface name = "reservationInterface" >
<fault name = "invalidDataFault"
element = "ghns:invalidDataError"/>
<operation name="opCheckAvailability"
pattern="http://www.w3.org/ns/wsdl/in-out"
style="http://www.w3.org/ns/wsdl/style/iri"
wsdlx:safe = "true">
<input messageLabel="In"
element="ghns:checkAvailability" />
<output messageLabel="Out"
element="ghns:checkAvailabilityResponse" />
<outfault ref="tns:invalidDataFault" messageLabel="Out"/>
</operation>
</interface>
. . .
</description>
<interface name =
"reservationInterface">インタフェースは、description要素の直接の内側で宣言される。
この例では、我々はインタフェースを一つだけ宣言しているが、一般的には、WSDL 2.0文書は一つ以上のインタフェースを宣言してよい。
つまり、各々のインタフェースには、このWSDL 2.0名前空間で定義されるインタフェースの集合のなかで一意になる名前を与えなければならない。
インタフェース名は、スペースやコロン (":")を含んではならないトークンである。
<fault name ="invalidDataFault"name属性は、このフォルト (fault)の名前を定義する。
この名前は、オペレーションが定義されるときに、望んでいるフォルトを名前で参照できるようにするために要求される。
フォルト名は、インタフェース内で一意であれば良い。
element
="ghns:invalidDataError"/>element属性が指定するのは、先にtypesの節で定義した、フォルト・メッセージのスキーマタイプである。
<operation
name="opCheckAvailability"name属性が定義するのは、このオペレーションの名前である。
こうすることによって、後で、バインディングが定義されるときに、参照可能になる。
また、オペレーション名は、インタフェース内で一意でなければならない。 (WSDL
2.0では、オペレーション名とフォルト名に対して、別々のシンボル空間を用いるので、オペレーション名"foo"はフォルト名"foo"とは区別される。)
pattern="http://www.w3.org/ns/wsdl/in-out"この行が指定するのは、このオペレーションが、先に説明したin-outパターンを使うことである。 WSDL 2.0では、誰かが将来、新しいパターンを定義できるようにするために、識別子がグローバルに重複しない(unambiguous)ことを確保できるよう、メッセージ交換パターンを識別するためにURIsを用いる。 (しかしながら、誰かが新しいパターンを定義し、それを識別するためのURIを作ったからといって、他のWSDL 2.0処理系が自動的にそのパターンを認識、あるいは解釈できるようになるわけではない。他の拡張と同様、それを認識して解釈しようとする処理系でだけ利用できる。)
style="http://www.w3.org/ns/wsdl/style/iri"この行は、このサービスの入力メッセージを定義するXMLスキーマが、IRI Styleで指定される規則の集合に従っていることを示している。IRI Styleは、そのメッセージが、IRIとしてシリアライズされることを保証している。
wsdlx:safe="true" >この行は、このオペレーションが、どういう形であれクライアントに責務を負わせないことを示している。つまり、クライアントは、そのサービスが責務を課すかもしれないこと(例えば、何かの購入に同意すること)を恐れることなく、そのオペレーションを安全に呼び出せる。このことは、2.4.4 インタフェース・オペレーションで更に説明する。
<input messageLabel="In"input要素は入力メッセージを指定する。我々が既にそのオペレーションが利用するメッセージ交換パターンを指定していても、メッセージ・パターンが表現するのはメッセージ・シーケンスのテンプレートであり、理論的には、複数の入力および/または出力メッセージで構成されるかもしれない。
従って、我々は、この特定の入力メッセージが表現するのが、そのパターンにおいて可能性のある入力メッセージのうちのどれであるかも、示さなければならない。
これがmessageLabel属性の目的である。 我々が選んだin-outパターンには唯一つの入力メッセージしかないので、この場合は当然の結論になる:我々は単に、メッセージ・ラベルに"In"を埋めるだけである。このラベル"In"は、in-outパターンを説明したWSDL
2.0定義済み拡張 [WSDL 2.0 Adjuncts]第2.2.3節In-Outで定義されている。
しかしながら、もし新しいパターンが複数の入力メッセージを含むように定義されていれば、そのパターンの異なるメッセージは異なるラベルを使って区別されることになるだろう。
element="ghns:checkAvailability"/>ここでは、この入力メッセージに対するメッセージ型を指定している。typesの節で定義済みのとおりである。
<output messageLabel="Out" . . .これは入力メッセージの定義と同様である。
<outfault
ref="tns:invalidDataFault" messageLabel="Out"/>ここでは、フォルト出力をこのオペレーションと結び付けている。 フォルトは、正常メッセージとは若干異なって宣言される。 ref属性が参照するのは、そのインタフェースで既に定義済みのフォルトの名前である
-- メッセージスキーマタイプを直接指定するわけではない。
メッセージ交換パターンは、一般的には、複数メッセージのシーケンスを含むので、フォルトはそのメッセージシーケンスのさまざまな場所で発生する可能性がある。
異なるフォルトを、そのシーケンス内の各々の許されたポイントに結び付けたいときは、この特定のフォルトに対する望むポイントを示すために、messageLabelが使われる。
パターンによって、このフォルトのトリガとなるメッセージと、フォルトが置換するメッセージのどちらかを指定することによって、間接的に行う。
(幾つかのパターンがmessage-triggers-fault規則を利用している;他のものはfault-replaces-message規則を利用している。WSDL
2.0定義済み拡張 [WSDL 2.0 Adjuncts]第2.1.2節メッセージによるフォルトの起動および第2.1.1節フォルトによるメッセージの置換を参照。)
ここまでで、我々は、GreatHサービスに対する抽象インタフェースを定義した。それに対するバインディングを定義する準備ができた。
我々は、どんな抽象メッセージがGreatHサービスで交換できるかを指定してきたが、まだどのようにそれらのメッセージが交換されるかを指定していない。これがバインディングの目的である。 バインディングが指定するのは、そのサービスに対する具体的なメッセージ・フォーマットと転送プロトコルの詳細であり、そのインタフェース内のあらゆるオペレーションとフォルトに対して、そのような詳細を提供しなければならない。
一般的な場合では、各々のオペレーションとフォルトに対する詳細のバインディングは、次の例のように、binding要素内のoperation要素とfault要素を使って指定される。
しかしながら、ある場合には、情報提供のためのデフォルト規則(指定を省略したときの規則)を使うこともできる。 例えば、WSDL 2.0
SOAPバインディング拡張では、オペレーションに対する幾つかのデフォルト規則を定義している。(Web Services
Description Language (WSDL) Version 2.0 Part 2: Adjuncts [WSDL 2.0 Adjuncts], デフォルト・バインディング規則参照。)
新しい種類のメッセージ・フォーマットと転送プロトコルを含めるために、バインディングは、WSDL 2.0オープン内容モデルによる、WSDL 2.0の拡張を利用して定義されている。 (拡張可能性に対する更なる情報は4.1拡張性参照。) WSDL 2.0 Part 2 [WSDL 2.0 Adjuncts]は、バインディング拡張を、SOAP 1.2 [SOAP 1.2 Part 1: Messaging Framework]とHTTP 1.1 [IETF RFC 2616]に対する、定義済み拡張として定義する。SOAP 1.2やHTTP 1.1バインディングがWSDL 2.0文書で簡単に定義できるようにするためである。 (任意の拡張に対してと同様に、他のWSDL 2.0処理系は、新しい構造については、利用するものについてだけ、認識するだろう。)
GreatHサービスのために我々は、次に示すとおり、具体的なメッセージ・フォーマットとしてSOAP 1.2、その下層の転送プロトコルとしてHTTPを利用する。
<?xml version="1.0" encoding="utf-8" ?>
<description
xmlns="http://www.w3.org/ns/wsdl"
targetNamespace= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc"
xmlns:wsoap= "http://www.w3.org/ns/wsdl/soap"
xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
. . .
<types>
. . .
</types>
<interface name = "reservationInterface" >
...
</interface>
<binding name="reservationSOAPBinding"
interface="tns:reservationInterface"
type="http://www.w3.org/ns/wsdl/soap"
wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">
<operation ref="tns:opCheckAvailability"
wsoap:mep="http://www.w3.org/2003/05/soap/mep/soap-response"/>
<fault ref="tns:invalidDataFault"
wsoap:code="soap:Sender"/>
</binding>
. . .
</description>
xmlns:wsoap="http://www.w3.org/ns/wsdl/soap"我々は、二つの名前空間宣言を追加した。一つは、WSDL 2.0 Part 3 [SOAP 1.2 Part 1: Messaging Framework]で定義されているSOAP
1.2バインディング拡張の名前空間である。そこでは、接頭辞wsoap:を持つ要素と属性の構造が定義されている。
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"この名前空間は、SOAP 1.2仕様自身で定義されている。 SOAP
1.2仕様では、特定のコンセプトを明確に識別する、この名前空間内の特定の用語を定義している。
つまり、それらの用語の一つを参照する必要があるときは、soap:接頭辞を利用することになる。
<binding
name="reservationSOAPBinding"バインディングは、description要素の直接的な内側で宣言する。 name属性が定義するのは、このバインディングの名前である。
各々の名前は、WSDL
2.0ターゲット名前空間内の全てのバインディングを通して一意でなければならず、あとで、このバインディングを参照するサービス・エンドポイントを定義するときに利用する。
WSDL
2.0では、インタフェース、バインディング、サービスのために、別々のシンボル空間を利用するので、インタフェース"foo"と、バインディング"foo"とサービス"foo"は区別される。
interface="tns:reservationInterface"これは、我々が指定するメッセージ・フォーマットと転送プロトコルに対するインタフェース名である。 2.5 バインディングの詳細で議論されているように、interface属性を省略することで、再利用可能なバインディングを定義することが可能になる。
また、tns:接頭辞を利用していることにも注意して欲しい。この接頭辞は、このWSDL
2.0文書に対する定義済みのWSDL 2.0ターゲット名前空間を参照している。この場合は、tns:接頭辞を指定しなければならないことが馬鹿らしく思えるかもしれないが、3.1 WSDLのインポートで、WSDL
2.0のインポーティング・メカニズムが、異なるWSDL
2.0ターゲット名前空間で定義されたコンポネントを、どのように結合できるかを見ることになる。
type="http://www.w3.org/ns/wsdl/soap"これは、利用する具体的メッセージフォーマットの種類を指定する。この場合はSOAP1.2である。
wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/"この属性は、WSDL 2.0のSOAPバインディング拡張に固有の属性である(そのため、wsoap:接頭辞を使っている)。
これは、下層で利用されるべき転送プロトコルを指定する。この場合はHTTPである。
<operation
ref="tns:opCheckAvailability"これは新しいオペレーションを定義しているわけではない;正しくは、定義済みのopCheckAvailabilityオペレーションを、そのバインディングの詳細を指定するために、参照している。
この要素は、代わりにデフォルト規則が必要な情報を提供するために使えるのであれば、省略することができる。(WSDL 2.0 Part 2 [WSDL 2.0 Adjuncts]第4.3節Default
Binding RulesのSOAPバインディング拡張を参照。)
wsoap:mep="http://www.w3.org/2003/05/soap/mep/soap-response">この属性も、WSDL 2.0のSOAPバインディング拡張に固有である。 これは、opCheckAvailabilityオペレーションが定義されたときに指定された、抽象WSDL
2.0メッセージ交換パターン(in-out)を実装するために使われるSOAPメッセージ交換パターン
(MEP)を指定する
下層の転送プロトコルにHTTPが使われるときは(この例の場合)、wsoap:mep属性で下層のHTTPメソッドとしてGETとPOSTの何れが使われるのかも制御する必要がある。
この場合は、wsoap:mep="http://www.w3.org/2003/05/soap/mep/soap-response"を利用していることが、デフォルトでGETが使われる原因となっている。2.5.7 HTTP GET対POST:
どちらを使うか?も参照。
<fault
ref="tns:invalidDataFault"バインディング・オペレーションと同様、これは新しいフォルトを宣言しているわけではない;正しくは、opCheckAvailabilityインタフェースで定義済みのフォルト(invalidDataFault)を、そのバインディングの詳細指定するために、参照している。
wsoap:code="soap:Sender"/>この属性も、WSDL 2.0のSOAPバインディング拡張に固有である。 これは、SOAP
1.2フォルト・コードを指定している。この指定によって、フォルト・メッセージが送信される。 もしそうしたいのであれば、任意指定のwsoap:subcodes属性を用いて、サブコードのリストを指定することもできる。
ここまでは、バインディングでどのようにメッセージが転送されるかを指定してきた。service要素を使って、どこでサービスにアクセスできるかを指定する準備ができた。
WSDL 2.0サービスは、サービスがサポートする単一のインタフェースと、サービスにアクセスできる一連のエンドポイントのロケーションを指定する。 各々のエンドポイントは、そのエンドポイントで利用されるプロトコルと転送フォーマットを指定する、定義済みのバインディングも参照しなければならない。 一つのサービスは一つのインタフェースしか持つことができない。(この制約に関する更なる議論は、5.4同一サービスに対する複数インタフェースを参照。)
我々のGreatHサービスに対する定義がこれである。
<?xml version="1.0" encoding="utf-8" ?>
<description
xmlns="http://www.w3.org/ns/wsdl"
targetNamespace= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc"
xmlns:wsoap= "http://www.w3.org/ns/wsdl/soap"
xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
. . .
<types>
. . .
</types>
<interface name = "reservationInterface" >
. . .
</interface>
<binding name="reservationSOAPBinding"
interface="tns:reservationInterface"
. . . >
. . .
</binding>
<service name="reservationService"
interface="tns:reservationInterface">
<endpoint name="reservationEndpoint"
binding="tns:reservationSOAPBinding"
address ="http://greath.example.com/2004/reservation"/>
</service>
</description>
<service
name="reservationService"ここでは、このサービスの名前を定義している。そのWSDL 2.0ターゲット名前空間内のサービス名を通して一意でなければならない。
name属性は必須である。WSDL 2.0記述でコンポネントを識別するためにURIsを作ることが許されている。 (WSDL
2.0 Core Language [WSDL 2.0 Core]
appendix C IRI
References for WSDL 2.0 constructsを参照。)
interface="tns:reservationInterface">ここでは、これらのエンドポイントがサポートする定義済みのインタフェースの名前を指定している。
<endpoint
name="reservationEndpoint"ここでは、サービスに対するエンドポイントと、そのエンドポイントの名前を定義している。エンドポイント名は、このサービス内で一意でなければならない。
binding="tns:reservationSOAPBinding"ここでは、このエンドポイントで使われる定義済みのバインディングを指定している。
address="http://greath.example.com/2004/reservation"/>ここでは、binding属性で指定されてバインディングを使ってこのサービスにアクセスできる物理的なアドレスを指定している。
That's it! だいたい終わった。
我々が見てきたとおり、WSDL 2.0文書は、本質的にサービスに対する一部だけの記述だけである。 サービスとやり取りするための基本的なメカニズム -- メッセージタイプ、転送プロトコル、サービスの場所、など -- を捕らえているにせよ、一般的には、それを利用するための他のアプリケーション・レベルの要求を説明する追加のドキュメンテーションが必要になる。 例えば、そのドキュメンテーションでは、そのサービスの目的と利用、全てのメッセージの意味、それらの利用に当たっての制約、オペレーションを呼び出すべき順番を説明すべきだ。
documentation要素は、WSDL 2.0記述者が、幾つかの人可読
(human-readable)ドキュメンテーションをWSDL 2.0文書内に含められるようにする。
また、このサービスを利用するクライアント開発者にとって必要な、任意の追加外部文書を参照する場所としても便利だ。
ここの例では、我々は文書の冒頭で実例として挙げているだけであるが、documentation要素はWSDL
2.0文書内に幾つでも記述することができる(2.2.1
WSDL 2.0インフォセット参照)。
<?xml version="1.0" encoding="utf-8" ?>
<description
. . . >
<documentation>
この文書はGreatHサービスについて記述している。
このサービスを利用するための、追加のアプリケーションレベルの要求 --
WSDL 2.0で記述できる範囲以上のもの -- は、次のURIで得られる:
http://greath.example.com/2004/reservation-documentation.html
</documentation>
. . .
</description>
<documentation>この要素は任意選択であるが、含めておくのは良いことである。この要素の内容には、任意の要素を混ぜて含んでよい。
at
http://greath.example.com/2004/reservation-documentation.html含めるべき最も重要なことは、そのサービスを利用するためにクライアント開発者が必要な全ての追加文書に対するポインタである。
これでGreatHサービスの例の提示が完了した。後続の節では、我々はWSDL 2.0仕様のさまざまな面に関する更なる詳細を見ていくことになる。
コンピュータ・サイエンスの理論では、言語はセンテンスの(上限のない)集合で構成され、各々のセンテンスは有限のリテラル・シンボルや文字から成る文字列である。 従って、言語仕様は、当該言語におけるセンテンスの集合を定義しなければならず、有用であるためには、各々センテンスの意味も示すべきである。 実際、これがWSDL 2.0仕様の目的である。
しかしながら、リテラル・シンボルや文字から成る用語においてWSDL
2.0を定義する代わりに、特定の文字符号化に依存することを避けるために、WSDL 2.0はXMLインフォセット [XML Information Set]の用度で定義されている。 特に、WSDL
2.0文書は、WSDL 2.0仕様に適合する(XMLインフォセットにおける)description要素インフォメーション・アイテムによって構成される。
言い換えると、WSDL 2.0言語のセンテンスは、WSDL 2.0仕様で言い表された追加制約に従う、description要素のインフォメーション・アイテムである。
XMLインフォセットは、一つ以上の物理的文書から作り出し得るので、WSDL 2.0文書は単一の物理的文書に対応付ける必要なくてもよい:ここでは便宜上、比喩的に「文書」という言葉を遣った。
更に、WSDL 2.0はimport and includeメカニズムを提供する。ここでは、WSDL
2.0文書は、組織化と再利用の便宜の促進のために、他のWSDL 2.0文書を参照する。
このような場合では、インクルードしたりインポートしたりする文書全体の意味は、インクルードされたりインポートされたりする文書の意味に(部分的に)依存する。
XMLインフォセットは、「要素インフォメーション・アイテム」や「属性インフォメーション・アイテム」のような用語を利用する。 不幸にも、これらの用語は頻繁に繰り返すには長すぎる。そのため、便宜上、この入門では、「要素」や「属性」と云う用語を、省略記法として、頻繁に利用している。 しかしながら、WSDL 2.0はXMLインフォセットに基づいているので、それぞれ、実際には「要素インフォメーション・アイテム」や「属性インフォメーション・アイテム」を意味していることを、理解しておくべきである。
WSDL 2.0仕様は、[XML Schema Structures]で定義された規範的WSDL 2.0スキーマを提供する。これは、WSDL 2.0の妥当性検証 (validation)の材料として利用できる。 我々がここで「材料として」と云ったのは、WSDL 2.0仕様[WSDL 2.0 Core]はしばしばWSDL 2.0スキーマに対する更なる制約も提供するからだ。 規範的なスキーマに対して妥当であることに加えて、WSDL 2.0文書はWSDL 2.0仕様で定義された全ての制約にも従っていなければならない。
この節では、最上位のWSDL 2.0要素の順番に関して、WSDL 2.0仕様がWSDL 2.0スキーマをどのように制約するかの例を与える。
WSDL 2.0スキーマが要素の順序についての要求を示していないくても、WSDL 2.0仕様(WSDL 2.0 Part 1 [WSDL 2.0 Core] section "XML
Representation of Description Component")では、description要素の子要素がどのような順序を持つべきかの制約の集合を明確に表明している。
こうして、WSDL 2.0スキーマがこの制約を含んでいないとしても、WSDL 2.0要素の順序は問題となる。
次の例は、description要素の擬似内容モデルである。
<description> <documentation />? [ <import /> | <include /> ]* <types />? [ <interface /> | <binding /> | <service /> ]* </description>
言い換えると、description要素の子要素は、次のように並ぶべきである:
もしあれば、任意指定のdocumentation要素が最初に来る。
次に、次のものの中から、任意の順序で、ゼロ個以上の要素が来る:
include
import
拡張要素
任意指定のtypes要素が続く
次のものの中から、任意の順序で、ゼロ個以上の要素が来る:
interface
binding
service
拡張要素
ここでは「拡張要素」という用語は、名前空間指定された拡張要素を指す便法として遣われている。 それらの拡張要素の名前空間名は、"http://www.w3.org/ns/wsdl"であってはならない。
先ほどのWSDL 2.0インフォセット・モデルは、XMLインフォセットを用いて、WSDL 2.0文書の構造の要求を説明している。 しかしながら、WSDL 2.0言語はこのXMLインフォセットに対する、構造的な適合性にまたがって超越する、多くの意味的な制約も課している。 これらの制約を正確に記述するために、また、WSDL 2.0文書の意味を正確に定義する材料として、WSDL 2.0仕様では、XMLインフォセットを超越した追加の抽象レイヤとして、コンポネント・モデルを定義する。 制約と意味はこのコンポネント・モデルで定義され、各々のコンポネントの定義は、そのコンポネント・モデルにおける値を、XMLインフォセットの対応するアイテムから抜き出す方法のマッピングを含んでいる。 次のダイアグラムは、WSDL 2.0コンポネントとその内容の階層に関する概要を与える。
一般的には、WSDL 2.0コンポネント・モデルは、先ほど説明したXMLインフォセットで要求される構造とは平行関係にある。
例えば、Description, Interface, Binding, Service
and Endpointコンポネントは各々、description, interface,
binding, service, and endpoint要素インフォメーションアイテムに対応する。
WSDL 2.0言語における構造の意味を含むのに、WSDL
2.0はコンポネント・モデルに深く頼っているので、Descriptionコンポネントを、description要素インフォメーション・アイテムの意味を表わすものとして考えることができて、従って、それは、全体としては、WSDL
2.0文書の意味を表わしている。
更に、これらのコンポネントの各々がプロパティを持っている。プロパティの値は、(通常は)それらの要素インフォメーション・アイテムの子供となる要素インフォメーション・アイテムと属性インフォメーションアイテムから抽出される。
例えば、Serviceコンポネントはservice要素インフォメーション・アイテムに対応し、Serviceコンポネントは{endpoint}プロパティを持つ。{endpoint}プロパティの値は、service要素インフォメーション・アイテムの子供であるendpoint要素に対応するEndpointコンポネントの集合である。(Whew!)
WSDL 2.0コンポネント・モデルは、特に、import and include要素の意味を定義するのに役に立つ。
include要素のおかげで、名前空間のコンポネントを定義する複数のWSDL 2.0文書から、与えられたWSDL
2.0名前空間の内容をつなぎ合わせることができる。 ある与えられたWSDL
2.0文書で定義される複数のコンポネントは、その文書に定義が含まれるものと、include要素によってその文書に含まれるWSDL
2.0文書で定義されるものから構成される。 include要素の効果は、もし文書Aが文書Bを含み、文書Bが文書Cを含むのであれば、文書Aによって定義されるコンポネントは、文書A,
B, Cに含まれる定義によって構成されるという、蓄積的なものである。
対照的に、import 要素は、いかなるコンポネントも定義しない。 代わりに、import要素が宣言するのは、与えられたWSDL
2.0名前空間に対するWSDL 2.0文書に定義が含まれるコンポネントが、別のWSDL 2.0名前空間に属するコンポネントを参照することである。
もし、WSDL 2.0文書が他の名前空間を参照するコンポネント定義を含むのであれば、それらの名前空間はimport要素で宣言されていなければならない。
import要素はまた、任意指定のlocation属性を持っていて、これは、処理系に対して、インポートされた名前空間の定義がどこで得られるかのヒントになる。
しかしながら、処理系は、他の手段、例えば、カタログを利用することで、定義を見つけるかもしれない。
なんらかのinclude要素が処理され、なんらかのインポートされた名前空間に属するコンポネントの場所が特定された後は、そのWSDL
2.0文書のWSDL 2.0コンポネント・モデルは、その文書のWSDL
2.0名前空間となんらかのインポートされた名前空間と属するコンポネント群の集合を含むようになる。
これらのコンポネントは、通常はQName参照によって、お互いに参照しあう。
もし何らかのコンポネント参照が解決できないのであれば、その参照されているコンポネントが属している名前空間が、同じものであれ、別のものであれ、そのWSDL
2.0文書は不正である。
WSDL 2.0のインポートとインクルードの使い方については、3.1 WSDLのインポートで、より多くをカバーする。
メッセージ型は、さまざまなスキーマ言語で定義され得る。 この入門では、WSDL
2.0でネイティブ・サポートされているために、XML Schema [XML
Schema Structures]の利用だけに集中している。 他の言語で定義されたメッセージ型は、拡張のWSDL 2.0 descriptionの中で導入されるかもしれない。更なる詳細は、W3Cノート[Alternative Schema Languages Support]を参照。
次のものは、wsdl:types要素のXMLシンタックスである:
<description>
<types>
<documentation />*
[ <xs:import namespace="xs:anyURI" schemaLocation="xs:anyURI"? /> |
<xs:schema targetNamespace="xs:anyURI" /> |
other extension elements ]*
</types>
</description>
WSDL 2.0文書で、XML Schemaメッセージ定義を可視化、言い換えると、QName(WSDL 2.0 Part 1 [WSDL 2.0 Core] "QName
Resolution"参照)で参照できるようにするためには、二つの方法がある:インライン化とインポートである。 インライン化は、types配下のxs:schema要素内に、直接スキーマ定義を配置することである。
インポートは、スキーマを別の文書内に定義し、types直下のxs:importを使って、WSDL定義に持ち込むことである。
後続の節では、別のメカニズムの例を提供する。
我々は、すでに2.1.3
メッセージ型の定義の中で、既にインライン化スキーマを利用した例を見てきた。 WSDL
2.0文書の中で、XMLスキーマが直にインライン化される場合、これを実現するためには、既存の最上位レベルのXMLスキーマによって定義されたxs:schema要素を利用する。これは、まるでtypes要素内にスキーマファイルがコピー&ペーストされたようなものである。
インライン化されたスキーマで定義されたスキーマ・コンポネントは、包含WSDL 2.0 descriptionでQNameで参照するために利用できるようになる。
例えば、例2-1では、インタフェース・オペレーション"opCheckAvailability"の入力メッセージは、インライン化されたスキーマの"ghns:checkAvailability"要素で定義される。
XML Schemaコンポネントは、分離されたスキーマファイルで定義可能であり、types要素直下のxs:importを用いて、WSDL2.0
descriptionで利用可能できる。
分離されたスキーマファイルでスキーマを定義したくなるときには、多くの場合がる。 一つの理由は、スキーマ定義の再利用性だ。
インライン化されたスキーマ定義は、包含WSDL 2.0 descriptionでしか利用できない。 WSDL
2.0は、他のWSDLファイルをインポートするためのwsdl:importメカニズムを提供する。
インポートされたWSDL文書内でインライン化されているスキーマ定義は、他のWSDL
2.0コンポネント(インタフェース、バインディングなど)が利用可能になったとしても、自動的にはインポートするWSDL
2.0文書で利用可能にはならない。 従って、もし複数のWSDL 2.0 descriptionでスキーマ定義を共有したいのであれば、これらのスキーマ定義は別のXML
Schema文書に配置しておき、types直下のxs:importを使って、各々のWSDL
2.0 descriptionへインポートすべきである。
例を見てみよう。 例2-3のメッセージ型が、ターゲット名前空間"http://greath.example.com/2004/schemas/resSvc"を持つ別のスキーマファイル"http://greath.example.com/2004/schemas/resSvc.xsd"で定義されているとすると、そのスキーマ定義は、xs:importを使ってWSDL
2.0 descriptionの中に持ち込むことができる。
インポートされた名前空間"http://greath.example.com/2004/schemas/resSvc"内のコンポネントだけが、WSDL
2.0文書内で参照するために利用可能になることに注意して欲しい。
例2-8.
xs:importされたメッセージ定義。包含WSDL 2.0 Descriptionから可視的になる
<?xml version="1.0" encoding="utf-8" ?>
<description xmlns="http://www.w3.org/ns/wsdl"
targetNamespace= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc"
. . . >
. . .
<types>
<xs:import namespace="http://greath.example.com/2004/schemas/resSvc"
schemaLocation= "http://greath.example.com/2004/schemas/resSvc.xsd"/>
</types>
. . .
</description>
wsdl:typesの直下で使われているxs:importが、インライン化されたスキーマ内で使われいてるxs:importとは異なる可視性を与えられていることに注意を向けることが重要である。
インライン化されたスキーマは、異なる名前空間内にある外部のスキーマ定義を持ち込むために、ネイティブXMLスキーマxs:importを使ってもよい;
しかしながら、これがWS-I
Basic ProfileのWSDL 1.1に対して勧告されたスキーマのインーポーティング・メカニズムであっても、XML
Schema仕様によれば、そのような閉じたメッセージ定義は、インポートしているスキーマ(この例では、インライン化されたスキーマ)に対してしか可視的ではない。
それらは、包含WSDL 2.0 descriptionに対して可視的ではない。
もし我々が例2-8を、インライン化されたスキーマ内のXML
Schemaネイティブxs:import要素を使うように変更すると、http://greath.example.com/2004/schemas/resSvcで定義されるスキーマ・コンポネントは、我々の例のWSDL
2.0定義のどこでも利用できなくなる。
例2-9.
インライン化されたスキーマ内のxs:importされたメッセージ定義は、包含WSDL 2.0
Descriptionに対して可視的ではない
<?xml version="1.0" encoding="utf-8" ?>
<description xmlns="http://www.w3.org/ns/wsdl"
targetNamespace= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc"
. . . >
. . .
<types>
<xs:schema targetNamespace="http://greath.example.com/2004/schemas/resSvcWrapper">
<xs:import namespace="http://greath.example.com/2004/schemas/resSvc"
schemaLocation= "http://greath.example.com/2004/schemas/resSvc.xsd"/>
</xs:schema>
</types>
. . .
</description>
もちろん、インライン化されたXML
Schemaは、インクルードされるスキーマが名前空間を持たない場合やインクルードするスキーマと同じ名前空間を持つ場合は、別のファイルに定義されたスキーマを参照するために、XML
Schemaのネイティブxs:include要素を使ってもよい。 この場合は、XML
Schemaによれば、インクルードされたスキーマ・コンポネントは、あたかもインクルードするスキーマにコピー&ペーストされたかのように、インクルードするスキーマの一部となる。
従って、インクルードされたスキーマコンポネントは、包含するWSDL 2.0 descriptionに対して、QNameによる参照のために利用可能でもある。
次の例は、例2-3と同様の効果を持つ:
例2-10.
インライン化されたスキーマ内のxs:includeされたメッセージ定義は、包含WSDL 2.0
Descriptionに対して可視的になる
<?xml version="1.0" encoding="utf-8" ?>
<description xmlns="http://www.w3.org/ns/wsdl"
targetNamespace= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:tns= "http://greath.example.com/2004/wsdl/resSvc"
xmlns:ghns = "http://greath.example.com/2004/schemas/resSvc"
. . . >
. . .
<types>
<xs:schema targetNamespace="http://greath.example.com/2004/schemas/resSvc">
<xs:include schemaLocation= "http://greath.example.com/2004/schemas/resSvc.xsd"/>
</xs:schema>
</types>
. . .
</description>
ここまでで、我々はWSDLインポートとインクルード、およびスキーマ・インポートとインクルードの両方を簡単にカバーした。
次の表は、WSDL 2.0とML Schemaのincludeおよびimportメカニズム間に見られる類似と差異をまとめたものだ。
我々は、3.1
WSDLのインポートと3.2
Schemaのインポートで、インポーティング・メカニズムについて、もっと多くのことを話題にする。
| メカニズム | 対象 | 意味 | スキーマコンポネントの可視性 |
|---|---|---|---|
wsdl:import |
WSDL 2.0名前空間 | WSDL 2.0コンポネントが、異なったtargetNamespaceからWSDL 2.0コンポネントを参照することを宣言する。 | インポートされたDescriptionコンポネント内のXML
Schemaコンポネントは、包含descriptionに対して可視的ではない。 |
wsdl:include |
WSDL 2.0文書 | 同じtargetNamespaceを持つ別のWSDL 2.0文書から、Interface, Binding, Serviceコンポネントをマージする。 | インクルードされたDescriptionコンポネントの{要素宣言}と{型定義}プロパティ内のXML
Schemaコンポネントは、包含descriptionに対して可視的になる。 |
wsdl:types/ xs:import |
XML Schema名前空間 | XML Schemaコンポネントが、異なったtargetNamespaceからXML Schemaコンポネントを参照することを宣言する。 | インポートされた名前空間内のXML Schemaコンポネントは、包含descriptionに対して可視的になる。 |
wsdl:types/ xs:schema/
xs:import |
XML Schema名前空間 | XML Schemaコンポネントが、異なったtargetNamespaceからXML Schemaコンポネントを参照することを宣言する。 | インポートされた名前空間内のXML Schemaコンポネントは、包含descriptionに対して可視的ではない。 |
wsdl:types/ xs:schema/
xs:include |
XML Schema文書 | 同じtargetNamespaceか、targetNamespaceを持たない、別のXML Schema文書からXML Schema文書をマージする。 | インクルードされた文書内のXML Schemaコンポネントは、包含descriptionに対して可視的になる。 |
我々は、先ほど、WSDL 2.0インタフェースは、基本的にはオペレーションの集合であると述べた。
しかしながら、我々がまだカバーしていない追加能力も存在する。 手始めに、interface要素のシンタックスを見てみよう。
次の挙げたものが、interface要素のXMLシンタックスのサマリーである。単純化のために、任意指定の<documentation>要素については省略してある:
<description targetNamespace="xs:anyURI" >
. . .
<interface name="xs:NCName"
extends="list of xs:QName"?
styleDefault="list of xs:anyURI"? >
<fault name="xs:NCName"
element="xs:QName"? >
</fault>*
<operation name="xs:NCName"
pattern="xs:anyURI"
style="list of xs:anyURI"?
wsdlx:safe="xs:boolean"? >
<input messageLabel="xs:NCName"?
element="union of xs:QName, xs:Token"? >
</input>*
<output messageLabel="xs:NCName"?
element="union of xs:QName, xs:Token"? >
</output>*
<infault ref="xs:QName" messageLabel="xs:NCName"? > </infault>*
<outfault ref="xs:QName" messageLabel="xs:NCName"? > </outfault>*
</operation>*
</interface>*
. . .
</description>
interface要素には二つの任意指定の属性がある:styleDefaultとextendsだ。
styleDefault属性は、このインタフェース配下の全てのオペレーションに対するstyle属性のデフォルト値を定義するために使える(WSDL
2.0 Part 1 "styleDefault属性インフォメーション・アイテム"参照)。
extends属性は、継承のためのもので、次に説明する。
任意指定のextends属性によって、インタフェースを、一つ以上のインタフェースから拡張あるいは継承できるようになる。
このような場合では、インタフェースは、それが直接定義するインタフェースと共に、それが拡張する複数のインタフェースを含んでいる。
インタフェースの拡張に関して二つの事柄が、いくらかの注意を払うに値する。
第一に、継承ループ(または無限再起)は禁止されている: あるインタフェースが継承するインタフェースは、それら自身ではそのインタフェースを、直接的と間接的とを問わず、継承してはならない。
第二に、二つの異なるインタフェースが、同じターゲット名前空間とオペレーション名を持つとき、何が起こるかを説明しなければならない。 これには二つの場合がある:それらのオペレーションのコンポネント・モデルが、同じであるか、異なっているかだ。 もしコンポネント・モデルが同じであれば(WSDL 2.0 Part 1 [WSDL 2.0 Core] " 等価なコンポネント"で定義されているコンポネント競合アルゴリズムを参照)、それらは同じオペレーションであるとみなさなけれる、例えば、それらは一つのオペレーションに縮約され、一度以上含まれているという事実は、エラーとは考えられない。 (オペレーションにとっては、コンポネント等価性は、基本的には二つのオペレーションが、同じ属性と子孫の集合を持つことを意味している。) 第二の場合、二つのオペレーションが同一WSDL 2.0ターゲット名前空間内で同じ名前を持つが、それらが等価ではない場合は、エラーである。 上記の理由で、同一の名前空間内の全てのオペレションは一意に名付けられていることを保証することは、グッド・プラクティスであると考えられる。
最後に、フォルトはinterface要素の子供として定義され得るので(次の節で記述されるように)、同一の名前競合規則がそれらの構造に適用される。
GreatHホテルが、全ての応答メッセージに対する標準的なメッセージ・ログ・オペレーションをメンテナンスしたいとしよう。
そこでは、このオペレーションが全ての予約システムをまたがって再利用可能であることを求めている。各々のサービスが、潜在的にロギング・サービスを利用するために、タイムスタンプとメッセージのオリジネータと一緒に受信する各メッセージの内容を送信する。
この要求を満たす一つの方法は、他のインタフェースによって継承されるインタフェースの中で、ログ・オペレーションを定義することである。 messageLog要素が、既にghns名前空間内に、要求されている内容で定義されているとすると、継承ユースケースは次の例のように説明される。
継承の結果、reservationInterfaceは、このとき、二つのオペレーションを含む:opCheckAvailabilityとopLogMessageだ。
<description ...>
...
<interface name = "messageLogInterface" >
<operation name="opLogMessage"
pattern="http://www.w3.org/ns/wsdl/out-only">
<output messageLabel="out"
element="ghns:messageLog" />
</operation>
</interface>
<interface name="reservationInterface" extends="tns:messageLogInterface" >
<operation name="opCheckAvailability"
pattern="http://www.w3.org/ns/wsdl/in-out"
style="http://www.w3.org/ns/wsdl/style/iri"
wsdlx:safe = "true">
<input messageLabel="In"
element="ghns:checkAvailability" />
<output messageLabel="Out"
element="ghns:checkAvailabilityResponse" />
<outfault ref="tns:invalidDataFault" messageLabel="Out"/>
</operation>
</interface>
...
</description>
interfaceの子要素について見ていこう、faultから始める。
fault要素は、インタフェースのオペレーションの実行中に発生するかもしれないフォルトを宣言するために使われる。
それらは、複数のオペレーションにまたがって再利用できるようにするために、interface直下で宣言され、それらが適用されるオペレーションから参照される。
フォルトはメッセージととてもよく似ており、特殊なメッセージとしてみなせる。 フォルトとメッセージは両方とも、通常は要素宣言によって記述されるパイロードを運ぶかもしれない。 しかしながら、WSDL 2.0はフォルトとメッセージを若干異なる方法で扱う。 オペレーションのメッセージはその要素宣言を直接参照するが、オペレーションのフォルトはその要素宣言を、インタフェースで定義されたフォルト要素を通して、間接的に参照する。
フォルトをインタフェースレベルで定義する理由は、それらを複数のオペレーションにまたがって再利用できるようにするためだ。 この設計は特にバインディングが定義されるときに有用である。SOAPのようなバインディング拡張では、フォルトと関連する追加情報が存在するからだ。 SOAPの場合、フォルトはペイロードに加えて、コードとサブコードを持つ。 フォルトをインタフェース・レベルで定義することで、共通コードとサブコードを、それらと関連らセルことができる。よって、それらのフォルトを利用する全てのオペレーションにまたがる一貫性を保証することになる。
fault要素は、親のinterface要素内で一意でなければならない、必須のname属性を持つ。この属性は、オペレーション宣言から参照されることを許す。
任意のelement属性は、フォルト・メッセージの内容、つまりペイロードのスキーマを示すために使える。 その値は、typesセクションで定義したグローバル要素のQNameであるべきである。
他の型システムがフォルト・メッセージのスキーマを定義するために使われるときは、そのスキーマをフォルトと関連されられるように、WSDL
2.0属性拡張メカニズムによって、追加属性の定義が必要になるかもしれないことに注意して欲しい。
先ほど示したように、operation要素は、包含インタフェースによってサポートされるオペレーションを示すために使われる。
それは、Webサービスとの単純なやりとりを抽象的に記述するために、メッセージ・スキーマとメッセージ交換パターン(MEP)を関連付ける。
operationは、二つの必須属性と、一つの任意属性を持つ:
必須name属性は、既に見てきたとおり、インタフェース内で一意でなければならない。
必須pattern属性の値は、そのオペレションに対して望んでいるMEPを識別する絶対URIでなければならない。MEPsについては、2.4.4.3
メッセージ交換パターン(Message Exchange Patterns (MEPs))の理解で更に説明されている。
任意style属性の値は、絶対URIsのリストである。各々のURIは、このoperation定義で従うある規則集合を識別する。もし、特定のスタイルが指定されているが、関連する規則が守られないのであれば、エラーである。[WSDL 2.0 Adjuncts]では、次のものを含むスタイルの集合が定義されている
RPCスタイル。RPCスタイルは、styleの値にhttp://www.w3.org/ns/wsdl/rpcを割り当てるときに選択される。
リモートプロシジャーコール型のやりとりに制約とするときに使われる。
IRIスタイル。IRIスタイルは、styleの値にhttp://www.w3.org/ns/wsdl/style/iriを割り当てるときに選択される。
HTTP URLエンコードのような形にシリアライズされるかもしれないメッセージ定義の制約に使われる。
Multipartスタイル。Multipartスタイルは、styleの値にhttp://www.w3.org/ns/wsdl/style/multipartを割り当てるときに選択される。
HTTPバインディングでは、XFormsクライアントに対して、メッセージはMultipartスタイルに従って定義し、"Multipart/form-data"としてシリアライズされなければならない。
これらのWSDL 2.0定義済みスタイルの更なる詳細を見つけることができる。 4.3
RPC Style節では、RPC styleの利用例を提供する。 [WSDL 2.0 Adjuncts]では、IRIスタイルとMultipartスタイルの例を提供する。
[WSDL 2.0 Adjuncts]がオペレーションの安全性を示す定義済み拡張を提供することに注意して欲しい。
ブーリアン値を持つwsdlx:safeグローバル属性は、クライアントからの呼び出しに対して、そのオペレーションが"safe"である(Section
3.5 of the Web Architecture [Web
Architecture]で定義されている)と注釈されているかどうかを示すためにオペレーションに指定できる。
本質的には、安全なオペレーションとは、クライアントに対していかなる新しい責務も負わせない任意のオペレーションのことである。
例えば、クライアントが製品の価格を確認できるオペレーションは、通常はクライアントにそれらの製品を購入させる責務を負わせないであろうから、安全であるだろう。一方、製品購入のオペレーションは、クライアントに注文された製品に対する支払いの責務を負わせるだろう。
Web Architecture [Web
Architecture]のセクション3.5で定義されている安全なやり取りの条件を満たすのであれば、オペレーションは安全であるとマークされるべき(このマークにはwsdlx:safeを用い、その値には"true"をセットする)である。
このことによって、基盤が有効な最適化、例えば、プリ・フェッチ、リフェッチ、キャッシングなどを行えるからである。
この属性のデフォルト値は偽(false)である。 もし偽または何も設定されていないのであれば、そのオペレーションの安全性については一切注釈されない;つまり、そのオペレーションは、安全であるかもしれないし、そうでないかもしれない。
An operation will also have input, output,infault,
and/or outfault element children that specify the ordinary
and fault message types to be used by that operation. The MEP specified
by the pattern attribute determines which of these elements
should be included, since each MEP has placeholders for the message
types involved in its pattern.
Since operations were already discussed in 2.1.4 Defining an Interface, this section will merely comment on additional capabilities that were not previously explained.
The messageLabel attribute of the input
and output elements is optional. It is not necessary to
explicitly set the messageLabel when the MEP in use is one
of the eight MEPs predefined in WSDL 2.0 Part 2 [WSDL 2.0 Adjuncts] and it has only one message
with a given direction.
The element attribute of the input and
output elements is used to specify the message content
schema (aka payload schema) when the content model is defined using XML
Schema. As we have seen already, it can specify the QName of an element
schema that was defined in the types section. However,
alternatively it can specify one of the following tokens:
#anyThe message content is any single element.
#noneThere is no message content, i.e., the message payload is empty.
#otherThe message content is described by a non-XML type system. Extension attributes specify the type.
The element attribute is also optional. If it is not
specified, then the message content is described by a non-XML type
system.
Note that there are situations that the information conveyed in
the element attribute is not sufficient for a service
implementation to uniquely identify an incoming message and dispatch it
to an appropriate operation. In such situations, additional means may be
required to aid identifying an incoming message. See 5.1 Enabling Easy
Message Dispatch for more detail.
WSDL 2.0 message exchange patterns (MEPs) are used to define the sequence and cardinality of the abstract messages in an operation. By design, WSDL 2.0 MEPs are abstract. First of all, they abstract out specific message types. MEPs identify placeholders for messages, and placeholders are associated with specific message types when an operation is defined, which includes specifying which MEP to use for that operation. Secondly, unless explicitly stated otherwise, MEPs also abstract out binding-specific information like timing between messages, whether the pattern is synchronous or asynchronous, and whether the messages are sent over a single or multiple channels.
It's worth pointing out that WSDL 2.0 MEPs do not exhaustively describe the set of messages that may be exchanged between a service and other nodes. By some prior agreement, another node and/or the service may send other messages (to each other or to other nodes) that are not described by the MEP. For instance, even though an MEP may define a single message sent from a service to one other node, a service defined by that MEP may multicast that message to other nodes. To maximize reuse, WSDL 2.0 message exchange patterns identify a minimal contract between other parties and Web Services, and contain only information that is relevant to both the Web service and the client that engages that service.
A total of eight MEPs are defined in [WSDL 2.0 Adjuncts]. These MEPs should cover the most common use cases, but they are not meant to be an exhaustive list of MEPs that can ever be used by operations. More MEPs can be defined for particular application needs by interested parties. (See 2.4.4.3 Understanding Message Exchange Patterns (MEPs) )
For the eight MEPs defined by WSDL 2.0, some of them are variations of others based on how faults may be generated. For example, the In-Only pattern ("http://www.w3.org/ns/wsdl/in-only") consists of exactly one message received by a service from some other node. No fault can be generated. As a variation of In-Only, Robust In-Only pattern ("http://www.w3.org/ns/wsdl/robust-in-only") also consists of exactly one message received by a service, but in this case faults can be triggered by the message and must be delivered to the originator of the message. If there is no path to this node, the fault must be discarded. For details about the common fault generation models used by the eight WSDL 2.0 MEPs, see [WSDL 2.0 Adjuncts].
Depending on how the first message in the MEP is initiated, the eight WSDL 2.0 MEPs may be grouped into two groups: in-bound MEPs, for which the service receives the first message in the exchange, and out-bound MEPs, for which the service sends out the first message in the exchange. (Such grouping is not provided in the WSDL 2.0 specification and is presented here only for the purpose of easy reference in this primer).
A frequently asked question about out-bound MEPs is how a service
knows where to send the message. Services using out-bound MEPs are
typically part of large scale integration systems that rely on mapping
and routing facilities. In such systems, out-bound MEPs are useful for
specifying the functionality of a service abstractly, including its
requirements for potential customers, while endpoint address information
can be provided at deployment or runtime by the underlying integration
infrastructure. For example, the GreatH hotel reservation system may
require that every time a customer interacts with the system to check
availability, data about the customer must be logged by a CRM system. At
design time, it's unknown which particular CRM system would be used
together with the reservation system. To address this requirement, we
may change the "reservationInterface" in 例2-1
to include an out-bound logInquiry operation. This logInquiry
operation advertises to potential service clients that customer data
will be made available by the reservation service at run time. When the
reservation service is deployed to GreatH's IT landscape, appropriate
configuration time and run time infrastructure will help determine which
CRM system will get the customer data and log it appropriately. It's
worth noting that in addition to being used by a CRM system for customer
management purpose, the same data may also be used by a system
performance analysis tool for different purpose. Providing an out-bound
operation in the reservation service enables loose coupling and so
improves the overall GreatH IT landscape's flexibility and scalability.
<description ...>
...
<interface name="reservationInterface">
...
<operation name="opCheckAvailability" ... >
<operation name="opLogInquiry"
pattern="http://www.w3.org/ns/wsdl/out-only">
<output messageLabel="Out" element="ghns:customerData" />
</operation>
</interface>
...
</description>
Although the eight MEPs defined in WSDL 2.0 Part 2 [WSDL 2.0 Adjuncts] are intended to cover most use cases, WSDL 2.0 has designed this set to be extensible. This is why MEPs are identified by URIs rather than a fixed set of tokens.
For more about defining new MEPs, see 4.2 Defining New MEPs.
Bindings are used to supply protocol and encoding details that
specify how messages are to be sent or received. Each binding
element uses a particular binding extension to specify such
information. WSDL 2.0 Part 2 [WSDL
2.0 Adjuncts] defines several binding extensions that are typically
used. However, binding extensions that are not defined in WSDL 2.0 Part
2 can also be used, provided that client and service toolkits support
them.
Binding information must be supplied for every operation in the interface that is used in an endpoint. However, if the desired binding extension provides suitable defaulting rules, then the information will only need to be explicitly supplied at the interface level, and the defaulting rules will implicitly propagate the information to the operations of the interface. For example, see the Default Binding Rules of SOAP binding extension in WSDL 2.0 Part 2 [WSDL 2.0 Adjuncts].
Since bindings are specified using extensions to the WSDL 2.0 language (i.e., binding extensions are not in the WSDL 2.0 namespace), the XML for expressing a binding will consist of a mixture of elements and attributes from WSDL 2.0 namespace and from the binding extension's namespace, using WSDL 2.0's open content model.
Here is a syntax summary for binding, simplified by
omitting optional documentation elements. Bear in mind that
this syntax summary only shows the elements and attributes defined
within the WSDL 2.0 namespace. When an actual binding is defined,
elements and attributes from the namespace of the desired binding
extension will also be intermingled as required by that particular
binding extension.
<description targetNamespace="xs:anyURI" >
. . .
<binding name="xs:NCName" interface="xs:QName"? >
<fault ref="xs:QName" > </fault>*
<operation ref="xs:QName" >
<input messageLabel="xs:NCName"? > </input>*
<output messageLabel="xs:NCName"? > </output>*
<infault ref="xs:QName" messageLabel="xs:NCName"? > </infault>*
<outfault ref="xs:QName" messageLabel="xs:NCName"? > </outfault>*
</operation>*
</binding>*
. . .
</description>
The binding syntax parallels the syntax of interface:
each interface construct has a binding counterpart. Despite this
syntactic similarity, they are indeed different constructs, since they
are in different symbol spaces and are designed for different purposes.
A binding can either be reusable (applicable to any interface) or non-reusable (specified for a particular interface). Non-reusable bindings may be specified at the granularity of the interface (assuming the binding extension provides suitable defaulting rules), or on a per-operation basis if needed. A non-reusable binding was demonstrated in 2.1.5 Defining a Binding.
To define a reusable binding, the binding element
simply omits the interface attribute and omits specifying
any operation-specific and fault-specific binding details. Endpoints can
later refer to a reusable binding in the same manner as for a
non-reusable binding. Thus, a reusable binding becomes associated with a
particular interface when it is referenced from an endpoint, because an
endpoint is part of a service, and the service specifies a particular
interface that it implements. Since a reusable binding does not specify
an interface, reusable bindings cannot specify operation-specific
details. Therefore, reusable bindings can only be defined using binding
extensions that have suitable defaulting rules, such that the binding
information only needs to be explicitly supplied at the interface level.
A binding fault associates a concrete message format
with an abstract fault of an interface. It describes how faults that
occur within a message exchange of an operation will be formatted, since
the fault does not occur by itself. Rather, a fault occurs as part of a
message exchange specified by an interface operation and
its binding counterpart, the binding operation.
A binding fault has one required ref
attribute which is a reference, by QName, to an interface fault.
It identifies the abstract interface fault for which
binding information is being specified. Be aware that the value of ref
attribute of all the faults under a binding
must be unique. That is, one cannot define multiple bindings for the
same interface fault within a given binding.
A binding operation describes a concrete binding of
an interface operation to a concrete message format. An interface
operation is uniquely identified by the WSDL 2.0 target namespace of the
interface and the name of the operation within that interface, via the
required ref attribute of binding operation.
As with faults, for each operation within a binding,
the value of the ref attribute must be unique.
The WSDL 2.0 SOAP Binding Extension (see WSDL 2.0 Part 2 [WSDL 2.0 Adjuncts]) was primarily designed to support the features of SOAP 1.2 [SOAP 1.2 Part 1: Messaging Framework]. However, for backwards compatibility, it also provides some support for SOAP 1.1 [SOAP 1.1].
An example using the WSDL 2.0 SOAP binding extension was already presented in 2.1.5 Defining a Binding, but some additional points are worth mentioning:
Because the same binding extension is used for both SOAP 1.2 and
SOAP 1.1, a wsoap:version attribute is provided to allow
you to indicate which version of SOAP you want. If this attribute is
not specified, it defaults to SOAP 1.2.
The WSDL 2.0 SOAP binding extension defines a set of default rules, so that bindings can be specified at the interface level or at the operation level (or both), with the operation level taking precedence. However, it does not define default binding rules for faults. Thus, if a given interface defines any faults, then corresponding binding information must be explicitly provided for each such fault.
If HTTP is used as the underlying protocol, then the binding can (and should) control whether each operation will use HTTP GET or POST. (See 2.5.7 HTTP GET Versus POST: Which to Use?.)
Here is an example that illustrates both a SOAP 1.2 binding (as seen before) and a SOAP 1.1 binding.
例2-13. SOAP 1.2 and SOAP 1.1 Bindings
<?xml version="1.0" encoding="utf-8" ?>
<description
xmlns="http://www.w3.org/ns/wsdl"
targetNamespace="http://greath.example.com/2004/wsdl/resSvc"
xmlns:tns="http://greath.example.com/2004/wsdl/resSvc"
xmlns:ghns="http://greath.example.com/2004/schemas/resSvc"
xmlns:wsoap="http://www.w3.org/ns/wsdl/soap"
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
....
<!-- SOAP 1.2 Binding -->
<binding name="reservationSOAPBinding"
interface="tns:reservationInterface"
type="http://www.w3.org/ns/wsdl/soap"
wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">
<operation ref="tns:opCheckAvailability"
wsoap:mep="http://www.w3.org/2003/05/soap/mep/request-response"/>
<fault ref="tns:invalidDataFault"
wsoap:code="soap:Sender"/>
</binding>
<!-- SOAP 1.1 Binding -->
<binding name="reservationSOAP11Binding"
interface="tns:reservationInterface"
type="http://www.w3.org/ns/wsdl/soap"
wsoap:version="1.1"
wsoap:protocol="http://www.w3.org/2006/01/soap11/bindings/HTTP/">
<operation ref="tns:opCheckAvailability"/>
<fault ref="tns:invalidDataFault"
wsoap:code="soap11:Client"/>
</binding>
<service name="reservationService"
interface="tns:reservationInterface">
<!-- SOAP 1.2 End Point -->
<endpoint name="reservationEndpoint"
binding="tns:reservationSOAPBinding"
address="http://greath.example.com/2004/reservation"/>
<!-- SOAP 1.1 End Point -->
<endpoint name="reservationEndpoint2"
binding="tns:reservationSOAP11Binding"
address="http://greath.example.com/2004/reservation"/>
</service>
</description>
Most lines in this example is the same as previously explained in 2.1.5 Defining a Binding, so we'll only point out lines that are demonstrating something new for SOAP 1.1 binding.
<description ...
xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">This is the namespace for terms defined within the SOAP 1.1 specification [SOAP 1.1].
<binding...wsoap:version="1.1"This line indicates that this binding uses SOAP 1.1 [WSDL 2.0 SOAP 1.1 Binding], rather than SOAP 1.2.
wsoap:protocol="http://www.w3.org/2006/01/soap11/bindings/HTTP/">This line specifies that HTTP should be used as the underlying transmission protocol. See also 2.5.7 HTTP GET Versus POST: Which to Use?.
<operation
ref="tns:opCheckAvailability"/>Note that wsoap:mep is not applicable to SOAP 1.1
binding.
<fault...wsoap:code="soap11:Client"/>This line specifies the SOAP 1.1 fault code that will be used in transmitting invalidDataFault.
In addition to the WSDL 2.0 SOAP binding extension described above, WSDL 2.0 Part 2 [WSDL 2.0 Adjuncts] defines a binding extension for HTTP 1.1 [IETF RFC 2616] and HTTPS [IETF RFC 2818], so that these protocols can be used natively to send and receive messages, without first encoding them in SOAP.
The HTTP binding extension provides many features to control:
Which HTTP operation will be used. (GET, PUT, POST, DELETE, and other HTTP operations are supported.)
Input, output and fault serialization
Transfer codings
Authentication requirements
Cookies
HTTP over TLS (https)
As with the WSDL 2.0 SOAP binding extension, the HTTP binding extension also provides defaulting rules to permit binding information to be specified at the interface level and used by default for each operation in the affected interface, however, defaulting rules are not provided for binding faults.
Here is an example of using the HTTP binding extension to check hotel room availability at GreatH.
<?xml version="1.0" encoding="utf-8" ?>
<description xmlns="http://www.w3.org/ns/wsdl"
. . .
xmlns:whttp="http://www.w3.org/ns/wsdl/http" >
. . .
<binding name="reservationHTTPBinding"
interface="tns:reservationInterface"
type="http://www.w3.org/ns/wsdl/http"
whttp:methodDefault="GET">
<operation ref="tns:opCheckAvailability"
whttp:location="{checkInDate}" />
</binding>
<service name="reservationService"
interface="tns:reservationInterface">
<!-- HTTP 1.1 GET End Point -->
<endpoint name="reservationEndpoint"
binding="tns:reservationHTTPBinding"
address="http://greath.example.com/2004/checkAvailability/"/>
</service>
. . .
</description>
Most of this example is the same as previously explained in 2.1.5 Defining a Binding, so we'll only point out lines that are demonstrating something new for HTTP binding extension.
<description...xmlns:whttp="http://www.w3.org/ns/wsdl/http"
>This defines the namespace prefix for elements and attributes defined by the WSDL 2.0 HTTP binding extension.
<binding...type="http://www.w3.org/ns/wsdl/http"This declares the binding as being an HTTP binding.
whttp:methodDefault="GET">The default method for operations in this interface will be HTTP GET.
whttp:location="{checkInDate}" >The whttp:location attribute specifies a pattern
for serializing input message instance data into the path component of
the request URI. The default binding rules for HTTP specify that the
default input serialization for GET is application/x-www-form-urlencoded.
Curly braces are used to specify the name of a schema type in the input
message schema, which determines what input instance data will be
inserted into the path component of the request URI. The curly
brace-enclosed name will be replaced with instance data in constructing
the path component. Remaining input instance data (not specified by whttp:location)
will either be serialized into the query string portion of the URI or
into the message body, as follows: if a "/" is appended to a curly
brace-enclosed type name, then any remaining input message instance
data will be serialized into the message body. Otherwise it will be
serialized into query parameters.
Thus, in this example, each of the elements in the tCheckAvailability
type will be serialized into the query parameters. A sample resulting
URI would therefore be http://greath.example.com/2004/checkAvailability/5-5-5?checkOutDate=6-6-5&roomType=foo.
Here is an alternate example that appends "/" to the type name in order to serialize the remaining instance data into the message body:
Example 2-15. Serializing a Subset of Types in the Path
. . .
<operation ref="tns:opCheckAvailability"
whttp:location="bycheckInDate/{checkInDate/}" >
. . .
This would instead serialize to a request URI such as: http://greath.example.com/2004/checkAvailability/bycheckInDate/5-5-5.
The rest of the message content would go to the HTTP message body.
When a binding using HTTP is specified for an operation, the WSDL 2.0 author must decide which HTTP method is appropriate to use -- usually a choice between GET and POST. In the context of the Web as a whole (rather than specifically Web services), the W3C Technical Architecture Group (TAG) has addressed the question of when it is appropriate to use GET, versus when to use POST, in a finding entitled URIs, Addressability, and the use of HTTP GET and POST ([W3C TAG Finding: Use of HTTP GET]). From the abstract:
". . . designers should adopt [GET] for safe operations such as simple queries. POST is appropriate for other types of applications where a user request has the potential to change the state of the resource (or of related resources). The finding explains how to choose between HTTP GET and POST for an application taking into account architectural, security, and practical considerations."
Recall that the concept of a safe operation was discussed in 2.4.4.1 Operation
Attributes. (Briefly, a safe operation is one that does not cause the
invoker to incur new obligations.) Although the wsdlx:safe
attribute of an interface operation indicates that the abstract
operation is safe, it does not automatically cause GET to be used at the
HTTP level when the binding is specified. The choice of GET or POST is
determined at the binding level:
If the WSDL 2.0 SOAP binding extension is used (2.5.5 The SOAP Binding Extension), with HTTP as the underlying transport protocol, then GET may be specified by setting:
wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/"on the binding element (to indicate the use of
HTTP as the underlying protocol); and
wsoap:mep="http://www.w3.org/2003/05/soap/mep/soap-response/"on the binding operation element, which causes GET
to be used by default.
If the WSDL 2.0 HTTP binding extension is used directly (2.5.6 The HTTP Binding Extension), GET may be specified by setting either:
whttp:methodDefault="GET"on the binding element; or
whttp:method="GET"on the binding operation element, which overrides
whttp:methodDefault if set on the binding
element; or
wsdlx:safe="true"on the bound interface operation . When the above
two items are not explicitly set, and when the bound interface
operation is marked safe, the HTTP Binding will by default set the
method to GET.
For example, in the GreatH interface definition shown in 例2-4, the wsdlx:safe attribute is set to "true". The HTTP binding definition in 例2-14 may take advantage of that and be simplified as below and still have the http method set to GET by default:
In some circumstances WSDL authors may want to split up a Web service description into two or more documents. For example, if a description is getting long or is being developed by several authors, then it is convenient to divide it into several parts. Another very important case is when you expect parts of the description to be reused in several contexts. Clearly it is undesirable to cut and paste sections of one document into another, since that is error prone and leads to maintenance problems. More importantly, you may need to reuse components that belong to a wsdl:targetNamespace that is different than that of the document you are writing, in which case the rules of WSDL 2.0 prevent you from simply cutting and pasting them into your document.
To solve these problems, WSDL 2.0 provides two mechanisms for
modularizing Web service description documents: import and
include. This section discusses the import mechanism and
describes some typical cases where it may be used.
The import mechanism lets one refer to the
definitions of Web service components that belong to other namespaces.
To illustrate this, consider the GreatH hotel reservation service.
Suppose that the reservation service uses a standard credit card
validation service that is provided by a financial services company.
Furthermore, suppose that companies in the financial services industry
decided that it would be useful to report errors in credit card
validation using a common set of faults, and have defined these faults
in the following Web service description:
Example 3-1. Standard Credit Card Validation Faults (credit-card-faults.wsdl)
<?xml version="1.0" encoding="utf-8" ?>
<description xmlns="http://www.w3.org/ns/wsdl"
targetNamespace="http://finance.example.com/CreditCards/wsdl"
xmlns:tns="http://finance.example.com/CreditCards/wsdl"
xmlns:cc="http://finance.example.com/CreditCards/xsd">
<documentation>
This document describes standard faults for use
by Web services that process credit cards.
</documentation>
<types>
<xs:import xmlns:xs="http://www.w3.org/2001/XMLSchema"
namespace="http://finance.example.com/CreditCardFaults/xsd"
schemaLocation="credit-card-faults.xsd" />
</types>
<interface name="creditCardFaults">
<fault name="cancelledCreditCard" element="cc:CancelledCreditCard">
<documentation>Thrown when the credit card has been cancelled.</documentation>
</fault>
<fault name="expiredCreditCard" element="cc:ExpiredCreditCard">
<documentation>Thrown when the credit card has expired.</documentation>
</fault>
<fault name="invalidCreditCardNumber" element="cc:InvalidCreditCardNumber">
<documentation>Thrown when the credit card number is invalid.
This fault will occur if the wrong credit card type is specified.
</documentation>
</fault>
<fault name="invalidExpirationDate" element="cc:InvalidExpirationDate">
<documentation>Thrown when the expiration date is invalid.</documentation>
</fault>
</interface>
</description>
This example defines an interface, creditCardFaults,
that contains four faults, cancelledCreditCard, expiredCreditCard,
invalidCreditCardNumber, and invalidExpirationDate.
These components belong to the namespace http://finance.example.com/CreditCards/wsdl.
Because these faults are defined in a different wsdl:targetNamespace than the one used by the GreatH Web service description, import must be used to make them available within the GreatH Web service description, as shown in the following example:
例3-2. Using the Standard Credit Card Validation Faults (use-credit-card-faults.wsdl)
<?xml version="1.0"?>
<description
targetNamespace="http://greath.example.com/2004/wsdl/resSvc"
xmlns:ghns="http://greath.example.com/2004/schemas/resSvc"
xmlns:cc="http://finance.example.com/CreditCards/wsdl"
xmlns="http://www.w3.org/ns/wsdl"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<documentation>
Description: The definition of the reservation Web service of
GreatH hotel. Author: Joe Somebody Date: 05/17/2004
</documentation>
<import namespace="http://finance.example.com/CreditCards/wsdl"
location="credit-card-faults.wsdl"/>
. . .
<interface name="reservation" extends="cc:creditCardFaults">
. . .
<operation name="makeReservation"
pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="In" element="ghns:makeReservation" />
<output messageLabel="Out"
element="ghns:makeReservationResponse" />
<outfault ref="invalidDataFault" messageLabel="Out" />
<outfault ref="cc:cancelledCreditCard" messageLabel="Out" />
<outfault ref="cc:expiredCreditCard" messageLabel="Out" />
<outfault ref="cc:invalidCreditCardNumber" messageLabel="Out" />
<outfault ref="cc:invalidExpirationDate" messageLabel="Out" />
</operation>
</interface>
</description>
The hotel reservation service declares that it is using
components from another namespace via the import>
element. The import element has a required namespace
attribute that specifies the other namespace, and an optional location
attribute that gives the processor a hint where to find the description
of the other namespace. The reservation interface extends
the creditCardFault interface from the other namespace in
order to make the faults available in the reservation interface.
Finally, the makeReservation operation refers to the
standard faults in its outfault elements.
Another typical situation for using imports is to define a
standard interface that is to be implemented by many services. For
example, suppose the hotel industry decided that it was useful to have a
standard interface for making reservations. This interface would belong
to some industry association namespace, e.g. http://hotels.example.com/reservations/wsdl.
Each hotel that implemented the standard reservation service would
define a service in its own namespace, e.g. http://greath.example.com/2004/wsdl/resSvc.
The description of each service would import the http://hotels.example.com/reservations/wsdl
namespace and refer to the standard reservation interface in it.
WSDL 2.0 documents may contain one or more XML schemas defined
within the wsdl:types element. This section illustrates the
correct way to refer to these schemas, both from within the same
document and from other documents.
In this example, we consider some GreatH Hotel Web services that
retrieve and update reservation details. The retrieval Web service is
defined in the retrieveDetails.wsdl WSDL 2.0 document,
along with a schema for the message format. The updating Web service is
defined in the updateDetails.wsdl WSDL 2.0 document which
imports the first document and refers to both WSDL 2.0 and schema
definitions contained in the imported document.
例3-3 shows the definition of
the retrieval Web service in the http://greath.example.com/2004/services/retrieveDetails
namespace. This WSDL 2.0 document also contains an inline schema that
describes the reservation detail in the http://greath.example.com/2004/schemas/reservationDetails
namespace. This schema is visible to the retrieveDetailsInterface
interface definition which refers to it in the retrieve
operation's output message.
例3-3. The Retrieve Reservation Details Web Service: retrieveDetails.wsdl
<?xml version="1.0" encoding="utf-8" ?>
<description xmlns="http://www.w3.org/ns/wsdl"
targetNamespace="http://greath.example.com/2004/services/retrieveDetails"
xmlns:tns="http://greath.example.com/2004/services/retrieveDetails"
xmlns:wdetails="http://greath.example.com/2004/schemas/reservationDetails"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<documentation>
This document describes the GreatH Retrieve Reservation Details
Web service.
</documentation>
<types>
<xs:schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://greath.example.com/2004/schemas/reservationDetails">
<xs:element name="reservationDetails">
<xs:complexType>
<xs:sequence>
<xs:element name="confirmationNumber"
type="string" />
<xs:element name="checkInDate" type="date" />
<xs:element name="checkOutDate" type="date" />
<xs:element name="roomType" type="string" />
<xs:element name="smoking" type="boolean" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</types>
<interface name="retrieveDetailsInterface">
<operation name="retrieve"
pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="In" element="#none" />
<output messageLabel="Out"
element="wdetails:reservationDetails" />
</operation>
</interface>
</description>
例3-4 shows the definition of
the updating Web service in the http://greath.example.com/2004/services/updateDetails
namespace. The updateDetailsInterface interface extends the
retrieveDetailsInterface interface. However, the retrieveDetailsInterface
belongs to the http://greath.example.com/2004/services/retrieveDetails
namespace, so updateDetails.wsdl must import retrieveDetails.wsdl
to make that namespace visible.
The updateDetailsInterface interface also uses the reservationDetails
element definition that is contained in the inline schema of the
imported retrieveDetails.wsdl document. However, this
schema is not automatically visible within the updateDetails.wsdl
document. To make it visible, the updateDetails.wsdl
document must import the namespace of the inline schema within the types
element using the XML schema import element.
In this example, the schemaLocation attribute of the
import element has been omitted. The schemaLocation
attribute is a hint to the WSDL 2.0 processor that tells it where to
look for the imported schema namespace. However, the WSDL 2.0 processor
has already processed the retrieveDetails.wsdl document
which contains the imported namespace in an inline schema so it should
not need any hints. However, this behavior depends on the implementation
of the processor and so cannot be relied on.
Although the WSDL 2.0 document may validly omit the schemaLocation
attribute, it is a best practice to either provide a reliable value for
it or move the inline schema into a separate document, say reservationDetails.xsd,
and directly import it in the types element of both retrieveDetails.wsdl
and updateDetails.wsdl. In general, schemas that are
expected to be referenced from more than one WSDL 2.0 document should be
defined in a separate schema document rather than be inlined.
Example 3-4. The Update Reservation Details Web Service: updateDetails.wsdl
<?xml version="1.0" encoding="utf-8" ?>
<description xmlns="http://www.w3.org/ns/wsdl"
targetNamespace="http://greath.example.com/2004/services/updateDetails"
xmlns:tns="http://greath.example.com/2004/services/updateetails"
xmlns:retrieve="http://greath.example.com/2004/services/retrieveDetails"
xmlns:details="http://greath.example.com/2004/schemas/reservationDetails"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<documentation>
This document describes the GreatH Update Reservation Details
Web service.
</documentation>
<import
namespace="http://greath.example.com/2004/services/retrieveDetails"
location="retrieveDetails.wsdl" />
<types>
<xs:import
namespace="http://greath.example.com/2004/schemas/reservationDetails" />
</types>
<interface name="updateDetailsInterface"
extends="retrieve:retrieveDetailsInterface">
<operation name="update"
pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="In"
element="details:reservationDetails" />
<output messageLabel="Out"
element="details:reservationDetails" />
</operation>
</interface>
</description>
A WSDL 2.0 document may define multiple inline schemas in its types
element. The two or more schemas may have the same target namespace
provided that they do not define the same elements or types. It is an
error to define the same element or type more than once, even if the
definitions are identical.
Each namespace of an inline schema becomes visible to the Web
service definitions. However, the namespaces are not automatically
visible to the other inline schemas. Each inline schema must explicitly
import any other namespace it references. The schemaLocation
attribute is not required in this case since the WSDL 2.0 processor
knows the location of each schema by virtue of having processed the
enclosing WSDL 2.0 document.
To illustrate this, consider 例3-5
which contains two inline schemas. The http://greath.example.com/2004/schemas/reservationItems
namespace contains some elements for items that appear in the
reservation details. The http://greath.example.com/2004/schemas/reservationDetails
namespace contains the reservationDetails element which
refers to the item elements. The schema for the http://greath.example.com/2004/schemas/reservationDetails
namespace contains an import element that imports the http://greath.example.com/2004/schemas/reservationItems
namespace. No schemaLocation attribute is required for this
import since the schema is defined inline in the importing document.
Example 3-5. Multiple Inline Schemas: retrieveItems.wsdl
<?xml version="1.0" encoding="utf-8" ?>
<description xmlns="http://www.w3.org/ns/wsdl"
targetNamespace="http://greath.example.com/2004/services/retrieveDetails"
xmlns:tns="http://greath.example.com/2004/services/retrieveDetails"
xmlns:wdetails="http://greath.example.com/2004/schemas/reservationDetails"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<documentation>
This document describes the GreatH Retrieve Reservation Details
Web service.
</documentation>
<types>
<xs:schema targetNamespace="http://greath.example.com/2004/schemas/reservationItems">
<xs:element name="confirmationNumber" type="string" />
<xs:element name="checkInDate" type="date" />
<xs:element name="checkOutDate" type="date" />
<xs:element name="roomType" type="string" />
<xs:element name="smoking" type="boolean" />
</xs:schema>
<xs:schema targetNamespace="http://greath.example.com/2004/schemas/reservationDetails"
xmlns:items="http://greath.example.com/2004/schemas/reservationItems">
<xs:import
namespace="http://greath.example.com/2004/schemas/reservationItems" />
<xs:element name="reservationDetails">
<xs:complexType>
<xs:sequence>
<xs:element ref="items:confirmationNumber" />
<xs:element ref="items:checkInDate" />
<xs:element ref="items:checkOutDate" />
<xs:element ref="items:roomType" />
<xs:element ref="items:smoking" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</types>
<interface name="retrieveDetailsInterface">
<operation name="retrieve"
pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="In" element="#none" />
<output messageLabel="Out"
element="wdetails:reservationDetails" />
</operation>
</interface>
</description>
In the preceding examples, schemas were defined inline in WSDL
2.0 documents. This section discusses the correct way to specify a schemaLocation
attribute on a schema import element to provide a processor
with a hint for locating these schemas.
例3-4 shows how one WSDL 2.0
document imports a schema defined in another, i.e. 例3-3. Similarly, 例3-5 shows how one schema in a WSDL 2.0
document imports another schema defined in the same document. In both of
these examples, the schemaLocation attribute was omitted
since the WSDL 2.0 processor was assumed to know how to locate the
imported schemas because they were part of the WSDL 2.0 documents being
processed. The schemaLocation attribute can be used to give
the processor a URI reference that explicitly locates the schemas. A URI
reference is a URI plus an optional fragment identifier that indicates
part of the resource. For schemas, the fragment should identify the schema
element. The simplest way to accomplish this is to use the id
attribute, however XPointer (see [XPointer
Framework]) can also be used.
例3-6 shows the use of the id
attribute. Both of the inline schemas have id attributes.
The id of the http://greath.example.com/2004/schemas/reservationItems
schema is items and the id of the http://greath.example.com/2004/schemas/reservationDetails
schema is details. The import element in the http://greath.example.com/2004/schemas/reservationDetails
schema uses the id of the http://greath.example.com/2004/schemas/reservationItems
schema in the schemaLocation attribute, i.e. #items.
Example 3-6. Using Ids in Inline Schemas: schemaIds.wsdl
<?xml version="1.0" encoding="utf-8" ?>
<description xmlns="http://www.w3.org/ns/wsdl"
targetNamespace="http://greath.example.com/2004/services/retrieveDetails"
xmlns:tns="http://greath.example.com/2004/services/retrieveDetails"
xmlns:wdetails="http://greath.example.com/2004/schemas/reservationDetails"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<documentation>
This document describes the GreatH Retrieve Reservation Details
Web service.
</documentation>
<types>
<xs:schema id="items"
targetNamespace="http://greath.example.com/2004/schemas/reservationItems">
<xs:element name="confirmationNumber" type="string" />
<xs:element name="checkInDate" type="date" />
<xs:element name="checkOutDate" type="date" />
<xs:element name="roomType" type="string" />
<xs:element name="smoking" type="boolean" />
</xs:schema>
<xs:schema id="details"
targetNamespace="http://greath.example.com/2004/schemas/reservationDetails"
xmlns:items="http://greath.example.com/2004/schemas/reservationItems">
<xs:import
namespace="http://greath.example.com/2004/schemas/reservationItems"
schemaLocation="#items" />
<xs:element name="reservationDetails">
<xs:complexType>
<xs:sequence>
<xs:element ref="items:confirmationNumber" />
<xs:element ref="items:checkInDate" />
<xs:element ref="items:checkOutDate" />
<xs:element ref="items:roomType" />
<xs:element ref="items:smoking" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</types>
<interface name="retrieveDetailsInterface">
<operation name="retrieve"
pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="In" element="#none" />
<output messageLabel="Out"
element="wdetails:reservationDetails" />
</operation>
</interface>
</description>
WSDL 2.0 provides an open content model, which allows XML elements and attributes from other (non-WSDL 2.0) XML namespaces to be interspersed in a WSDL 2.0 document. The qualified name (complete with namespace URI) of the extension element or attribute acts as an unambiguous name for the semantics of that extension.
The namespace URI of the extension element should be dereferenceable to a document that describes the semantics of that extension. As of this writing, there is no generally accepted standard for what kind of document that should be. However, the W3C TAG has been discussing the issue (see TAG issue namespaceDocument-8) and is likely to provide guidance at some point.
Extensions can either be required or optional.
An optional extension is one that the client may either
engage or ignore, entirely at its discretion, and is signaled by wsdl:required="false"
or the absence of the wsdl:required attribute (because it
defaults to false). Thus, a WSDL 2.0 processor, acting on behalf of the
client, that encounters an unknown optional extension can safely ignore
it and continue to process the WSDL 2.0 document. However, it is
important to stress that optional extensions are only optional to the client
-- not the service. A service must support all optional and required
extensions that it advertises in its WSDL 2.0 document.
A required extension is one that must be supported and
engaged by the client in order for the interaction to proceed properly,
and is signaled by wsdl:required="true". If a WSDL 2.0
processor, acting on behalf of the client, encounters a required
extension that it does not recognize or does not support, then it cannot
safely continue to process the WSDL 2.0 document. In most practical
cases, this is likely to mean that the processor will require manual
intervention to deal with the extension. For example, a client developer
might manually provide an implementation for the required extension to
the WSDL 2.0 processor.
As we mentioned in 2.4.4.3 Understanding Message Exchange Patterns (MEPs), even though the 8 MEPs defined by WSDL 2.0 are intended to cover most of the common use cases, there are situations that require new MEPs to be defined. In this section, we will explain how new MEPs can be defined to address special business requirements.
Following the wild success of its reservation service, GreatH discovered that it could radically increase tourist interest by supplying information on weather conditions, both to travel agents and to the general touring public. This produced a challenge for the service implementers: how could this information be supplied to interested parties without requiring knowledge of web service technology specifically, and of computers generally? At issue was the desire to provide asynchronous updates to unsophisticated customers without incurring onerous overheads for technical support.
The solution adopted was to create a standard mailing list, and to make available a small cross-platform web service client (actually, a subscriber) that could be installed on any computer with POP or IMAP access to a mailbox. The mailbox, once signed up for the mailing list, could either be processed as "dedicated" (to the GreatH weather service; travel agents did this) or as "general purpose" (in which case the application would only examine those emails that contained Subject headers associated with the service). This required development of a binding to email, which is out of scope for this example, but the resulting WSDL 2.0 was otherwise quite straightforward.
Note: the email binding in use here supports publish/subscribe, by supporting the robust-out-only MEP as well as the client/server style in-out used for subscribing and unsubscribing. Details of this binding would require a document as long as the primer, so play along.
例4-1. Weather Notification Service (Initial)
<?xml version="1.0" encoding="utf-8" ?>
<description xmlns="http://www.w3.org/ns/wsdl"
targetNamespace="http://greath.example.com/2004/wsdl/weathSvc.wsdl"
xmlns:tns="http://greath.example.com/2004/wsdl/weathSvc.wsdl"
xmlns:wsoap="http://www.w3.org/ns/wsdl/soap"
xmlns:email="http://www.example.com/webservices/email" >
<types>
. . .
</types>
<interface name="weatherInterface">
<operation name="opSubscribeWeather"
pattern="http://www.w3.org/ns/wsdl/in-out">
<input element=". . ." />
<output element=". . ." />
</operation>
<operation name="opUnsubscribeWeather"
pattern="http://www.w3.org/ns/wsdl/in-out">
<output element=". . ." />
<input element=". . ." />
</operation>
<operation name="opNotifyWeather"
pattern="http://www.w3.org/ns/wsdl/robust-out-only">
<output element=". . ." />
</operation>
</interface>
<binding name="weatherMailingListBinding"
interface="tns:weatherInterface
type="http://www.w3.org/ns/wsdl/soap"
wsoap:protocol="http://www.example.com/bindings/email">
. . .
</binding>
<service name="weatherService"
interface="tns:weatherInterface">
<endpoint name="greatHWeatherList"
binding="tns:weatherMailingListBinding"
address="mailto:weather-owner@greath.example.com" />
</service>
</description>
Note: in the example, the messageLabels of all input and output elements have been elided, as they are not necessary to disambiguate (but note that the order of input and output elements is not significant).
Unfortunately, the service was soon highjacked for the purpose of annoyment. Repeatedly, hotels in less salubrious climes, and the victims of various natural climactic disasters (hurricanes, tornadoes) found themselves signed up to receive material full of incomprehensible pointy brackets. They complained to GreatH, who complained to their service designers.
Applying public key infrastructure to solving the problem was immediately rejected as too complex and too heavyweight. Analysis showed that the problem was simply to verify that the address requesting information actually wanted that information. Consequently, a new message exchange pattern was defined.
This pattern consists of two or more messages in order as follows:
A message:
indicated by a Message Label component whose message label is "Request" and direction is "in"
received from some node N1
A message:
indicated by a Message Label component whose message label is "Challenge" and direction is "out"
sent to some node N2 (which may be the same node as N1)
An optional message:
indicated by a Message Label component whose message label is "Confirmation" and direction is "in"
received from node N2
An optional message:
indicated by a Message Label component whose message label is "Response" and direction is "out"
sent to node N2
This pattern uses the rule Message Triggers Fault.
An operation using this message exchange pattern has a pattern property with the value "http://www.example.com/webservices/meps/confirmed-challenge".
Once the MEP had been defined (and the email binding specification appropriately modified to indicate that this was a supported MEP), the service was redefined and redeployed. Only the changed operations are shown in the excerpt below.
Example 4-2. Weather Notification Service (Revised)
<?xml version="1.0" encoding="utf-8" ?>
<description xmlns="http://www.w3.org/ns/wsdl"
targetNamespace="http://greath.example.com/2004/wsdl/weathSvc.wsdl"
xmlns:tns="http://greath.example.com/2004/wsdl/weathSvc.wsdl"
xmlns:wsoap="http://www.w3.org/ns/wsdl/soap"
xmlns:email="http://www.example.com/webservices/email" >
. . .
<interface name="weatherInterface">
<operation name="opSubscribeWeather"
pattern="http://www.example.com/webservices/meps/confirmed-challenge">
<input messageLabel="Request" element=". . ." />
<output messageLabel="Challenge" element=". . ." />
<input messageLabel="Confirmation" element=". . ." />
<output messageLabel="Response" element=". . ." />
</operation>
<operation name="opUnsubscribeWeather"
pattern="http://www.example.com/webservices/meps/confirmed-challenge">
<output messageLabel="Challenge" element=". . ." />
<output messageLabel="Response" element=". . ." />
<input messageLabel="Confirmation" element=". . ." />
<input messageLabel="Request" element=". . ." />
</operation>
. . .
</interface>
. . .
</description>
Note: in the second example, the input and output examples are not in the sequence in which they occur in the pattern; this illustrates that the sequence is not significant. Note, however, that for this pattern, the messageLabel attribute is required on every input and output element.
Section 2.4.4.1
Operation Attributes mentioned that the (optional) style
attribute of an interface operation is used to indicate that the
operation conforms to a particular pre-defined operation style, or set
of constraints. Actually, if desired the style attribute
can hold a list of URIs, indicating that the operation simultaneously
conforms to multiple styles.
Operation styles are named using URIs, in order to be unambiguous while still permitted new styles to be defined without requiring updates to the WSDL 2.0 language. WSDL 2.0 Part 2 [WSDL 2.0 Adjuncts] defines three such operation styles; one of these is the RPC Style (RPC Style).
The RPC Style is designed to facilitate programming language bindings to WSDL 2.0 constructs. It allows a WSDL 2.0 interface operation to be easily mapped to a method or function signature, such as a method signature in Java (TM) or C#. RPC Style is restricted to operations that use the In-Out or In-Only MEPs (see 2.4.4.3 Understanding Message Exchange Patterns (MEPs)).
A WSDL 2.0 document makes use of the RPC Style in an interface
operation by first defining the operation in conformance with all of the
RPC Style rules, and then setting that operation's style
attribute to include the URI that identifies the RPC Style, thus
asserting that the operation does indeed conform to the RPC Style. These
rules permit the input and output message schemas to map conveniently to
inputs and outputs of a method signature. Roughly, input elements map to
input parameters, output elements map to output parameters, and elements
that appear both in the input and output message schemas map to
input/output parameters. WSDL 2.0 Part 2 section "RPC
Style" provides full details of the mapping rules and requirements.
The RPC Style also permits the full signature of the intended
mapping to be indicated explicitly, using the wrpc:signature
attribute defined in WSDL 2.0 Part 2 section "wrpc:signature
Extension". This is an (optional) extension to the WSDL 2.0 language
whose value designates how input and output message schema elements map
to input and output parameters in the method signature.
The example below illustrates how RPC Style may be used to
designate a signature. This example is a modified version of the GreatH
reservation service. In particular, the interface and types
sections have been modified to specify and conform to the RPC Style.
Example 4-3. Specifying RPC Style
. . .
<types>
<xs:element name="checkAvailability">
<xs:complexType>
<xs:sequence>
<xs:element name="checkInDate" type="xs:date"/>
<xs:element name="checkOutDate" type="xs:date"/>
<xs:element name="roomType" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="checkAvailabilityResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="roomType" type="xs:string"/>
<xs:element name="rateType" type="xs:string"/>
<xs:element name="rate" type="xs:double"/>
</xs:sequence>
</xs:complexType>
</xs:element>
. . .
</types>
<interface name = "reservationInterface" >
<operation name="checkAvailability"
pattern="http://www.w3.org/ns/wsdl/in-out"
style="http://www.w3.org/ns/wsdl/rpc"
wrpc:signature=
"checkInDate #in checkOutDate #in roomType #inout rateType #out rate #return">
<input messageLabel="In"
element="tns:checkAvailability" />
<output messageLabel="Out"
element="tns:checkAvailabilityResponse" />
</operation>
. . .
</interface>
. . .
Note that the interface operation's name "checkAvailability",
is the same as the localPart of the input element's QName, "tns:checkAvailability".
This is one of the requirements of the RPC Style. The name of the
operation is used as the name of the method in a language binding,
subject to further mapping restrictions specific to the target
programming language. In this case, the name of the method would be "checkAvailability".
The local children elements of the input element and output
element designate the parameters and the return type for a method call.
Note that the elements checkInDate, checkOutDate
are input parameters, however the element roomType is an
in-out parameter, as it appears both as a local element child of both
input and output elements. This indicates that the reservation system
may change the room type requested based on availability.
The reservation service also returns a rate type for the reservation, such as "rack rate". The return value for the method is designated as the "rate" element.
Based on the value of the wrpc:signature attribute,
the method signature would be obtained following the order of the
parameters. A sample mapping is provided below for the Java (TM)
language. This example was created using JAX RPC 1.1 [JAX RPC 1.1] for mapping simple types to Java types
and designated inout and output parameters by using Holder classes.
例4-4. Sample Java (TM) Signature for RPC Style
public interface reservationInterface extends Remote{
double checkAvailability (java.util.calendar checkInDate,
java.util.calendar checkOutDate,
StringHolder roomType,
StringHolder rateType) throws RemoteException;
. . .
}
Programming languages may further specify how faults are mapped to language constructs and their scopes, such as Exceptions, but they are not specific to RPC style.
This section covers various topics that may fall outside the scope of WSDL 2.0, but shall provide useful background and best practice guidances that may be useful when authoring a WSDL 2.0 document or implementing the WSDL 2.0 specification.
It is desirable for a message recipient to have the capability to uniquely identify a message type in order to handle it correctly. The capability of identifying a message type is typically used for dispatching purposes within an implementation of a web service. Therefore, WSDL authors are recommended to consider how to disambiguate message types when they develop their services.
The context in which a Web service may be deployed plays an important role in choosing an appropriate way to disambiguate and identify message types. In a typical deployment, an endpoint address may host a single service that is described by a WSDL service element. In this case, when XSD is used, assigning unique qualified names of global element declarations as inputs within the interface that describes the service would be sufficient to disambiguate the types of the messages that are received. However, when endpoint address hosts multiple services, in essence supporting several WSDL descriptions, the desire to disambiguate message types should be considered within the context of all the deployed services, not only within a single interface.
As explained in 2.4.4.1
Operation Attributes, when XSD is used as the type system, a few special
tokens can be used for the element attributes. Uniquely
identifying a message type may become very difficult when:
any of these input elements within an interface has a value of "#any"; or
more than one of these input elements (see below) has a value of "#none"; or
the qualified names of the global element declarations that are specified as input elements are NOT unique when considered together.
If any of the three cases above arise, disambiguation mechanisms may be provided by means of an extension element (i.e., an element that is not in the http://www.w3.org/ns/wsdl namespace), having a wsdl:required attribute with a value of "true". The semantics of such an extension element would indicate the mechanism for unambiguously identifing the mechanism that a message sender is required to support in order to enable the message recipient to unambiguously determine the message received.
For example, the WS-Addressing [WS-Addressing] specification provides such a disambiguation mechanism. It consists of an extension element which may be marked as required, and defines a required [action] property whose value is always present in a conformant message delivery. The value of the action property can be used to disambiguate the message by the receiver and there is a well defined way to associate actions to messages in WS-Addressing specifications. Further, WS-Addressing also provides an appropriate default action value that identifies each message type uniquely.
When using the HTTP Binding, or when using the SOAP Binding with the SOAP Response MEP, there is no SOAP envelope in a request message, and thus mechanisms other than unique qualified names of global element declarations, or headers such as wsa:Action, must be considered. In these cases, the {address} and {http location} properties may be constructed so as to provide a location that can be correlated uniquely with an operation. For instance, one could prefix the {http location} property with the operation name, or one could ensure that the portion of the {http location} preceding the first unescaped "{" character be unique per operation.
A WSDL 2.0 document describes a set of messages that a Web service may send and receive. In essence, it describes a language for interacting with that service. However it is possible for a Web service to exchange other messages beyond those described in a particular WSDL 2.0 document. Often this circumstance occurs following an evolution of the client and/or service, and thus an evolution of the interaction language.
How best to manage the evolution (versioning) of Web based systems is, at the time of writing, the subject of a wide-ranging debate. However, there are three activities within the W3C that are directly relevant to versioning of Web services description:
The Technical Architecture Group (TAG) has published guidance on the extensibility and versioning of data formats in its Web Architecture document [Web Architecture]. There is also a more wide ranging draft finding on Versioning and Extensibility [W3C TAG Finding: Extending and Versioning Languages Part 1]. Both of these works build upon the technical note on Web Architecture: Extensible Languages [WebArch: Extensible Languages].
The XML Schema Working Group is collecting a series of use cases for schema versioning as a part of the Schema 1.1 activity. See XML Schema Versioning Use Cases [XML Schema: Versioning Use-Cases].
The Guide to Versioning XML Languages using XML Schema 1.1 [Guide to Versioning XML Languages using XML Schema 1.1] illustrates some techniques for versioning XML languages enabled by features of XML Schema 1.1 [XML Schema 1.1].
The Semantic Web Best Practices and Deployments Working Group is examining how vocabularies may evolve. See [SW VocabManagementNote]
While incomplete, these activities all agree in one important respect: that versioning is difficult, but you should anticipate and plan for change.
The draft finding on Versioning and Extensibility details two key approaches to versioning:
compatible evolution; and
big bang.
In compatible evolution, designers are expected to limit changes to those that are either backward or forward compatible, or both:
The receiver behaves correctly if it receives a message in an older version of the interaction language.
The receiver behaves correctly if it receives a message in a newer version of the interaction language.
Since Web services and their clients both send and receive messages, these concepts can apply to both parties. However, since WSDL 2.0 is service-centric, we will focus on the case of service evolution.
There are three critical areas in which a service described in WSDL 2.0 my evolve:
The service now also supports additional binding. In compatible evolution, this should be a safe addition, given that adding a new binding should not impact any existing interactions using another transport.
An interface supports new operations. Again, in compatible evolution this is usually safe, given that adding an additional operation to an abstract interface should not impact any existing interactions.
The message bodies may include additional data. How the message
contents may change within a description depends to a large extent upon
the type system being used to describe the message contents. RelaxNG [RELAX NG] has good support for describing
vocabularies that ignore unknown XML, as does OWL/RDF. XML Schema 1.0
has limited support for extending the description of a message via the
xs:any and xs:anyAttribute constructs. XML
Schema 1.1 has been chartered to provide "changes necessary to provide
better support for versioning of schemas", and it is anticipated that
this may include improved support for more "open content" and therefore
better support for compatible evolution of messages.
The protocol used to exchange messages may provide mechanisms for exchanging data outside of the message body. In the case of SOAP, the WSDL 2.0 binding provides the ability to describe application data to be exchanged as headers. The SOAP processing model has a very good extensibility model with unknown headers being ignored by a receiver by default. There is also a mechanism whereby headers which are required as a part of an incompatible change may be marked with a 'mustUnderstand' flag. Passing additional items as headers may be the only way to compatibly evolve messages with fixed bodies.
The big bang approach to versioning is the simplest to currently represent in WSDL 2.0. In this approach, any change to a WSDL 2.0 document implies a change to the document's namespace, a change to the interface implies a new interface namespace and a change to the message contents is communicated using a new message namespace. This approach has particular benefits where an agent may quickly tell if a service has changed by simply comparing the namespace value.
Compatible changes are far more easily managed than incompatible ones:
With a compatible change the service need only support the latest version of a service. A client may continue to use a service adjusting to new version of the interface description at a time of its choosing.
With an incompatible change, the client receives a new version of the interface description and is expected to adjust to the new interface before old interface is terminated. Either the service will need to continue to support both versions of the interface during the hand over period, or the service and the clients are coordinated to change at the same time. An alternative is for the client to continue until it encounters an error, at which point it uses the new version of the interface.
It is feasible to combine the "compatible evolution" and "big bang" approaches in a variety of different ways. For example, the namespace could be changed when message descriptions are changed, but the namespace could stay the same when new operations are added.
While the big bang approach is currently the easiest to implement in WSDL 2.0, it can lead to a large number of cloned interfaces that become difficult to manage, thus making the compatible approach preferable to many for widely distributed systems. In the end, the choice of a versioning strategy for Web services described in WSDL 2.0 is left as an exercise to the reader.
The following example demonstrates how content may be extended with additional content. The reservation service is changed to a newer version that can accept an optional number of guests parameter. The service provider wants existing clients to continue to be able to use the service. The author adds the element into the schema as an optional element.
Example 5-1. XML Schema with Optional Elements
<xs:complexType name="tCheckAvailability">
<xs:sequence>
<xs:element name="checkInDate" type="xs:date"/>
<xs:element name="checkOutDate" type="xs:date"/>
<xs:element name="roomType" type="xs:string"/>
<xs:element name="numberOfGuests" type="xs:integer" minOccurs="0"/>
<xs:any namespace="##other" processContents="lax"/>
</xs:sequence>
</xs:complexType>
The author has the choice of keeping the same namespace or using a different namespace for the additional content and the existing content. In this scenario, it is a compatible change and the author decides to keep the same namespace. This allows existing clients to interact with a new service, and it allows newer clients to interact with older services.
Another option is to add the extension as a header block. This is accomplished by defining an element for the extension and adding a header element that references the element into the binding operation as child of the input.
Example 5-2. Additional optional elements added to a SOAP header
<xs:element name="NumberOfGuests" type="tNumberOfGuests"/>
<xs:complexType name="tNumberOfGuests">
<xs:sequence>
<xs:element name="numberOfGuests" type="xs:integer" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<binding name="reservationSOAPBinding"
interface="tns:reservationInterface"
type="http://www.w3.org/ns/wsdl/soap"
wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">
<operation ref="tns:opCheckAvailability">
<input>
<wsoap:header element="tns:NumberOfGuests"/>
</input>
</operation>
...
</binding>
It is also possible for the header to be marked with soap:mustUnderstand set to true. The HTTP Binding has similar functionality though without a mustUnderstand attribute.
This following example demonstrates an extension with additional content. The reservation service requires a number of guests parameter. The service provider wants existing clients to be unable to use the service. The author adds the element into the schema as a mandatory element.
Example 5-3. Additional Mandatory Elements in Content
<xs:complexType name="tCheckAvailabilityV2">
<xs:sequence>
<xs:element name="checkInDate" type="xs:date"/>
<xs:element name="checkOutDate" type="xs:date"/>
<xs:element name="roomType" type="xs:string"/>
<xs:element name="numberOfGuests" type="xs:integer"/>
<xs:any namespace="##other" processContents="lax"/>
</xs:sequence>
</xs:complexType>
The author has the choice of keeping the same namespace or using a different namespace for the additional content and the existing content. In this scenario, it is an incompatible change and the author decides to use a new name but the same namespace. This type is then used in the interface operation, and then binding and service endpoints.
Section 2.4.2 Interface Inheritance shows another type of versioning or extension, where the reservationInterface extends the MessageLogInterface. By definition of interface inheritance, a client that understands just the MessageLogInterface will continue to work with the reservationInterface, that it is backwards compatible.
Often mandatory operations are added to an interface. The Hotel service decides to add an operation to the reservation service which is a confirmation. The Hotel service requires that all clients upgrade to the new interface to use the service. They have a variety of options for indicating that the old interface is deprecated.
By the definition of interface inheritance, they cannot use interface inheritance for defining the extension.
Example 5-4. Additional Mandatory Operation Added to the Interface
<interface name="reservationWithConfirmation" extends="cc:creditCardFaults">
...
<operation name="makeReservation">
<input messageLabel="In" element="ghns:makeReservation" />
<output messageLabel="Out" element="ghns:makeReservationResponse" />
<outfault ref="invalidDataFault" messageLabel="Out" />
<outfault ref="cc:cancelledCreditCard" messageLabel="Out" />
<outfault ref="cc:expiredCreditCard" messageLabel="Out" />
<outfault ref="cc:invalidCreditCardNumber" messageLabel="Out" />
<outfault ref="cc:invalidExpirationDate" messageLabel="Out" />
</operation>
<operation name="confirmReservation">
<input messageLabel="In" element="ghns:makeReservationResponse" />
<output messageLabel="Out" element="ghns:confirmReservationResponse" />
<outfault ref="expiredReservation" messageLabel="Out" />
</operation>
</interface>
This interface cannot be bound and deployed at the existing URI and indicate incompatibility, as the service will still accept the makeReservation request. Changing the name of the interface from reservation to reservationWithConfirmation or changing the name of the operation from makeReservation to makeReservationV2 does not affect the messages that are exchanged. Thus it can't be used as a mechanism for indicating incompatibility. To indicate incompatibility, a change must be made to something that appears in the message. For a SOAP over HTTP request, the list is roughly the URI, the SOAP Action HTTP Header, or the Message content.
To indicate incompatibility, the URI of the Hotel Endpoint can be changed and messages send to the old Endpoint return a Fault.
The SOAP Action can be set for the makeReservation request, and making it different than the earlier version should indicate incompatibility.
例5-5. Indicating Incompatibility by changing the SOAP Action
<binding name="reservationSOAPBinding"
interface="tns:reservationInterface"
type="http://www.w3.org/ns/wsdl/soap"
wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">
<operation ref="tns:makeReservation"
wsoap:action="tns:makeReservationV2"/>
. . .
Note that this mechanism is applicable on a per-binding basis. The SOAP HTTP Binding provides for setting Action, but other bindings may not provide such a facility.
The namespace or name of the makeReservation element can be changed, and then the interface and bindings changed. To indicate incompatibility, requests using the old makeReservation QName should probably return a fault. The new interface, with a changed makeReservation, is:
Example 5-6. Indicating incompatibility by changing the element content
<xs:element name="ghns2:makeReservation" type="ghns:tmakeReservation"/>
<interface . . .>
<operation name="makeReservation">
<input messageLabel="In" element="ghns2:makeReservation" />
</interface>
The binding and service endpoints require no change.
Finally, the service could also provide an interface for ghns:makeReservation that only returns a fault.
Hyperlinking is one of the defining characteristics of the Web. The ability to navigate from one Web page to another is extremely useful. It is therefore natural to apply this capability to Web services. This section describes references to endpoints and services, which are the Web service analogs of document hyperlinks.
A reference to an endpoint is an element or attribute
that contains the address of a Web service endpoint. A reference
to a service is an element or attribute that contains one or more
references to the endpoints of a service. If the interface or binding
that the service or endpoint implements is known at description time, it
may be useful to add this information to the WSDL 2.0 document that
describes the Web service. This is accomplished by using the wsdlx:interface
or wsdlx:binding attribute to annotate the XML Schema
component that defines the message.
One may wonder, from a Web architectural point of view, why anything more than a URI would be needed to reference a Web service. Indeed, a reference to a service does make use of one or more URIs to indicate the endpoint addresses of a service. However, it may also include additional metadata about that service, such as the WSDL 2.0 interface and binding that the service supports.
References to services and endpoints will be illustrated by expanding the GreatH example already discussed.
When designing a Web application it is natural to give each important concept a URI. In the GreatH hotel reservation system, the important concepts are reservations, so we begin our design by assigning a URI to each reservation. Since each reservation has a unique confirmation number, e.g OMX736, we create a URI for each reservation by appending the confirmation number to a base URI, e.g. http://greath.example.com/2004/reservation/OMX736. This URI will be the endpoint address for a Reservation Details Web service that can retrieve and update the state of a reservation. 例5-7 shows the format of the reservation detail.
例5-7. Detail for Reservation OMX736
<?xml version="1.0" encoding="UTF-8"?>
<reservationDetails
xmlns="http://greath.example.com/2004/schemas/reservationDetails">
<confirmationNumber>OMX736</confirmationNumber>
<checkInDate>2005-06-01</checkInDate>
<checkOutDate>2005-06-03</checkOutDate>
<roomType>single</roomType>
<smoking>false</smoking>
</reservationDetails>
The Reservation Details Web service provides operations for
retrieving and updating the detail for a reservation. 例5-8 shows the description for this
Web service. Note that there is no service element in this
description since the set of reservations is dynamic. Instead, the
endpoints for the reservations will be returned by querying the
Reservation List Web service.
例5-8. The Reservation Details Web Service Description: reservationDetails.wsdl
<?xml version="1.0" encoding="utf-8" ?>
<description
xmlns="http://www.w3.org/ns/wsdl"
targetNamespace="http://greath.example.com/2004/services/reservationDetails"
xmlns:tns="http://greath.example.com/2004/services/reservationDetails"
xmlns:wdetails="http://greath.example.com/2004/schemas/reservationDetails"
xmlns:wsoap="http://www.w3.org/ns/wsdl/soap"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<documentation>
This document describes the GreatH Reservation Details Web
services. Use these services to retrieve or update reservation
details. Each reservation has its own service and endpoint. To
obtain the reference for a reservation service, make a request to
the GreatH Reservation List Web service. See
reservationList.wsdl for a description of the Reservation List
Web service.
</documentation>
<types>
<xs:import
namespace="http://greath.example.com/2004/schemas/reservationDetails"
schemaLocation="reservationDetails.xsd" />
</types>
<interface name="reservationDetailsInterface">
<operation name="retrieve"
pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="In" element="#none" />
<output messageLabel="Out"
element="wdetails:reservationDetails" />
</operation>
<operation name="update"
pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="In"
element="wdetails:reservationDetails" />
<output messageLabel="Out"
element="wdetails:reservationDetails" />
</operation>
</interface>
<binding name="reservationDetailsSOAPBinding"
interface="tns:reservationDetailsInterface"
type="http://www.w3.org/ns/wsdl/soap"
wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">
<operation ref="tns:retrieve"
wsoap:mep="http://www.w3.org/2003/05/soap/mep/request-response" />
<operation ref="tns:update"
wsoap:mep="http://www.w3.org/2003/05/soap/mep/request-response" />
</binding>
</description>
例5-9 shows the XML schema elements that are used in this Web service.
例5-9. The Reservation Details Web Service XML Schema: reservationDetails.xsd
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://greath.example.com/2004/schemas/reservationDetails"
xmlns:tns="http://greath.example.com/2004/schemas/reservationDetails"
xmlns:wdetails="http://greath.example.com/2004/services/reservationDetails"
xmlns:wsdli="http://www.w3.org/ns/wsdl-instance"
xmlns:wsdlx="http://www.w3.org/ns/wsdl-extensions"
wsdli:wsdlLocation="http://greath.example.com/2004/services/reservationDetails reservationDetails.wsdl">
<element name="confirmationNumber" type="string" />
<element name="checkInDate" type="date" />
<element name="checkOutDate" type="date" />
<element name="reservationDetails">
<complexType>
<sequence>
<element ref="tns:confirmationNumber" />
<element ref="tns:checkInDate" />
<element ref="tns:checkOutDate" />
<element name="roomType" type="string" />
<element name="smoking" type="boolean" />
</sequence>
</complexType>
</element>
<simpleType name="reservationDetailsSOAPEndpointType" wsdlx:binding="wdetails:reservationDetailsSOAPBinding">
<restriction base="anyURI"/>
</simpleType>
<element name="reservationDetailsSOAPEndpoint" type="tns:reservationDetailsSOAPEndpointType" />
<element name="reservationDetailsService">
<annotation>
<documentation>
This element contains references to the Reservation
Details Web Service endpoints for this reservation.
</documentation>
</annotation>
<complexType>
<sequence>
<element name="soap" type="tns:reservationDetailsSOAPEndpointType"/>
<element name="secure-soap" type="tns:reservationDetailsSOAPEndpointType"/>
</sequence>
</complexType>
</element>
</schema>
This XML schema contains the usual definitions for the elements
that appear in the messages of the Web service. For example, the reservationDetails
element is used in the messages of the retrieve and update
operations. In addition, the schema defines the simple type reservationDetailsSOAPEndpointType
which is based on xs:anyURI and has the annotation wsdlx:binding
= "wdetails:reservationDetailsSOAPBinding" which means that the URI is
the address of a Reservation Details Web service endpoint that
implements the wdetails:reservationDetailsSOAPBinding
binding. Note that the wsdli:wsdlLocation attribute is used
to define the location of the WSDL 2.0 document that defines the wdetails:reservationDetailsSOAPBinding
binding. This annotated simple type is used to define the reservationDetailsSOAPEndpoint
element which will be used in the Reservation List service.
Since the set of reservations changes as reservations are made and cancelled, the Reservation Detail endpoints are not described in a fixed WSDL 2.0 document. Instead they are returned as references to endpoints in response to requests made on a Reservation List Web service. The endpoint address for the Reservation List service will be http://greath.example.com/2004/reservationList.
例5-10 shows the format of the response from the Reservation List service.
例5-10. Response from the Reservation List Web Service
<?xml version="1.0" encoding="UTF-8"?>
<reservationList
xmlns="http://greath.example.com/2004/schemas/reservationList"
xmlns:details="http://greath.example.com/2004/schemas/reservationDetails">
<reservation>
<details:confirmationNumber>HSG635</details:confirmationNumber>
<details:checkInDate>2005-06-27</details:checkInDate>
<details:checkOutDate>2005-06-28</details:checkOutDate>
<details:reservationDetailsSOAPEndpoint>
http://greath.example.com/2004/reservation/HSG635
</details:reservationDetailsSOAPEndpoint>
</reservation>
<reservation>
<details:confirmationNumber>OMX736</details:confirmationNumber>
<details:checkInDate>2005-06-01</details:checkInDate>
<details:checkOutDate>2005-06-03</details:checkOutDate>
<details:reservationDetailsSOAPEndpoint>
http://greath.example.com/2004/reservation/OMX736
</details:reservationDetailsSOAPEndpoint>
</reservation>
<reservation>
<details:confirmationNumber>WUH663</details:confirmationNumber>
<details:checkInDate>2005-06-11</details:checkInDate>
<details:checkOutDate>2005-06-15</details:checkOutDate>
<details:reservationDetailsSOAPEndpoint>
http://greath.example.com/2004/reservation/WUH663
</details:reservationDetailsSOAPEndpoint>
</reservation>
</reservationList>
Here, the <details:reservationDetailsSOAPEndpoint>
elements contain references to the Reservation Details Web service
endpoints for the reservations HSG635, OMX736, and WUH663.
例5-11 shows the description of the Reservation List Web service. Note that it contains operations to retrieve the entire list and to query for a list of reservations by confirmation number, check-in date, and check-out date. In each case, the operation returns a list of reservations.
例5-11. The Reservation List Web Service Description: reservationList.wsdl
<?xml version="1.0" encoding="utf-8" ?>
<description
xmlns="http://www.w3.org/ns/wsdl"
targetNamespace="http://greath.example.com/2004/services/reservationList"
xmlns:tns="http://greath.example.com/2004/services/reservationList"
xmlns:details="http://greath.example.com/2004/schemas/reservationDetails"
xmlns:list="http://greath.example.com/2004/schemas/reservationList"
xmlns:wsoap="http://www.w3.org/ns/wsdl/soap"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<documentation>
This document describes the GreatH Reservation List Web
services. Use this service to retrieve lists of reservations
based on a variety of search criteria.
</documentation>
<types>
<xs:import
namespace="http://greath.example.com/2004/schemas/reservationDetails"
schemaLocation="reservationDetails.xsd" />
<xs:import
namespace="http://greath.example.com/2004/schemas/reservationList"
schemaLocation="reservationList.xsd" />
</types>
<interface name="reservationListInterface">
<operation name="retrieve"
pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="In" element="#none" />
<output messageLabel="Out" element="list:reservationList" />
</operation>
<operation name="retrieveByConfirmationNumber"
pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="In"
element="details:confirmationNumber" />
<output messageLabel="Out" element="list:reservationList" />
</operation>
<operation name="retrieveByCheckInDate"
pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="In" element="details:checkInDate" />
<output messageLabel="Out" element="list:reservationList" />
</operation>
<operation name="retrieveByCheckOutDate"
pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="In" element="details:checkOutDate" />
<output messageLabel="Out" element="list:reservationList" />
</operation>
</interface>
<binding name="reservationListSOAPBinding"
interface="tns:reservationListInterface"
type="http://www.w3.org/ns/wsdl/soap"
wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">
<operation ref="tns:retrieve"
wsoap:mep="http://www.w3.org/2003/05/soap/mep/request-response" />
<operation ref="tns:retrieveByConfirmationNumber"
wsoap:mep="http://www.w3.org/2003/05/soap/mep/request-response" />
<operation ref="tns:retrieveByCheckInDate"
wsoap:mep="http://www.w3.org/2003/05/soap/mep/request-response" />
<operation ref="tns:retrieveByCheckOutDate"
wsoap:mep="http://www.w3.org/2003/05/soap/mep/request-response" />
</binding>
<service name="reservationListService"
interface="tns:reservationListInterface">
<endpoint name="reservationListEndpoint"
binding="tns:reservationListSOAPBinding"
address="http://greath.example.com/2004/reservationList" />
</service>
</description>
例5-12 shows the schema for the messages used in the Reservation List Web service.
例5-12. The Reservation List Schema: reservationList.xsd
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://greath.example.com/2004/schemas/reservationList"
xmlns:tns="http://greath.example.com/2004/schemas/reservationList"
xmlns:details="http://greath.example.com/2004/schemas/reservationDetails"
xmlns:wsdli="http://www.w3.org/ns/wsdl-instance">
<import
namespace="http://www.w3.org/ns/wsdl-instance" />
<import
namespace="http://greath.example.com/2004/schemas/reservationDetails"
schemaLocation="reservationDetails.xsd" />
<element name="reservation">
<annotation>
<documentation>
A reservation contains the confirmation number, check-in
and check-out dates, and a reference to a Reservation
Details Web service.
</documentation>
</annotation>
<complexType>
<sequence>
<element ref="details:confirmationNumber" />
<element ref="details:checkInDate" />
<element ref="details:checkOutDate" />
<element ref="details:reservationDetailsSOAPEndpoint" />
</sequence>
</complexType>
</element>
<element name="reservationList">
<annotation>
<documentation>
A reservation list contains a sequence of zero or more
reservations.
</documentation>
</annotation>
<complexType>
<sequence>
<element ref="tns:reservation" minOccurs="0"
maxOccurs="unbounded">
</element>
</sequence>
<attribute ref="wsdli:wsdlLocation" />
</complexType>
</element>
</schema>
In the preceding example, there was a single endpoint associated
with each Reservation Detail Web service. Suppose GreatH hotel decided
to provide a second, secure endpoint. In this case, references to
services would be used to collect together the endpoints for each
reservation. The reservationDetails.xsd schema defines the reservationDetailsService
element for this purpose. It contains the nested elements soap
and secure-soap which are each of type reservationDetailsSOAPEndpointType
and therefore contain the address of an endpoint that implements the wdetails:reservationDetailsSOAPBinding
binding.
Example 5-13 shows an example of a message that contains a reference to the service for reservation HGS635. Note that the service contains two endpoints, one of which provides secure access to the Reservation Details Web service.
Example 5-13. A Reference to the Reservation Details Web Service
<?xml version="1.0" encoding="UTF-8"?>
<details:reservationDetailsService
xmlns:details="http://greath.example.com/2004/schemas/reservationDetails"
<details:soap>
http://greath.example.com/2004/reservation/HSG635
</details:soap>
<details:secure-soap>
https://greath.example.com/2004/reservation/HSG635
</details:secure-soap>
</details:reservationDetailsService>
This section presents a variation on the example in 5.3.1 The Reservation Details Web Service . It illustrates the use of HTTP transfer operations, GET and PUT, to retrieve and update GreatH hotel reservation details using the Representational State Transfer (REST) architectural style described by Roy Fielding [REST] . REST is a distillation of the architectural properties that Dr. Fielding identified as being vital to the Web's robustness and enormous scalability.
Since each reservation in our example will have a distinct URI, the Reservation Details Web service can be offered using HTTP GET and HTTP PUT. The binding would be modified as follows:
Example 5-14. Reservation Details Web Service Using HTTP Transfer
. . .
<binding name="reservationDetailsHTTPBinding"
type="http://www.w3.org/ns/wsdl/http"
interface="tns:reservationDetailsInterface" >
<operation ref="tns:retrieve"
whttp:method="GET" />
<operation ref="tns:update"
whttp:method="PUT" />
</binding>
. . .
As with the example in 5.3.1 The Reservation Details Web Service , service and endpoint elements are not provided because the Reservation List Web service provides the endpoints.
This section continues the REST-style example of 5.3.3 Reservation Details Web Service Using HTTP Transfer by modifying the example of 5.3.2 The Reservation List Web Service to use HTTP GET.
The SOAP version of the Reservation List Web service above offers four different search operations. These can also be expressed as various parameters in a URI used by HTTP GET:
Example 5-15. Reservation List Web Service Using HTTP GET
. . .
<binding name="reservationListHTTPBinding"
type="http://www.w3.org/ns/wsdl/http"
interface="tns:reservationListInterface"
whttp:methodDefault="GET">
<operation ref="tns:retrieve"
whttp:location="" />
<operation ref="tns:retrieveByConfirmationNumber"
whttp:location="reservationList/ConfirmationNumber/{confirmationNumber/}" />
<operation ref="tns:retrieveByCheckInDate"
whttp:location="reservationList/CheckInDate/{checkInDate/}" />
<operation ref="tns:retrieveByCheckOutDate"
whttp:location="reservationList/CheckOutDate/{checkOutDate/}" />
</binding>
. . .
<service . . . >
<endpoint name="reservationListEndpoint"
binding="tns:reservationListHTTPBinding"
address="http://greath.example.com/2004/reservationList" />
. . .
</service>
. . .
A retrieval by Confirmation Number URI would look like: http://greath.example.com/2004/reservationList/ConfirmationNumber/HSG635
.
Alternatively, a single query type may be provided. This query type is a sequence of optional items. Any items in the sequence are serialized into the URI query string. A query sequence for any of ConfirmationNumber, checkInDate, checkOutDate would look like this:
Example 5-16. Query Sequence Using a Single Query Type
<element name="reservationQuery">
<annotation>
<documentation>
A reservation contains the confirmation number, check-in
and check-out dates, and a reference to a Reservation
Details Web service.
</documentation>
</annotation>
<complexType>
<sequence>
<element ref="details:confirmationNumber" minOccurs="0"/>
<element ref="details:checkInDate" minOccurs="0"/>/>
<element ref="details:checkOutDate" minOccurs="0"/>/>
</sequence>
</sequence>
</complexType>
</element>
The WSDL 2.0 service that offers this type serialized as a parameter would look like this:
Example 5-17. WSDL 2.0 for Using a Single Query Type
. . .
<interface name="reservationListInterfaceWithQuery">
<operation name="retrieveByReservationQuery"
pattern="http://www.w3.org/ns/wsdl/in-out">
<input messageLabel="In"
element="details:ReservationQuery" />
<output messageLabel="Out"
element="list:reservationList" />
</operation>
</interface>
<binding name="reservationListQueryHTTPBinding"
type="http://www.w3.org/ns/wsdl/http"
interface="tns:reservationListInterfaceWithQuery"
whttp:methodDefault="GET">
<operation ref="tns:retrieveByReservationQuery"
whttp:location="reservationList/{ReservationQuery}}" />
</binding>
. . .
<endpoint name="reservationListEndpoint"
binding="tns:reservationListHTTPBinding"
address="http://greath.example.com/2004/reservationList" />
. . .
Various URIs would be: http://greath.example.com/2004/reservationList/ReservationQuery?confirmationNumber=HSG635
http://greath.example.com/2004/reservationList/ReservationQuery?checkInDate=06-06-05
.
It is important to observe that using the URI serialization can result in very flexible queries and few operations. The previous discrete SOAP operations are collapsed into one "parameterized" operation.
Suppose a Web service wishes to expose two different interfaces:
a customer interface for its regular users, and a management interface
for its operator. A wsdl:service specifies only one
wsdl:interface, so to achieve the desired effect the service provider
would somehow need to indicate a relationship between two services. How
can a service provider indicate a relationship between services?
Potential strategies include:
Declare both interfaces in the same wsdl:description element. Although WSDL 2.0 does not ascribe any particular significance to the fact that two wsdl:services are declared within the same wsdl:description, an application or toolkit could interpret this to mean that they are related in some way.
Declare both interfaces in the same wsdl:targetNamespace. Again, although WSDL 2.0 does not ascribe any particular significance to the fact that two wsdl:services are declared within the same wsdl:targetNamespace, an application or toolkit could interpret this to mean that they are related in some way.
Add an extension to WSDL 2.0 that links together all services that are related in this way. WSDL 2.0's open content model permits extension elements from other namespaces to appear in a WSDL 2.0 document.
Declare them in completely separate WSDL 2.0
documents, but use the same endpoint address for both. I.e., declare a
wsdl:interface and wsdl:service for the
customer interface in one WSDL 2.0 document, and a wsdl:interface
and wsdl:service for the management interface in a
different WSDL 2.0 document, but use the same endpoint address for
both. (By "different WSDL 2.0 document" we mean that both documents are
never included or imported into the same WSDL 2.0 descriptions
component.) Although this approach may work in some circumstances, it
means that the same endpoint address would be used for two different
purposes, which is apt to cause confusion or ambiguity. Furthermore, it
is contrary to the Web architectural principle that different URIs
should be used to identify different Web resources. (See the Web
Architecture [Web Architecture]
section on URI
collision.)
Use inheritance to combine the customer interface and management interface into a single, larger wsdl:interface. Of course, this reduces modularity and means that the management interface becomes exposed to the customers, which is not good.
Bear in mind that since the above strategies step outside of the WSDL 2.0 language specifies (and are therefore neither endorsed nor forbidden by the WSDL 2.0 specification) the WSDL 2.0 specification cannot define or standardize their semantics.
The desire to express relationships between services is also relevant to Web service versioning, discussed next.
WSDL 2.0は原始的にはXMLシンタックスで定義された言語である。 XMLはほぼどこでも理解されるので、幾つかの課題を抱えている:
二つのXML文書を一つに組み立てる能力は、それらの文書の言語に依存している。 WSDL 2.0では、異なるtargetNamespaces内のWebサービス記述を単一の(物理的な)XML文書にマージすることを許していない。
XML言語を他のXML言語で拡張する能力もまたその言語に依存している。 WSDL 2.0は飛び抜けて拡張可能であるが、WSDL 2.0内の各々の単一の拡張の意味は顕に定義されていなければならない。 XMI (UMLのXMLフォーマット)の一部をWSDL 2.0文書に持ち込むことは、それをXHTML文書に持ち込むこととは意味が異なるかもしれない。 従って、XMLベースの拡張性は、多くの言語を含むのことになるのであれば、とてもコストが高い。
同様に、他のXML言語のWSDL 2.0の一部による拡張は、もし可能であったとしても、全ての可能性のある目的地で定義されなければならない。 WSDL 2.0インタフェース要素をUDDIレジストリに持ち込むことは、インタフェース要素をXHMTL文書に持ち込むのとは別のことを意味するかもしれない。
最後に、WSDL 2.0文書の部分の意味はWSDL 2.0仕様では定義されない。 interface要素が単独のXML文書を形成できるとしても、それはWSDL
2.0文書ではなく、従ってその意味はぜんぜん定義されていない。
このレベルの組み立て可能性(または分解可能性)を必要とるアプリケーションは、ますますRDF [RDF]とグラフ・ベースのナレッジ表現言語とWeb Ontology Language (OWL) [OWL]に基づくようになる。OWLは RDFに対する発展的スキーマ言語として考えることができる。 実効的には、RDFで表されるWSDL 2.0文書は、抽象RDFアサーションでより簡単に拡張され得て、WSDL 2.0情報はより簡単に抽象的な他のナレッジに関連付けられる。
WSDL 2.0: Mapping to RDF [WSDL 2.0 RDF Mapping]は、いかにしてWSDL 2.0構造が、個々のリソースを超越してリソースのクラス(OWLで説明されているオントロジーで記述される)とアサーションを使ってRDFで表現され得るかを記述している。 RDFが複数のリソースとそれらの間の関係を使ってナレッジを表わすように、我々はWSDL 2.0コンセプトをこのモデルに還元する必要がある。 このことは次のようにして実施される。
まず、全てのWSDL 2.0内のコンポネント(インタフェース、オペレーション、バインディング、サービス、エンドポイントなどと拡張も含む)は、Appendix C IRI-References for WSDL 2.0 Components of [WSDL 2.0 Core]によって作成された適切なURIsで識別されるリソースに還元される。
更に、これらはりソースとして提示される:
XM LSchemaから集められた要素宣言(また同様に、他のタイプのシステムから集められた他のコンポネント)
メッセージ内容モデル
メッセージ交換パターン(MEPを識別するURIはりソースのURIである)
オペレーション・スタイル(MEPsと同様に、オペレーション・スタイルのURIはリソースのURIである)
上に挙げた全てのリソースは、適切な型をrdf:typeステートメントで与えられる(例えば、インタフェースはInterfaceクラスに属し、そのインタフェース内のオペレーションはInterfaceOperationクラスに属する)。
WSDL
2.0内の全ての関係(OperationがInterfaceへ所属しており、与えられたオペレーション型を持っていることのような)は、operationとoperationStyleのような適切なプロパティを使ってRDFステートメントに還元される。
XM LSchemaのターゲット名前空間と対応するスキーマのロケーションをもつXMLインスタンスのxmlns属性の値を等価に考えることは普遍的な誤解である。
例え名前空間がURIsで、URIsがロケーションかもしれなくて、そのロケーションからスキーマを取得することが可能かもしれなくても、このことは、取得されたスキーマが、名前空間と関連付けられる唯一つのスキーマであることを意味しはしない。
特定の名前空間に関連付けられた複数のスキーマが存在可能だし、特定の処理コンテキストの中でどれを使うか決定するのは、XML処理系に任せられている。
WSDL 2.0仕様では、ここにimportメカニズムによって処理コンテキストを提供し、このメカニズムは類似したコンセプトでのためにXML
Schemaの用語に基づいている。
この文書全体を通して、WSDL 2.0とXSDの例では、完全修飾URIsが存在する。 幾つかの場合では、完全修飾URIsは、単に、参照コンセプトを説明するために使われた。 しかしながら、相対URIsの利用は多くの場合に許され、正当化される。 相対URIsの処理に関する情報については、RFC3986を参照。
一般的には、WSDL 2.0文書が他の人たちに使われるために公開されるとき、グローバルに一意的なURIsだけを含んでいるべきである。 このことは、通常は、発行者の制御下にあるドメイン名配下のものを割り当てることで実施される。 例えば、W3Cでは、その基本ドメイン名w3.org配下の名前空間URIsを割り当てている。
しかしながら、時には、開発期間中の利用のために、実体に対する一時URIを作成し、全ての時間軸でグローバルに一意なURIにはしないが、そのバージョンの実体(スキーマ、WSDL 2.0文書など)を意味させたいことがある。 予約済みトップレベルDNS名 [IETF RFC 2606]は、このタイプの振る舞いのために使うために予約された幾つかのURIベースの名前を指定している。 例えば、ベースURI "http://example.org/"は、実体に対するいかなる一意的な関連付けも持たない一時URIを組み立てるために使うことができる。 これが意味するのは、二人の人、もしくは複数のプログラムが、二つの全く異なるスキーマのために、一時URI "http://example.org/userSchema"を同時に選択することができるということである。 これらのURIsを利用するスコープが交わらない限りにおいて、それらは十分に一意であるだろう。 しかしながら、安定的でフィックスされたエントリのためのベースとして"http://example.org/"を使うことはお勧めしない。
本文書は、W3C Web Service Description作業部会の作業結果である。
作業部会のメンバ(執筆時点、アルファベット順): Charlton Barreto (Adobe Systems, Inc), Allen Brookes (Rogue Wave Softwave), Dave Chappell (Sonic Software), Helen Chen (Agfa-Gevaert N. V.), Roberto Chinnici (Sun Microsystems), Kendall Clark (University of Maryland), Glen Daniels (Sonic Software), Paul Downey (British Telecommunications), Youenn Fablet (Canon), Ram Jeyaraman (Microsoft), Tom Jordahl (Adobe Systems), Anish Karmarkar (Oracle Corporation), Jacek Kopecky (DERI Innsbruck at the Leopold-Franzens-Universitat Innsbruck, Austria), Amelia Lewis (TIBCO Software, Inc.), Philippe Le Hegaret (W3C), Michael Liddy (Education.au Ltd.), Kevin Canyang Liu (SAP AG), Jonathan Marsh (WSO2), Monica Martin (Sun Microsystems), Josephine Micallef (SAIC - Telcordia Technologies), Jeff Mischkinsky (Oracle Corporation), Dale Moberg (Cyclone Commerce), Jean-Jacques Moreau (Canon), David Orchard (BEA Systems, Inc.), Gilbert Pilz (BEA Systems, Inc.), Tony Rogers (Computer Associates), Arthur Ryman (IBM), Adi Sakala (IONA Technologies), Michael Shepherd (Xerox), Asir Vedamuthu (Microsoft Corporation), Sanjiva Weerawarana (WSO2), Umit Yalcトアnalp (SAP AG), Peter Zehler (Xerox).
過去のメンバ: Eran Chinthaka (WSO2), Mark Nottingham (BEA Systems, Inc.), Hugo Haas (W3C), Vivek Pandey (Sun Microsystems), Bijan Parsia (University of Maryland), Lily Liu (webMethods, Inc.), Don Wright (Lexmark), Joyce Yang (Oracle Corporation), Daniel Schutzer (Citigroup), Dave Solo (Citigroup), Stefano Pogliani (Sun Microsystems), William Stumbo (Xerox), Stephen White (SeeBeyond), Barbara Zengler (DaimlerChrysler Research and Technology), Tim Finin (University of Maryland), Laurent De Teneuille (L'Echangeur), Johan Pauhlsson (L'Echangeur), Mark Jones (AT&T), Steve Lind (AT&T), Sandra Swearingen (U.S. Department of Defense, U.S. Air Force), Philippe Le Hegaret (W3C), Jim Hendler (University of Maryland), Dietmar Gaertner (Software AG), Michael Champion (Software AG), Don Mullen (TIBCO Software, Inc.), Steve Graham (Global Grid Forum), Steve Tuecke (Global Grid Forum), Michael Mahan (Nokia), Bryan Thompson (Hicks & Associates), Ingo Melzer (DaimlerChrysler Research and Technology), Sandeep Kumar (Cisco Systems), Alan Davies (SeeBeyond), Jacek Kopecky (Systinet), Mike Ballantyne (Electronic Data Systems), Mike Davoren (W. W. Grainger), Dan Kulp (IONA Technologies), Mike McHugh (W. W. Grainger), Michael Mealling (Verisign), Waqar Sadiq (Electronic Data Systems), Yaron Goland (BEA Systems, Inc.), Umit Yalcトアnalp (Oracle Corporation), Peter Madziak (Agfa-Gevaert N. V.), Jeffrey Schlimmer (Microsoft Corporation), Hao He (The Thomson Corporation), Erik Ackerman (Lexmark), Jerry Thrasher (Lexmark), Prasad Yendluri (webMethods, Inc.), William Vambenepe (Hewlett-Packard Company), David Booth (W3C), Sanjiva Weerawarana (IBM), Asir Vedamuthu (webMethods, Inc.), Igor Sedukhin (Computer Associates), Martin Gudgin (Microsoft Corporation), Rebecca Bergersen (IONA Technologies), Ugo Corda (SeeBeyond).
また、www-ws-desc@w3.orgでの議論に貢献した人々に対しても大いに感謝する。