Example: Pausing a WS-Notification subscription

Use this task to write the code for a JAX-RPC client acting in the subscriber role, pausing a subscription for a consumer application, based on the example code extract provided.

About this task

這個範例的基礎如下:搭配 WSDL2Java 工具產生的程式碼(針對建立 WS-Notification 服務點所產生的「通知分配管理系統 WSDL」來執行這個工具)及 WebSphere® Application Server API 和 SPI,來使用 Java™ API for XML 型遠端程序呼叫 (JAX-RPC) API。

In WebSphere Application Server there are two implementations of the WS-Notification service: Version 6.1 and Version 7.0. 這個 JAX-RPC 範例可以與 6.1 版或 7.0 版 WS-Notification 服務點順利互動。 不過,如果您想要搭配原則集來使用 WS-Notification,例如,能夠與 WS-ReliableMessaging 組合起來,您的 WS-Notification 應用程式就必須編碼為使用 Java API for XML 型 Web 服務 (JAX-WS) 程式設計模型,且必須與 7.0 版 WS-Notification 服務點互動。 如果您還不熟悉如何撰寫 JAX-WS 用戶端應用程式,請參閱下列主題:

Procedure

  1. Look up the JAX-RPC service. The JNDI name is specific to your web services client implementation. The PauseSubscription operation belongs to the SubscriptionManager service.
  2. Get a stub for the port on which you want to invoke operations.
  3. Associate the request with the subscription you want to pause. The subscriptionEPR is the EndpointReference returned by the invocation of the Subscribe operation.
  4. Create any optional information.
  5. Invoke the PauseSubscription operation by calling the associated method on the stub.

Example

The following example code describes a JAX-RPC client acting in the subscriber role, pausing a subscription for a consumer application:

// Look up the JAX-RPC service. The JNDI name is specific to your web services client implementation.
// The PauseSubscription operation belongs to the SubscriptionManager service
InitialContext context = new InitialContext();
javax.xml.rpc.Service service = (javax.xml.rpc.Service) context.lookup("java:comp/env/services/SubscriptionManager");

// Get a stub for the port on which you want to invoke operations
SubscriptionManager stub = (SubscriptionManager) service.getPort(SubscriptionManager.class);

// Associate the request with the subscription you want to pause. The subscriptionEPR is the
// EndpointReference returned by the invocation of the Subscribe operation
((Stub) stub)._setProperty(WSAConstants.WSADDRESSING_DESTINATION_EPR, subscriptionEPR);

// Create any optional information
SOAPElement[] optionalInformation =  new SOAPElement[] {};

// Invoke the PauseSubscription operation by calling the associated method on the stub
SOAPElement[] additionalReturnedInformation = stub.pauseSubscription(optionalInformation);

指出主題類型的圖示 作業主題



時間戳記圖示 前次更新: July 9, 2016 11:16
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tjwsn_ex_sub_pause
檔名:tjwsn_ex_sub_pause.html