开发使用 WS-Notification 的应用程序
可编写单个应用程序以执行多个 WS-Notification 任务。下列主题提供 WS-Notification 应用程序可以执行的常见任务的样本代码。
开始之前
其中大部分示例使用 Java™ API for XML-based remote procedure call (JAX-RPC) API 和
WebSphere® Application Server API 及 SPI。这些 JAX-RPC 示例可与 V6.1 或 V7.0 WS-Notification 服务点成功交互。 但是,如果要将 WS-Notification 与策略集配合使用(例如,启用与 WS-ReliableMessaging 的组合),那么 WS-Notification 应用程序必须编码为使用 Java API for XML-based Web Services (JAX-WS) 编程模型,并且必须与 V7.0 WS-Notification 服务点交互。 如果您不熟悉 JAX-WS 客户机应用程序编程,请参阅下列主题:
如果已有 V6.1 WS-Notification 配置,并且要将 WS-Notification 与策略集配合使用,请完成下列任务:
应用程序还可以使用 WS-Notification 来接收由服务集成总线的其他客户机(例如 JMS 客户机)生成的事件通知。作为服务集成总线的入口点或出口点的 WS-Notification 的拓扑和为 WS-Notification 应用程序提供对现有总线主题空间的访问权对此功能作了描述。有关为混合客户机解决方案(包括来自 JMS 客户机的交叉流动)开发应用程序的信息,请参阅与 JMS 消息类型进行交互。
关于此任务
可以将一个应用程序编码为执行多个 WS-Notification 任务。使用示例来帮助您将这些任务编码到 WS-Notification 应用程序中。
要获取有关应用程序如何使用通知代理的概述,请参阅 WS-Notification:客户机应用程序在运行时的交互方式。
WS-Notification 应用程序大体上分为两类:公开 Web Service 端点的 WS-Notification 应用程序(例如,接收证券价值更改通知的 WS-Notification 使用者应用程序)和不公开 Web Service 端点的 WS-Notification 应用程序(例如,生成证券价值更改通知的应用程序)。要获取开发这两类应用程序时所需执行的步骤的概括性指导,请参阅下列主题:
消费应用程序可使用 XML 路径 (XPath) 选择器来根据每个消息的内容过滤消息,而不是接收有关您已预订的主题的所有消息。,如过滤发布的消息内容所述。
本主题中列示的代码示例使用以下 WebSphere Application Server API 和 SPI:
com.ibm.websphere.sib.wsn.AbsoluteOrRelativeTime;
com.ibm.websphere.sib.wsn.CreatePullPoint;
com.ibm.websphere.sib.wsn.CreatePullPointResponse;
com.ibm.websphere.sib.wsn.Filter;
com.ibm.websphere.sib.wsn.GetMessages;
com.ibm.websphere.sib.wsn.GetMessagesResponse;
com.ibm.websphere.sib.wsn.NotificationMessage;
com.ibm.websphere.sib.wsn.TopicExpression;
com.ibm.websphere.webservices.soap.IBMSOAPFactory;
com.ibm.websphere.wsaddressing.EndpointReference;
com.ibm.websphere.wsaddressing.WSAConstants;
com.ibm.wsspi.wsaddressing.EndpointReferenceManager;