Example: Creating a WS-Notification pull point
Use this task to write the code for a JAX-RPC subscriber client. This client creates a pull point for use by consumer applications that use pull style notifications.
About this task
這個範例的基礎如下:搭配 WSDL2Java 工具產生的程式碼(針對建立 WS-Notification 服務點所產生的「通知分配管理系統 WSDL」來執行這個工具)及 WebSphere® Application Server API 和 SPI,來使用 Java™ API for XML 型遠端程序呼叫 (JAX-RPC) API。
To write the code for a JAX-RPC client acting in the subscriber role, creating a pull point for use by a consumer application that is to use pull style notifications, complete the following steps, referring to the example code extract for further information.
Procedure
- Look up the JAX-RPC service. The JNDI name is specific to your web services client implementation.
- Get a stub for the port on which you want to invoke operations.
- Create the request information.
- Invoke the CreatePullPoint operation by calling the associated method on the stub.
- Retrieve the reference to the pull point from the response.
- Retrieve any additional information from the response.
Example
The following example code describes a JAX-RPC client acting in the subscriber role, creating a pull point for use by a consumer application that is to use pull style notifications:
// 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 the request information.
SOAPElement[] optionalInformation = null;
CreatePullPoint cpp = new CreatePullPoint(optionalInformation);
// Invoke the CreatePullPoint operation by calling the associated method on the stub
CreatePullPointResponse response = stub.createPullPoint(cpp);
// Retrieve the reference to the pull point from the response
EndpointReference pullPointEPR = response.getPullPoint();
// Retrieve any additional information from the response
SOAPElement[] additionalInformation = response.getElements();