Windows 8.1 Universal および Windows 10 UWP のエンドツーエンドのデモンストレーション

improve this page | report issue

概説

このデモンストレーションの目的は、エンドツーエンドのフローを体験することです。

  1. MobileFirst クライアント SDK と事前にバンドルされているサンプル・アプリケーションは登録済みで、MobileFirst Operations Console からダウンロードされています。
  2. 新規または提供済みのアダプターは MobileFirst Operations Console にデプロイされています。
  3. アプリケーション・ロジックは、リソース要求を行うために変更されています。

終了結果:

  • MobileFirst Server を正常に ping している。
  • アダプターを使用してデータを正常に取得している。

前提条件:

1. MobileFirst Server の開始

Mobile Foundation インスタンスが作成済みであることを確認してください。作成済みでない場合は、
MobileFirst Developer Kitを使用しているときは、サーバーのフォルダーにナビゲートして、コマンド ./run.cmd を実行します。

2. アプリケーションの作成

ブラウザー・ウィンドウで、URL http://your-server-host:server-port/mfpconsole をロードして MobileFirst Operations Console を開きます。 ローカルで実行している場合は、http://localhost:9080/mfpconsole を使用します。 ユーザー名/パスワードは admin/admin です。

  1. アプリケーションの隣の「新規」ボタンをクリックします。
    • Windows プラットフォームを選択します。
    • アプリケーション ID として、Windows の場合は MFPStarterCSharp.Windows を、Windows Phone の場合は MFPStarterCSharp.WindowsPhone を入力します。
    • 1.0.0version の値として入力します。
    • 「アプリケーションの登録」をクリックします。

    アプリケーションの登録

  2. 「スターター・コードの取得」タイルをクリックして、Windows 8.1 または Windows 10 サンプル・アプリケーションをダウンロードすることを選択します。

    サンプル・アプリケーションのダウンロード

3. アプリケーション・ロジックの編集

  1. Visual Studio プロジェクトを開きます。

  2. ソリューションの MainPage.xaml.cs ファイルを選択し、以下のコード・スニペットを GetAccessToken() メソッドに貼り付けます。

    try
       {
           IWorklightClient _newClient = WorklightClient.CreateInstance();
           accessToken = await _newClient.AuthorizationManager.ObtainAccessToken("");
           if (accessToken.IsValidToken && accessToken.Value != null && accessToken.Value != "")
           {
               System.Diagnostics.Debug.WriteLine("Received the following access token value: " + accessToken.Value);
               titleTextBlock.Text = "Yay!";
               statusTextBlock.Text = "Connected to MobileFirst Server";
    
               Uri adapterPath = new Uri("/adapters/javaAdapter/resource/greet",UriKind.Relative);
               WorklightResourceRequest request = _newClient.ResourceRequest(adapterPath, "GET","");
               request.SetQueryParameter("name", "world");
               WorklightResponse response = await request.Send();
    
               System.Diagnostics.Debug.WriteLine("Success: " + response.ResponseText);
    
             }
         }
         catch (Exception e)
         {
             titleTextBlock.Text = "Uh-oh";
             statusTextBlock.Text = "Client failed to connect to MobileFirst Server";
             System.Diagnostics.Debug.WriteLine("An error occurred: '{0}'", e);
         }
    

4. アダプターのデプロイ

この作成済みの .adapter 成果物をダウンロードし、MobileFirst Operations Console から「アクション」→「アダプターのデプロイ」アクションを使用して、この成果物をデプロイします。

サンプル・アプリケーション

5. アプリケーションのテスト

  1. Visual Studio で、mfpclient.resw ファイルを選択し、protocolhostport の各プロパティーをご使用の MobileFirst Server の正しい値で編集します。
    • ローカル MobileFirst Server を使用している場合、通常、値は httplocalhost、および 9080 です。
    • リモート MobileFirst Server (IBM Cloud 上) を使用している場合、通常、値は httpsyour-server-address、および 443 です。
    • IBM Cloud Private 上で Kubernetes クラスターを使用していて、デプロイメントのタイプが NodePort の場合、通常、ポートの値は、Kubernetes クラスターのサービスによって公開される NodePort です。

    あるいは、MobileFirst CLI がインストール済みの場合は、プロジェクト・ルート・フォルダーにナビゲートし、コマンド mfpdev app register を実行します。 リモート MobileFirst Server が使用されている場合は、コマンド mfpdev server add を実行してサーバーを追加し、続いて、例えば、mfpdev app register myIBMCloudServer を実行します。

  2. 「アプリケーションの実行 (Run App)」ボタンを押します。

結果

  • 「MobileFirst Server への ping (Ping MobileFirst Server)」ボタンをクリックすると、「MobileFirst Server に接続されています (Connected to MobileFirst Server)」が表示されます。
  • アプリケーションが MobileFirst Server に接続できた場合は、デプロイした Java アダプターを使用してリソース要求呼び出しが行われます。

その場合、アダプター応答が Visual Studio の出力コンソールに出力されます。

 MobileFirst Server からリソースを正常に呼び出したアプリケーションのイメージ

次の手順

アプリケーションでのアダプターの使用、プッシュ通知などの追加のサービスを統合する方法、MobileFirst セキュリティー・フレームワークの使用などについて学習します。

Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on July 02, 2019