Example: Getting messages from a WS-Notification pull point

Use this task to write the code for a JAX-RPC client acting in the pull style consumer role, requesting messages from a pull point, based on the example code extract provided.

About this task

This example is based on using the Java API for XML-based remote procedure calls (JAX-RPC) APIs with code generated by 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 WebSphere Application Server there are two implementations of the WS-Notification service: Version 6.1 and Version 7.0. This JAX-RPC example can interact successfully with Version 6.1 or Version 7.0 WS-Notification service points. However if you want 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 Version 7.0 WS-Notification service points. If you are new to programming JAX-WS client applications, see the following topics:

To write the code for a JAX-RPC client acting in the pull style consumer role, requesting messages from a pull point, complete the following steps, referring to the example code extract for further information.

Procedure

  1. Look up the JAX-RPC service. The JNDI name is specific to your web services client implementation.
  2. Get a stub for the port on which you want to invoke operations.
  3. Associate the request with a pull point. The pullPointEPR is the EndpointReference returned from invoking the CreatePullPoint operation.
  4. Specify the number of messages you want to retrieve.
  5. Create any optional information.
  6. Create the request information.
  7. Invoke the GetMessages operation by calling the associated method on the stub.
  8. Get the messages returned from the response.

Example

The following example code describes a JAX-RPC client acting in the pull style consumer role, requesting messages from a pull point:

// 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);

// Associate the request with a pull point. The pullPointEPR is the EndpointReference returned
// from invoking the CreatePullPoint operation
((Stub) stub)._setProperty(WSAConstants.WSADDRESSING_DESTINATION_EPR, pullPointEPR);

// Specify the number of messages you want to retrieve
Integer numberOfMessages = new Integer(2);

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

// Create the request information
GetMessages request = new GetMessages(numberOfMessages, optionalInformation);

// Invoke the GetMessages operation by calling the associated method on the stub
GetMessagesResponse response = stub.getMessages(request);

// Get the messages returned from the response
NotificationMessage[] messages = response.getMessages();



In this information ...


Related concepts

IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic Task topic    

Terms of Use | Feedback

Last updatedLast updated: Sep 19, 2011 7:16:32 PM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=matt&product=was-express-iseries&topic=tjwsn_ex_pp_get
File name: tjwsn_ex_pp_get.html