knowledge base ―utilization of data from the...
TRANSCRIPT
Knowledge base―Utilization of Data from the Web―
吉岡真治
Questions of the last class
n F measureの式が何を意味しているのかがよくわからなかった。
Webデータベース
n スタンドアロンのデータベース
– 既存のデータベースのWeb用のインタフェースを利用する方法(PHPなど)
n 複数のデータベースの統合利用(Webサービスの統合)
– データのやり取りの規格化(SOAPなど)
スタンドアロンのWebデータベースの構築
n PHP– html,httpdと親和性の高いスクリプト言語– html中にデータベースの問い合わせに関する記述を行うと、結果がhtmlの形式で提供される
– apacheモジュールなどを利用することにより、CGIなどに比べ、負荷が少ない
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との違い:アプリケーションのドメインが明確であり、オントロジーなどの定義よりも、データ形式の互換性などが重要になる。(XML base)
– 分散されたWebサービス間のデータ交換とRPC (Remote Procedure Call)を支援
データ交換
RPC
宿と飛行機の手配
飛行機の空席検索
宿と飛行機の情報
飛行機会社旅行代理店
SOAPメッセージ
n SOAPメッセージの構成– SOAPエンベロープ
• SOAPヘッダ– SOAPメッセージのあて先などのヘッダ情報
• SOAP本体– SOAPによる処理手続きの記述
SOAPエンベロープにおける表記
n データをどのように表記するか
– データの内容• XMLスキーマによるシリアライゼーション
n RPCの表現– 呼び出す手続き– 与えるパラメータ– 結果の転送先– エラー処理
SOAPメッセージ
n XMLXを用いたSOAPメッセージの記述
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:itineraryxmlns: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:lodgingxmlns: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>
</env:Header>
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:transactionxmlns: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>
UDDI とWSDLによるWebサービスの連携
n UDDIによるサービス発見– ユーザもしくはエージェントによるWebサービスの選択
n WSDLによるインタフェース仕様の獲得n SOAPによるデータのやり取り
RPC
宿と飛行機の手配
飛行機の空席検索
宿と飛行機の情報
飛行機会社旅行代理店A
WSDL, データ交換
旅行代理店B旅行代理店C
UDDI
SOAP,UDDI,WSDLの使われる分野
n ビジネスとして定型的なやり取りが行われるような分野
– 実用的な運用を目指す– データの形式などの取り決めがちゃんとできる業界団体などがある。
– サービス提供者が期待していない使われ方はほとんどしない
n 柔軟な利用のためにはオントロジーなどSemantic Webなどの研究が必要となる
REST
n REST (Representational State Transfer)– SOAPと違った簡易なWebベースのソフトウェアーキテクチャ
• 全てのリソース(Webサイトが保持していて、外部に公開される内容)をURIで識別
• リソースに対するアクセスは、標準化されたインターフェースHTTPで行う。
– PUT(Create)、GET(Read)、POST(Update)、DELETE(Delete)が重要な操作であり、それぞれ処理内容に合わせた結果が返されなければならない。
• リソースにHTTPを通じてアクセスした結果をリソースの表現(Representation)と呼ぶ。
API
n Application Programming Interface– アプリケーションの持っている機能の抽象的な記述
n アプリケーションを呼び出すためのインターフェースを規定することにより、個別のアプリケーションをブラックボックスのように利用可能
– 個別のアプリケーションの中身を公開する必要がない– バージョンアップなどを行ってもAPIのレベルで共通であれば、プログラムの修正が不要
n WebベースのAPIはSOAPやRESTで公開されることが多い。
様々なWeb APIの公開
n Googleや、Yahoo!などが、各社で作成しているサービスをAPIという形で公開している– Google
• SOAPによる検索サービスの公開• そのほかにも、地図, AdWords,…
– Yahoo!• 検索サービス、地図、乗り換え案内、…
– Amazon• Amazon Web Service
マッシュアップによるアプリケーションの構築
n APIの組み合わせによるWebサービスの組み合わせ
n 具体例
– http://mashupaward.jp/
様々なWebアプリケーション構築フレームワーク
n Ajax:Asynchronous JavaScript + XML– ウェブブラウザ内で非同期通信とインターフェイスの構築などを行う技術の総称
– 従来のブラウザでは、画面全体を同期して更新していたが、画面の一部更新などが可能となった。
– APIサービスなどを組み合わせて、複数のWebアプリケーションの出力結果などを一つの画面に表示させるといった使い方や、キーボードの入出力を動的にチェックして、適切な機能を起動するといったことが可能となる
まとめ
n Webデータベースの構築法– スタンドアロンのデータベース
• PHPの利用• httpdとの融合によるWebページの自動更新
– 分散Webサービスの統合• SOAP, UDDI, WSDL• XMLスキーマレベルでのデータ統合• 使い方が限定的な場合に、しっかりしたデータ交換が可能になる。
– レガシーアプリケーションのWebサービスによる分散化
n APIを利用したマッシュアップという形式