知識ベース特論 第
6回
―
Webデータベース―
本講義のすすめかた
n
情報検索
n
Semantic Web
– コンピュータがWebページの意味(Semantic)を理解し、
組み合わせて問題解決にあたれるようにするための
方法論
n
Webデータベース
n
Web2.0時代のWeb上の知識
n
授業資料(火曜日か金曜日の午後には公開)
http://www-kb.ist.hokudai.ac.jp/~yoshioka/kb/
n
質問・レポートはメールで
yoshioka@ist.hokudai.ac.jp
前回の答
n
問題
– 家畜(人間に飼われていて食べる人間がいる動物)
Animal ⊓ ∃ eaten-by.Human ⊓ ∃ bred-by.Human
– 家畜(人間のみに食べられるために飼われている動物)
Animal ⊓ ∀ eaten-by.Human ⊓ ∃ bred-by.Human
家畜(人間のみに食べられるために飼われていて、食べる
人間がいた動物)
Animal ⊓ ∃ eaten-by.Human ⊓ ∀ eaten-by.Human
⊓ ∃ bred-by.Human
– 先生(人間を教える人間)
Human ⊓ ∃ has-student.Human
– 女の先生
Female ⊓ ∃ has-student.Human
– 男子学生のみを教えている先生
前回の質問
n
ロールの全称、存在記号がよくわからなかった
。あるなしだけでなく、判別できないというのも
表現できるのか?
n
計算量が多いと聞きましたが、具体的なオー
ダーはどのくらいですか?
前回の質問
n
OWLのように順番を入れ替えてしまうよなこと
ってよくあるのですか?
n
人工知能に関してなのですが、学習する際に
属性値等をもたせて学習することによって精度
は上がるのでしょうか?
n
定理の自動証明の研究はどこまでやられてい
るのか?
Webデータベース
n
スタンドアロンのデータベース
– 既存のデータベースのWeb用のインタフェースを利用
する方法
(PHPなど)
n
複数のデータベースの統合利用(
Webサービス
の統合)
– データのやり取りの規格化(SOAPなど)
スタンドアロンの
Webデータベースの構築
n
PHP
– html,httpdと親和性の高いスクリプト言語
– html中にデータベースの問い合わせに関する記述を
行うと、結果が
htmlの形式で提供される
– apacheモジュールなどを利用することにより、CGIなど
に比べ、負荷が少ない
– 2004年7月にオブジェクト指向の拡張を行ったPHP5の
利用が始まっている。
n
Ruby on Rails
– PHPと同様にhttpdと連携して、データベースの問い合
わせなどを含む
Webアプリケーションが構築可能
– Ajaxなどによるインタラクティブなアプリケーションが
容易に構築可能
分散データベースの統合
n
分散環境にある異なるデータを組み合わせて利
用したい
– ある程度限定されたコミュニティでの利用を前提
n
統合方法に特有のプロトコルを利用した方法
– COM (Component Object Model)
– CORBA (Common Object Request Broker
Architecture)
– プロトコルの拡張性が限定されており、ファイアー
ウォールなどの問題もある。
CORBA
n
分散システムの統合を目指す
– 既存のアプリケーション(レガシーアプリケーション)の
入出力のレベルのインタフェースを統一することにより、
アプリケーション統合を支援
– 3-tier構成
– ORB (Object Request Broker)によるアプリケーション
の連携
クライアント
サーバ
クライアント
アプリケーションサーバ
データサーバ
2-tier構成
3-tier構成
複数の
Webサービスの統合
n
SOAP
– 分散された複数のWeb上に存在する情報を統合し利
用する方法
• Semantic Webとの違い:アプリケーションのドメイン
が明確であり、オントロジーなどの定義よりも、デー
タ形式の互換性などが重要になる。
– 分散されたWebサービス間のデータ交換とRPC
(Remote Procedure Call)を支援
– XMLベースのデータ交換
データ交換
RPC
宿と飛行機の手配
飛行機の空席検索
宿と飛行機の情報
飛行機会社
旅行代理店
SOAPメッセージ
n
SOAPメッセージの構成
– SOAPエンベロープ
• SOAPヘッダ
– SOAPメッセージのあて先などのヘッダ情報
• SOAP本体
– SOAPによる処理手続きの記述
SOAPエンベロープにおける表記
n
データをどのように表記するか
– XMLスキーマによるシリアライゼーション
– データの内容
n
RPCの表現
– 呼び出す手続き
– 与えるパラメータ
– 結果の転送先
– エラー処理
SOAPメッセージの埋め込み
n
httpへの埋め込み
n
Eメールに埋め込むことも可能
httpヘッダ
SOAPエンベロープ
SOAPヘッダ
SOAP本体
n
SOAP Version 1.2 Part 0: Primer (Second Edition)
http://www.w3.org/TR/2007/REC-soap12-part0-20070427/
SOAPメッセージの例:旅行システムにおける
Interaction例
<?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Header> <m:reservation xmlns:m="http://travelcompany.example.org/reservation" env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true"> <m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</m:reference> <m:dateAndTime>2001-11-29T13:20:00.000-05:00</m:dateAndTime> </m:reservation> <n:passenger xmlns:n="http://mycompany.example.com/employees" env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true"><n:name>Ake Jogvan Oyvind</n:name> </n:passenger>
</env:Header>
SOAP
ヘッダ
SOAPメッセージの例
<env:Body> <p:itinerary xmlns:p="http://travelcompany.example.org/reservation/travel"> <p:departure> <p:departing>New York</p:departing> <p:arriving>Los Angeles</p:arriving> <p:departureDate>2001-12-14</p:departureDate> <p:departureTime>late afternoon</p:departureTime> <p:seatPreference>aisle</p:seatPreference> </p:departure> <p:return> <p:departing>Los Angeles</p:departing> <p:arriving>New York</p:arriving> <p:departureDate>2001-12-20</p:departureDate> <p:departureTime>mid-morning</p:departureTime> <p:seatPreference/> </p:return> </p:itinerary> <q:lodging xmlns:q="http://travelcompany.example.org/reservation/hotels"> <q:preference>none</q:preference> </q:lodging> </env:Body> </env:Envelope>SOAP
本体
旅程情
報を記述
SOAPメッセージの例:システムからの返答
n
選択を求める返答(ヘッダ部分は、ほぼ同じ)
<?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Header> <m:reservation xmlns:m="http://travelcompany.example.org/reservation" env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true"> <m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</m:reference> <m:dateAndTime>2001-11-29T13:35:00.000-05:00</m:dateAndTime> </m:reservation> <n:passenger xmlns:n="http://mycompany.example.com/employees" env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true"><n:name>Ake Jogvan Oyvind</n:name> </n:passenger>
SOAPメッセージの例:システムからの返答
<env:Body> <p:itineraryClarification xmlns:p="http://travelcompany.example.org/reservation/travel"> <p:departure> <p:departing> <p:airportChoices> JFK LGA EWR </p:airportChoices> </p:departing> </p:departure> <p:return> <p:arriving> <p:airportChoices> JFK LGA EWR </p:airportChoices> </p:arriving> </p:return> </p:itineraryClarification> </env:Body> </env:Envelope>SOAP
本体
飛行場を
問い合わせ
JFK
ラガーディア
ニューアーク
SOAPメッセージの例:システムへの回答
n
ヘッダ部分は省略
<env:Body> <p:itinerary xmlns:p="http://travelcompany.example.org/reservation/travel"> <p:departure> <p:departing>LGA</p:departing> </p:departure> <p:return> <p:arriving>EWR</p:arriving> </p:return> </p:itinerary> </env:Body>SOAPメッセージの例: RPCによる手続きの
実行
<env:Header> <t:transaction xmlns:t="http://thirdparty.example.org/transaction" env:encodingStyle="http://example.com/encoding" env:mustUnderstand="true" >5</t:transaction> </env:Header> <env:Body> <m:chargeReservation env:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:m="http://travelcompany.example.org/"> <m:reservation xmlns:m="http://travelcompany.example.org/reservation"> <m:code>FT35ZBQ</m:code> </m:reservation> <o:creditCard xmlns:o="http://mycompany.example.com/financial"> <n:name xmlns:n="http://mycompany.example.com/employees"> Ake Jogvan Oyvind</n:name> <o:number>123456789099999</o:number> <o:expiration>2005-02</o:expiration> </o:creditCard> </m:chargeReservation> </env:Body>
SOAP
本体
手続き
呼び出し
SOAPメッセージの例: RPCの結果
<?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" > <env:Header> <t:transaction xmlns:t="http://thirdparty.example.org/transaction" env:encodingStyle="http://example.com/encoding" env:mustUnderstand="true">5</t:transaction> </env:Header> <env:Body> <m:chargeReservationResponse env:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:rpc="http://www.w3.org/2003/05/soap-rpc" xmlns:m="http://travelcompany.example.org/"> <rpc:result>m:status</rpc:result> <m:status>confirmed</m:status> <m:code>FT35ZBQ</m:code> <m:viewAt> http://travelcompany.example.org/reservations?code=FT35ZBQ </m:viewAt> </m:chargeReservationResponse> </env:Body> </env:Envelope>SOAP
本体
呼び出し
結果
Webサービスの発見
n
UDDI(Universal Description, Discovery and
Integration)
– レジストリサービス(UDDI registry)
• どのようなサービスを提供するサービスがあるの
か?
– ディレクトリ型のサービス検索
• ホワイトページ:名前で検索
• イエローページ:業種別で検索
• グリーンページ:Webサービスを利用するにあたっ
ての技術情報での検索
Webサービスの記述
n
WSDL (Web Service Description Language)
– Webサービスで何ができるかを記述
– 記述する情報
• types: 使用するデータ型の定義
• message: Webサービスでやり取りをするメッセージの定義と
そこで用いるデータの抽象定義
• operation: 操作の抽象的な定義 messageを参照
• portType: operationのセット
• binding: 特定のportTypeによって定義された操作とmessage
の関係付け
• port: 実際にWeb サービスを提供するサーバのURLなどの
通信端点の情報
• service: 関連する通信端点の情報をひとまとめに記述
WSDLの例: http://www.w3.org/TR/wsdl
<?xml version="1.0"?> <definitions name="StockQuote“ targetNamespace="http://example.com/stockquote.wsdl" xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <types> <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2000/10/XMLSchema"> <element name="TradePriceRequest"> <complexType> <all><element name="tickerSymbol" type="string"/> </all> </complexType> </element> <element name="TradePrice"> <complexType> <all>
<element name="price" type="float"/> </all> </complexType> </element> </schema> </types>
Types
WSDLの例
<message name="GetLastTradePriceInput">
<part name="body" element="xsd1:TradePriceRequest"/> </message>
<message name="GetLastTradePriceOutput">
<part name="body" element="xsd1:TradePrice"/> </message> <portType name="StockQuotePortType"> <operation name="GetLastTradePrice"> <input message="tns:GetLastTradePriceInput"/> <output message="tns:GetLastTradePriceOutput"/> </operation> </portType>
WSDLの例
<binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="GetLastTradePrice"> <soap:operation soapAction="http://example.com/GetLastTradePrice"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </binding> <service name="StockQuoteService">
<documentation>My first service</documentation>
<port name="StockQuotePort" binding="tns:StockQuoteBinding"> <soap:address location="http://example.com/stockquote"/>
</port> </service> </definitions>