示例:暂停 WS-Notification 预订

使用此任务为充当订户角色的 JAX-RPC 客户机编写代码(根据提供的示例代码摘录),暂停用户应用程序的预订。

关于此任务

本示例的依据是,将 Java™ API for XML-based remote procedure calls (JAX-RPC) API 与使用 WSDL2Java 工具生成的代码(此代码针对创建 WS-Notification 服务点时生成的通知代理 WSDL 运行)以及 WebSphere® Application Server API 和 SPI 配合使用。

WebSphere Application Server 中,WS-Notification 服务有两个实现:V6.1 和 V7.0。此 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 客户机应用程序编程,请参阅下列主题:

过程

  1. 查找 JAX-RPC 服务。 JNDI 名称特定于您的 Web Service 客户机信息。PauseSubscription 操作属于 SubscriptionManager 服务。
  2. 获取要对其调用操作的端口的存根。
  3. 使请求与您要暂停的预订相关联。 subscriptionEPR 是通过调用预订操作返回的 EndpointReference。
  4. 创建任何可选信息。
  5. 通过对存根调用关联方法来调用 PauseSubscription 操作。

示例

以下示例代码描述充当订户角色的 JAX-RPC 客户机,暂停用户应用程序的预订:

// Look up the JAX-RPC service. The JNDI name is specific to your web services client implementation.
// The PauseSubscription operation belongs to the SubscriptionManager service
InitialContext context = new InitialContext();
javax.xml.rpc.Service service = (javax.xml.rpc.Service) context.lookup("java:comp/env/services/SubscriptionManager");

// Get a stub for the port on which you want to invoke operations
SubscriptionManager stub = (SubscriptionManager) service.getPort(SubscriptionManager.class);

// Associate the request with the subscription you want to pause. The subscriptionEPR is the
// EndpointReference returned by the invocation of the Subscribe operation
((Stub) stub)._setProperty(WSAConstants.WSADDRESSING_DESTINATION_EPR, subscriptionEPR);

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

// Invoke the PauseSubscription operation by calling the associated method on the stub
SOAPElement[] additionalReturnedInformation = stub.pauseSubscription(optionalInformation);

指示主题类型的图标 任务主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tjwsn_ex_sub_pause
文件名:tjwsn_ex_sub_pause.html