Authenticate メソッドに InvocationStatus という名前のパラメータを追加します。このパラメータは、前回定義したタイプ ExternalServiceInvocationStatus のオブジェクトを受け取ります。
Define_Map For(*INPUT) Class(#ExternalServiceInvocationStatus) Name(#InvocationStatus) Pass(*BY_REFERENCE) Mandatory(*NULL)
応答オブジェクトからステータスを読み込む次のコードを #Request.DoGet の後に追加します。
* 要求ステータス取得If (#InvocationStatus *IsNot *Null) #InvocationStatus.FromHttpResponse( #Request.Response )Endif
(黄色でハイライトされた新規の行の) 調整を加えて、Authenticate メソッドのソースコードを完成させます。
Mthroutine Name(Authenticate) * パラメータ Define_Map For(*INPUT) Class(#PRIM_DC.UnicodeString) Name(#Domain) Define_Map For(*INPUT) Class(#PRIM_DC.UnicodeString) Name(#UserName) Define_Map For(*INPUT) Class(#PRIM_DC.UnicodeString) Name(#Password) Define_Map For(*RESULT) Class(#PRIM_DC.UnicodeString) Name(#Result) Define_Map For(*INPUT) Class(#ExternalServiceInvocationStatus) Name(#InvocationStatus) Mandatory(*NULL) Pass(*BY_REFERENCE) * 変数 Define_Com Class(#XPRIM_UriBuilder) Name(#Url) Define_Com Class(#XPRIM_HttpRequest) Name(#Request) Define_Com Class(#XPRIM_RandomAccessJsonReader) Name(#Json) * URL のベース・プロパティ設定 #COM_SELF.SetupUrlBuilder Urlbuilder(#Url) * ''authenticate' パス・コンポーネント追加 #Url.AddPathComponent Pathcomponent('authenticate') * フォームのパラメータ追加 #Url.AddQueryString( 'domain' 'syd' ) #Url.AddQueryString( 'username' 'tony' ) #Url.AddQueryString( 'password' 'test' ) * HTTP 要求の実行 #Request.DoGet Url(#Url) * 認証結果を取得 #Json.SetSourceHttpResponse( #Request.Response ) #Result := #Json.ReadStringWithName( 'result' ) * 要求ステータス取得 If (#InvocationStatus *IsNot *Null) #InvocationStatus.FromHttpResponse( #Request.Response ) EndifEndroutine
次は: ユーザー認証サービスのテスト