例: WS-Notification pull ポイントの作成
このタスクでは、JAX-RPC サブスクライバー・クライアントのコードを作成します。このクライアントは、pull スタイルの通知を使用するコンシューマー・アプリケーションで使用される pull ポイントを作成します。
このタスクについて
この例は 、Java™ API for XML-based remote procedure calls (JAX-RPC) API と、WSDL2Java ツール (WS-Notification サービス・ポイントの作成の結果として生成された Notification Broker WSDL に対し実行) および WebSphere® Application Server API および SPI を使用して生成されたコードと併せた使用を基にしています。
WebSphere Application Server では、WS-Notification サービスにはバージョン 6.1 およびバージョン 7.0 の 2 つの実装があります。この JAX-RPC 例は、バージョン 6.1 またはバージョン 7.0 WS-Notification サービス・ポイントと正常にやり取りすることができます。 ただし、WS-Notification をポリシー・セットと一緒に使用したい場合は (例えば、WS-ReliableMessaging による構成を可能にするため)、Java API for XML-based Web Services (JAX-WS) プログラミング・モデルを使用するように WS-Notification アプリケーションをエンコードする必要があります。なおかつ WS-Notification アプリケーションはバージョン 7.0 WS-Notification サービス・ポイントとやり取りする必要があります。 JAX-WS クライアント・アプリケーションをプログラミングした経験がない場合は、以下のトピックを参照してください。
サブスクライバー・ロールを果たす JAX-RPC クライアントが、pull スタイルの通知を使用するコンシューマー・アプリケーションで使用される pull ポイントを作成するコードを記述するには、以下のステップを実行します (詳しくは、コード例の抜粋を参照)。
手順
- JAX-RPC サービスを検索します。 JNDI 名は、Web サービス・クライアントの実装に固有のものです。
- 操作の呼び出しを行うポートのスタブを取得します。
- 要求情報を作成します。
- スタブで関連付けられているメソッドを呼び出して、CreatePullPoint 操作を呼び出します。
- 応答から、pull ポイントへの参照を取得します。
- 応答から追加情報を取得します。
例
以下は、サブスクライバー・ロールを果たす JAX-RPC クライアントが、pull スタイルの通知を使用するコンシューマー・アプリケーションで使用される pull ポイントを作成するコードの例を示しています。
// Look up the JAX-RPC service. The JNDI name is specific to your web services client implementation
InitialContext context = new InitialContext();
javax.xml.rpc.Service service = (javax.xml.rpc.Service) context.lookup(
"java:comp/env/services/NotificationBroker");
// Get a stub for the port on which you want to invoke operations
NotificationBroker stub = (NotificationBroker) service.getPort(NotificationBroker.class);
// Create the request information.
SOAPElement[] optionalInformation = null;
CreatePullPoint cpp = new CreatePullPoint(optionalInformation);
// Invoke the CreatePullPoint operation by calling the associated method on the stub
CreatePullPointResponse response = stub.createPullPoint(cpp);
// Retrieve the reference to the pull point from the response
EndpointReference pullPointEPR = response.getPullPoint();
// Retrieve any additional information from the response
SOAPElement[] additionalInformation = response.getElements();