WebSphere WebSphere Application Server Version 6.1.x Feature Pack for Web Services Operating Systems: AIX, HP-UX, i5/OS, Linux, Solaris, Windows, z/OS

Example: Registering a WS-Notification publisher

Example code that describes a client acting in the publisher registration role, registering a publisher (producer) application with a broker.

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);
        
// Create a reference for the publisher (producer) being registered. This contains the address of the
// producer Web service.
EndpointReference publisherEPR = 
    EndpointReferenceManager.createEndpointReference(new URI("http://myserver.mysom.com:9080/Producer"));

// Create a list (array) of topic expressions to describe the topics to which the producer publishes 
// messages. For this example you simply add one topic
Map prefixMappings = new HashMap();
prefixMappings.put("abc", "uri:mytopicns");
TopicExpression topic = 
    new TopicExpression(TopicExpression.SIMPLE_TOPIC_EXPRESSION, "abc:xyz", prefixMappings);                
TopicExpression[] topics = new TopicExpression[] {topic};

// Indicate that you do not want the publisher to use demand based publishing
Boolean demand = Boolean.FALSE;
        
// Set a value for the initial termination time of the registration. For this example we use 1 year in 
// the future
Calendar initialTerminationTime = Calendar.getInstance();
initialTerminationTime.add(Calendar.YEAR, 1);
        
// Create holders to hold the multiple values returned from the broker:
// PublisherRegistrationReference: An endpoint reference for use in lifetime management of 
// the registration
EndpointReferenceTypeHolder pubRegMgrEPR = new EndpointReferenceTypeHolder();
        
// ConsumerReference: An endpoint reference for use in subsequent publishing of messages
EndpointReferenceTypeHolder consEPR = new EndpointReferenceTypeHolder();
        
// Invoke the RegisterPublisher operation by calling the associated method on the stub
stub.registerPublisher(publisherEPR, topics, demand, initialTerminationTime, null, pubRegMgrEPR, consEPR);
        
// Retrieve the PublisherRegistrationReference
EndpointReference registrationEPR = pubRegMgrEPR.value;
        
// Retrieve the ConsumerReference
EndpointReference consumerReferenceEPR = consEPR.value;
Related concepts
JAX-RPC
Brokered notification
Related tasks
Writing a WS-Notification application that exposes a Web service endpoint
Writing a WS-Notification application that does not expose a Web service endpoint
WS-Notification - publish and subscribe messaging for Web services
Learning about WS-Notification
Securing WS-Notification
Related reference
Example: Subscribing a WS-Notification consumer
Example: Pausing a WS-Notification subscription
Example: Publishing a WS-Notification message
Example: Creating a WS-Notification pull point
Example: Getting messages from a WS-Notification pull point
Example: Notification consumer Web service skeleton
Sharing event notification messages with other bus client applications
WS-BrokeredNotification Version 1.3 OASIS Standard
WSDL2Java command
WS-Notification troubleshooting tips

Reference topic

Terms of use | Feedback


Timestamp icon Last updated: 27 November 2008
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.pmc.wsfep.multiplatform.doc/ref/rjwsn_ex_pub_reg.html

Copyright IBM Corporation 2004, 2008. All Rights Reserved.
This information center is powered by Eclipse technology. (http://www.eclipse.org)