You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

[ |../../../index.htm#lansa/webserviceseng01_0345.htm]
現在地: Webサービス > Webサービスの利用 > チュートリアル 3 - Web サービスを利用した .NET との相互運用性 > ユーザー認証メソッドを調整してユーザー HTTP 応答の呼び出しステータスを読み込む

ユーザー認証メソッドを調整してユーザー HTTP 応答の呼び出しステータスを読み込む

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 )
       Endif
    Endroutine
     
    次は: ユーザー認証サービスのテスト
    [ |../../../index.htm#lansa/webserviceseng01_0345.htm]
  • No labels