WAS v8.5 > Develop applications > Develop web services - Notification (WS-Notification) > Develop applications that use WS-Notification

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. This example is based on using the Java API for XML-based remote procedure calls (JAX-RPC) APIs with code generated using the WSDL2Java tool (run against the Notification Broker WSDL generated as a result of creating your WS-Notification service point) and WebSphere Application Server APIs and SPIs.

In WAS there are two implementations of the WS-Notification service: v6.1 and v7.0. This JAX-RPC example can interact successfully with v6.1 or v7.0 WS-Notification service points. However to use WS-Notification with policy sets, for example to enable composition with WS-ReliableMessaging, then your WS-Notification applications must be encoded to use the Java API for XML-based Web Services (JAX-WS) programming model and must interact with v7.0 WS-Notification service points. If you are new to programming JAX-WS client applications, see the following topics:

  1. Look up the JAX-RPC service. The JNDI name is specific to the web services client implementation. The PauseSubscription operation belongs to the SubscriptionManager service.
  2. Get a stub for the port on which to invoke operations.
  3. Associate the request with the subscription 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 the 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 to invoke operations SubscriptionManager stub = (SubscriptionManager) service.getPort(SubscriptionManager.class);

// Associate the request with the subscription 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);


Related concepts:

JAX-RPC
WS-Notification


Related


Writing a WS-Notification application that exposes a web service endpoint
Writing a WS-Notification application that does not expose a web service endpoint
Filtering the message content of publications
Example: Subscribing a WS-Notification consumer
Example: Publishing a WS-Notification message
Example: Creating a WS-Notification pull point
Example: Getting messages from a WS-Notification pull point
Example: Registering a WS-Notification publisher
Example: Creating a Notification consumer web service skeleton
Use WS-Notification for publish and subscribe messaging for web services
Secure WS-Notification


Reference:

WSDL2Java command for JAX-RPC applications
WS-Notification troubleshooting tips


+

Search Tips   |   Advanced Search