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_0270.htm]
現在地: Webサービス > Webサービスの利用 > チュートリアル 2 - Web サービス経由で Java コードを実行 > コピー・サービスのテスト

コピー・サービスのテスト

再利用可能パーツ ExternalFileServices が完成したので、このテストを行います。
TestFileServicesModule という名前のサーバー・モジュールを作成し、次のコードをこのサーバー・モジュールに追加します。

  • フィールド
    Define Field(#Fld_SourcePath) Type(*NVARCHAR) Length(1000)
    Define Field(#Fld_TargetPath) Type(*NVARCHAR) Length(1000)
    Define Field(#Fld_Message) Type(*NVARCHAR) Length(2000)
  • サーバー・ルーチン
    Srvroutine Name(TestFileCopy)
       Field_Map For(*INPUT) Field(#Fld_SourcePath) Parameter_Name(SourcePath)
       Field_Map For(*INPUT) Field(#Fld_TargetPath) Parameter_Name(TargetPath)
       Field_Map For(*OUTPUT) Field(#Fld_Message) Parameter_Name(Message)
       * FileServices 再利用可能パーツのインスタンス作成
       Define_Com Class(#ExternalFileServices) Name(#Services)
       * 呼び出しステータス・オブジェクトのインスタンス作成
       Define_Com Class(#ExternalServiceInvocationStatus) Name(#Status)
       * Copy メソッドの起動
       #Services.Copy SourcePath(#Fld_SourcePath) TargetPath(#Fld_TargetPath) InvocationStatus(#Status)
       * ステータスが OK でない場合は、エラー・メッセージを取得
       If (*Not #Status.OK)
          #Fld_Message := #Status.ErrorMessage
       Endif
    Endroutine
    Web ページを作成して、サーバー・モジュールを呼び出します。
    Evtroutine Handling(#Com_owner.Initialize)
       Define_Com Class(#TestFileServicesModule.TestFileCopy) Name(#FileCopy)
       Define_Com Class(#PRIM_DC.UnicodeString) Name(#Message)
       * サーバー・ルーチン経由で Copy サービスを起動
       * ソースとターゲット・ファイルのパスは要調整
       #FileCopy.Execute SourcePath('/home/tony/a.txt') TargetPath('/home/tony/b.txt') Message(#Message)
       * サーバー・ルーチンがエラー・メッセージを返しているか確認
       If (#Message.CurChars > 0)
          #SYS_WEB.Alert( #Message )
       Else
          #SYS_WEB.Alert( 'All good!')
       Endif
    Endroutine
    次は: Tomcat ジョブをバッチ・モードで開始
    [ |../../../index.htm#lansa/webserviceseng01_0270.htm]
  • No labels