JAX-RPC Web サービス |
|
|
![]() |
|
構成と実行 | 技術情報 | Javadoc | Ant を使用したビルド |
サンプルの構成 |
サンプルの実行 |
2 つの AddressBook クライアント、Java 2 Standard Edition (J2SE) バージョンと Java 2 Enterprise Edition (J2EE) コンテナー管理バージョンがあります。 J2EE コンテナー・サービスを最大限に利用するには、J2EE バージョンを実行してください。
このサンプルの構成を完了するには、JAX-RPC の Web サービス・サンプル・アプリケーションをサーバーにデプロイしてください。サンプル・アプリケーションがまだデプロイされていない場合、 WebServicesSamples.ear ファイルの再ビルドおよびデプロイの手順を参照してください。
クライアントを実行する前に、サーバーが開始されていることを確認してください。
2 つの AddressBook クライアント、J2SE 外部バージョンと Java 2 Enterprise Edition (J2EE) コンテナー管理バージョンがあります。 クライアントはそれぞれ、サーバーにデプロイされている AddressBook Web サービス Bean の 4 つのバリエーションを使用します。 AddressBook Web サービス Bean は固定値を返し、実行のためにインターネット接続を必要としません。
J2SE シンプル AddressBook クライアントの実行 |
J2EE アプリケーション AddressBook クライアントの実行 |
J2SE AddressBook クライアントは、住所を Web サービスから取得するための Web サービス AddressBook Bean について説明しています。 そのソースは profile_root/samples/src/WebServicesSamples/Clients/simpleClients/samples/address ディレクトリーにあります。
AddressBookClient を実行するとき、AddressBook.wsdl ファイルが現行ディレクトリーになければなりません。 AddressBook.wsdl ファイルを simpleClients.jar ファイルから解凍し、 サンプルを実行したいディレクトリーに置いてください。 simpleClients.jar ファイルは install_root/samples/lib/WebServicesSamples ディレクトリーにあります。
サーバーにデプロイされている AddressBook Web サービス Bean それぞれで、J2SE クライアントは 2 度ループします。 最初のループの間、クライアントは getPort メソッドを呼び出し、サンプル・アプリケーションの Bean ごとに固有のポートを取得します。 クライアントは、ポートごとに getAddressFromName メソッドを呼び出します。 2 番目のループは場合に応じて、ポートのいずれかとともに開始され、ループし、そのエンドポイント・アドレスを 4 つの考えられるエンドポイントそれぞれに設定します。 クライアントは、ポートごとに getAddressFromName メソッドを呼び出します。
WebSphere クライアントの呼び出しに関する一般的な手順については、 Info Center でシン・アプリケーション・クライアント・コードの開発に関するトピックを参照してください。
J2SE シンプル AddressBook クライアントを WebSphere Application Server から実行するには、
使用するオペレーティング・システムに応じて以下のステップを実行してください。
C:¥>"%JAVA_HOME%¥bin¥java" %WAS_LOGGING% -classpath "%WAS_CLASSPATH%;%WAS_HOME%¥samples¥lib¥WebServicesSamples¥simpleClients.jar;%WAS_HOME%¥runtimes¥com.ibm.ws.webservices.thinclient_7.0.0.jar" samples.address.AddressBookClient >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JE >> Response is: 1 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WE >> Response is: 2 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WB >> Response is: 3 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JB >> Response is: 4 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> >> Get port AddressBookJ2WB >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookW2JE/services/AddressBook >> Querying address for 'Purdue Boilermaker' >> Response is: 1 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookJ2WE/services/AddressBook >> Querying address for 'Purdue Boilermaker' >> Response is: 2 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookJ2WB/services/AddressBook >> Querying address for 'Purdue Boilermaker' >> Response is: 3 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookW2JB/services/AddressBook >> Querying address for 'Purdue Boilermaker' >> Response is: 4 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 |
J2EE アプリケーション AddressBook クライアントは、J2SE シンプル AddressBook クライアントに似ています。 このクライアントは、同じ AddressBook Web サービス Bean にアクセスしますが、launchClient コマンドを使用して J2EE アプリケーション・クライアント・コンテナーからアクセスします。
サーバーにデプロイされている AddressBook Web サービス Bean それぞれで、J2EE クライアントはループします。 このクライアントは Java Naming and Directory Interface (JNDI) lookup コマンドを使用して AddressBook サービスを検索し、ポート取得呼び出しを実行して 4 つの AddressBook Bean ごとに固有のポートを取得します。 クライアントは、ポートごとに getAddressFromName メソッドを呼び出します。
以下のステップで、変数 install_root は、WebSphere インストール・ルートを指しています。
J2EE アプリケーション AddressBook クライアントを WebSphere Application Server から実行するには、
使用するオペレーティング・システムに応じて以下のステップを実行してください。
C:¥WebSphere¥AppServer¥samples>¥WebSphere¥AppServer¥bin¥launchClient ¥WebSphere¥AppServer¥samples¥lib¥WebServicesSamples¥ApplicationClients.ear -CCjar=AddressBookClient.jar IBM WebSphere Application Server リリース 7.0 J2EE アプリケーション・クライアント・ツール Copyright IBM Corp., 1997-2008 WSCL0012I: コマンド行引数を処理しています。 WSCL0013I: J2EE アプリケーション・クライアント環境を初期化しています。 [3/29/06 14:47:51:062 CST] 0000000a W UOW=null source=com.ibm.ws.ssl.config.SSLConfig org=IBM prod=WebSphere component=Application Server thread=[P=269328:O=0:CT] CWPKI0041W: 1 つ以上の鍵ストアでデフォルト・パスワードが使用されています。 WSCL0035I: J2EE アプリケーション・クライアント環境の初期化が完了しました。 WSCL0014I: アプリケーション・クライアント・クラス com.ibm.websphere.samples.webservices.addr.AddressBookClient を起動しています。 >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JE >> Response is: 1 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WE >> Response is: 2 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WB >> Response is: 3 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JB >> Response is: 4 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 |
どのようにクライアントとアプリケーションが機能するかについては、Address Book 技術情報を参照し、Java ソース・コードを 表示してください。