FW APIServer 設定ガイド Version 1.4 2016 年 2 月 3 日富士通株式会社 i
改訂履歴 改訂 No. 日付 Version 章 No. 項 No. 改訂内容 1 2015/04/14 1.0 - - 新規作成 2 2015/06/02 1.1 3 表内 No.12 の備考欄を追記 3 2015/06/23 1.2 3 メソッドのフォワード先を とする注意事項を追記 4 2015/10/29 1.3 FW リファクタリング 5 2016/02/03 1.4 DELETE のマッピングが DELETE に変わったため修正 ii
目次 第 1 章 はじめに... 1 第 2 章 APISERVER とは... 2 第 3 章 定義ファイル詳細... 3 iii
第 1 章 はじめに 本書は FW の API サーバの設定ガイドです 1
第 2 章 APISERVER とは APIServer とは REST インタフェースに沿った URI を外部から受け付け 内部のシンプルイベントフローを呼び出すための URI へフォワードする機能を提供します APIServer の位置づけは以下の通りです 外部向け URI とシンプルイベントフローを呼び出すための URI の紐づけは定義ファイルで行います 定義ファイルについてはプラグインを使用し自動生成します 等 http://foo.com/api/customer/1234 http://foo.com/api/customer/1234 等 http://foo.com/restserver/uc001/op001 AP サーバ APIServer RESTServer シンプルイベントフロー PUT DELET 外部からの URI をシンプルイベントフロー の呼び出す URI に変換する 定義ファイル アプリケーションサーバ HTTP サーバ 2
第 3 章 定義ファイル詳細 APIServer は定義ファイル (UriMapping.xml) の定義に従い 外部向け URI とシンプルイベントフローを呼び出すための URI の紐づけを行います 定義ファイル (UriMapping.xml) はプラグインで自動生成します プラグインの詳細については RESTIF エディタマニュアル を参照してください 定義ファイルの詳細は以下の通りです ファイル名 UriMapping.xml No. URL 構成要素 属性 多重度 必須 設定値 備考 1 urimapping - 2 xmlns 1 http://com.fujitsu.fw.rest.server.uri.mapping 固定値 3 element - 1-* URI パターンごとに定義 4 no 1 連番 5 pattern 1 URI パターン ( 正規表現 ) URI のスラッシュ / 単位に括弧 ( ) で囲む 6 method - 1-4 APIServer が外部から受け付ける HTTP メソッドごとに定義する 7 name 1 APIServer が外部から受け付ける HTTP のメソッド (//PUT/DELETE) 8 forward - 1 フォワードする情報を定義する 9 method 1 シンプルイベントフローへフォワードする際に使用するメソッド (/) 10 usecaseid 1 URI にするユースケース ID 11 operationid 1 URI にするオペレーション ID 12 mapping - 0-* pattern の文字列をマップ上に設定するための定義 これらの値を設定した Map<String, String> は シンプルイベントフロー定義 (SEF 定義 ) のパラメータリストに格納 RP キーとして URI_MAPPING_DATA を指定すると取得できる 13 key 1 マップのキー 14 pattern-index 1 URI パターンの位置 pattern が (/customer)(/info)(/[\d]+)$ の場合 /customer/info/1234 の 1234 を指定したい場合は pattern-index=3 となる <?xml version="1.0" encoding="utf-8" standalone="yes"?> <urimapping xmlns="http://com.fujitsu.fw.rest.server.uri.mapping"> <element no="1" pattern="(/customer)(/info)(/[ d]+)$"> <method name=""> <forward usecaseid="uc001" operationid="op101" method="" /> <mapping key="id" pattern-index="3" /> </element> <element no="2" pattern="(/users)(/[0-9])"> <method name=""> <forward usecaseid="uc002" operationid="op201" method="" /> <method name=""> <forward usecaseid="uc002" operationid="op202" method="" /> <method name="put"> <forward usecaseid="uc002" operationid="op203" method="" /> <method name="delete"> <forward usecaseid="uc002" operationid="op205" method="" /> </element> </urimapping> 3
定義ファイル (UriMapping.xml) の設定内容に基づいた AP サーバの動作例を下記に示す AP サーバ シンプルイベントフロー 外部公開用 URI(APIServer) ユースケース (UC001) : http://{ ドメイン }/{ コンテキストルート }/API/customer/1234, DELETE, PUT URI を解析 & フォワード UriMapping.xml オペレーション A OP001 : http://{ ドメイン }/{ コンテキストルート }/RESTServer/UC001/OP001 ユースケース Y オペレーション C 既存の URI(RESTServer) オペレーション D (URI を解析 & フォワード ) ) 例 : A さん (ID=1234) の顧客情報を取得する シンプルイベントフロー上 UCID=UC001 OPID=001 で実装されている 外部公開する I/F 仕様 : http://{ ドメイン }/{ コンテキストルート }/API/customer/1234 UriMappinng.xml <element no="4" pattern="(/customer)(/[ d]+)$"> <method name=""> <forward usecaseid="uc001" operationid="op001" method="" /> </element> フォワードで呼びだす URI : http://{ ドメイン }/{ コンテキストルート }/RESTServer/UC001/OP001 4