当前位置:  开发笔记 > Android > 正文

JAX-RPC GenericHandler在Websphere Application Server v6.0.2.35上失败

如何解决《JAX-RPCGenericHandler在WebsphereApplicationServerv6.0.2.35上失败》经验,为你挑选了1个好方法。

我创建了一个名为SOAPHeaderHandler的GenericHandler扩展.我将log4j语句放在处理程序中,可以看到正在构建的构造函数.但是,当我生成SOAP消息时,我没有看到与handleRequest方法相关的消息.我在存根中注册了Handler,如下所示:

if (service == null) {
    super.service = new com.ibm.ws.webservices.engine.client.Service();
}
else {
    super.service = service;
}
List handlerInfoList = new ArrayList();
QName[] headersArr = null;
HandlerInfo handlerInfo = new HandlerInfo(com.xxxxxx.hdhp.business.debitcard.cardservices.CardServiceSOAPHeaderHandler.class, 
     null, headersArr);
handlerInfoList.add(handlerInfo);
service.getHandlerRegistry().setHandlerChain(new QName("MetavanteDebitCard"), handlerInfoList);

处理程序是:

public class AccountManagementSOAPHeaderHandler extends GenericHandler {
 private static Logger logger = Logger.getLogger  (AccountManagementSOAPHeaderHandler.class);
 private HandlerInfo handlerInfo = null;

public AccountManagementSOAPHeaderHandler () {
 logger.info("Constructing AccountManagementSOAPHeaderHandler");
}

 /* (non-Javadoc)
  * @see javax.xml.rpc.handler.GenericHandler#getHeaders()
  */
 public QName[] getHeaders() {
 logger.info("calling getHeaders()");
  return null;
 }

 public boolean handleFault(MessageContext arg0) {
     logger.info("Fault in AccountManagementSOAPHeaderHandler");
  return true;
 }
 public boolean handleResponse(MessageContext arg0) {
   logger.info("Response in AccountManagementSOAPHeaderHandler");
   return true;
 }
 public void init(HandlerInfo arg0) {
  logger.info("init in AccountManagementSOAPHeaderHandler");
  handlerInfo = arg0;
  super.init(arg0);
 }

 public void destroy() {
  logger.info("--- In AccountManagementSOAPHeaderHandler.destroy ()");
 } 

 public boolean handleRequest(MessageContext ctx) {
     logger.debug("BEGIN handleRequest()");
     if (ctx instanceof SOAPMessageContext) {
        SOAPMessageContext context = (SOAPMessageContext) ctx;
        logger.debug("instance of SOAPMessageContext");
        try {
           SOAPHeader header = context.getMessage().getSOAPPart()
                .getEnvelope().getHeader();
           logger.debug("SOAP Header is " + ((header==null)?"NULL":"NOT NULL"));
           Iterator headers = header
                .extractHeaderElements("http://schemas.xmlsoap.org/soap/actor/next");
           while (headers.hasNext()) {
               SOAPHeaderElement he = (SOAPHeaderElement) headers.next();
               logger.info("HEADER Qn " + he.getElementName().getQualifiedName());
           }
       } catch (SOAPException x) {
           logger.error("SOAPException while handlingRequest for SOAP: '" + x.getMessage() + "'");
   }
  }
 return true;
}

我已经更改了web.xml,如下所示:

   
        WSDL Service AccountManagerService
        service/AccountManagerService
        com.medibank.www.AccountManagerService

        WEB-INF/AccountManagerService.asmx_mapping.xml
        pfx:AccountManagerService
        
            com.medibank.www.AccountManagerServiceSoap
        
        
            com.medibank.www.AccountManagerServiceSoap
        
        
         
         
         
         AccountManagementSOAPHeaderHandler
         com.xxxxx.hdhp.business.debitcard.accountmanagement.AccountManagementSOAPHeaderHandler
        
    

这部署在Websphere Application Server v6.0.2.35上.任何想法可能是什么问题?为什么处理程序中的记录器语句永远不会被执行?我没有正确注册处理程序吗?我是否需要指定处理哪些服务方法?



1> Kaleb Brasee..:

我编写了一些在WAS 6.0上运行的JAX-RPC SOAP客户端,并要求GenericHandlers添加自定义SOAP头来请求消息.我还要求不使用service-ref(为了易于使用的原因在客户端代码库中),所以我的客户端类以编程方式设置处理程序.这可能不完全适用于您的配置如何工作,但可能会有一些用处.

我从Ant 7.5中的RAD 7.5的WSDL2Java工具生成的客户端代码开始,但"Web服务客户端"向导也使用它.它创建了所有业务对象,序列化器/反序列化器,定位器和SOAP绑定类等等.然后我创建了一个类似于你的自定义GenericHandler.

由于我没有可用的service-ref,因此无法将其绑定到客户端.所以我在客户端类本身使用了以下代码,以编程方式添加处理程序:

private AccountManager createAccountManagerStub() throws Exception {
    AccountManagerServiceLocator locator = new AccountManagerServiceLocator();

    // Set the JMS endpoint address
    AccountManagerSOAPBindingStub accountManagerStub = (AccountManagerSOAPBindingStub) locator
            .getAccountManagerSOAPPort(new URL(generateJMSEndpointAddress()));

    // Set the Client Handler
    HandlerRegistry registry = locator.getHandlerRegistry();
    List chain = registry
            .getHandlerChain((QName) locator.getPorts().next());
    HandlerInfo handlerInfo = new HandlerInfo();
    handlerInfo.setHandlerClass(AccountManagerClientHandler.class);
    chain.add(handlerInfo);

    return (AccountManager) accountManagerStub;
}

该方法返回的对象已完全设置,并且调用该类上的任何客户端方法都能正常工作.调用AccountManagerClientHandler.handleRequest(MessageContext msgContext)方法,更新messageContext,然后以快乐的方式发送消息.

推荐阅读
手机用户2402852387
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有