Example code that describes a client acting in the pull style consumer role, requesting messages from a pull point.
This example is based on using the Java™ API for XML-based remote procedure call (JAX-RPC) APIs in conjunction 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.
// 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();