Websphere Application Server v6.0.2.35上的JAX-RPC GenericHandler失败 [英] JAX-RPC GenericHandler fails on Websphere Application Server v6.0.2.35

查看:93
本文介绍了Websphere Application Server v6.0.2.35上的JAX-RPC GenericHandler失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've created an Extension of GenericHandler called SOAPHeaderHandler. I placed log4j statements in the handler and can see the constructor being built. When I generate a SOAP message, however, I don't see the message related to the handleRequest method. I've registered the Handler in the stub as follows:

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:

and I've changed the web.xml as follows:

   <service-ref>
        <description>WSDL Service AccountManagerService</description>
        <service-ref-name>service/AccountManagerService</service-ref-name>
        <service-interface>com.medibank.www.AccountManagerService</service-interface>
<!--        <wsdl-file>WEB-INF/wsdl/AccountManagerService.asmx.wsdl</wsdl-file>-->
        <jaxrpc-mapping-file>WEB-INF/AccountManagerService.asmx_mapping.xml</jaxrpc-mapping-file>
        <service-qname xmlns:pfx="http://www.medibank.com/MBIWebServices/Access/Services/AccountManager/2004/06/">pfx:AccountManagerService</service-qname>
        <port-component-ref>
            <service-endpoint-interface>com.medibank.www.AccountManagerServiceSoap</service-endpoint-interface>
        </port-component-ref>
        <port-component-ref>
            <service-endpoint-interface>com.medibank.www.AccountManagerServiceSoap</service-endpoint-interface>
        </port-component-ref>
        <handler>
         <description>
         </description>
         <display-name></display-name>
         <handler-name>AccountManagementSOAPHeaderHandler</handler-name>
         <handler-class>com.xxxxx.hdhp.business.debitcard.accountmanagement.AccountManagementSOAPHeaderHandler</handler-class>
        </handler>
    </service-ref>

这已部署在Websphere Application Server v6.0.2.35上.任何想法可能是什么问题?为什么处理程序中的logger语句从不执行?我是否无法正确注册处理程序?我需要指定要处理哪些服务方法吗?

This is deployed on Websphere Application Server v6.0.2.35. Any ideas what the problem may be? Why do the logger statements in the handler never get executed? Have I failed to register the handler correctly? Do I need to specify which service methods get handled?

推荐答案

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

I wrote a few JAX-RPC SOAP clients that run on WAS 6.0, and require GenericHandlers that add a custom SOAP header to request messages. I also had the requirement of not using a service-ref (for ease-of-use reasons in the client codebase), so my client class sets up the handler in a programmatic way. This may not exactly apply to how your configuration works, but maybe something will be of use.

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

I started with the client code generated by RAD 7.5's WSDL2Java tool in Ant, but the "Web Service Client" wizard uses it as well. It created all the business objects, serializer/deserializers, locator and SOAP binding classes, etc, etc. I then created a custom GenericHandler similar to the one you have.

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

Since I didn't have a service-ref available, I couldn't bind it to the client that way. So I used the following code in the client class itself, to programmatically add the handler:

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,然后以一种愉快的方式发送该消息.

The object returned by that method is completely set up, and calling any of the client methods on that class work correctly. The AccountManagerClientHandler.handleRequest(MessageContext msgContext) method is invoked, the messageContext updated, and then the message is sent on its merry way.

这篇关于Websphere Application Server v6.0.2.35上的JAX-RPC GenericHandler失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆