users@jax-rpc.java.net

Handler Problem

From: Abe Zafar <abezafar_at_yahoo.com>
Date: Mon, 19 May 2003 18:49:24 -0600

I like to use a Handler for authentication. I like to pass a username and password as part of the SOAP message. Unfortunately the callback methods in my handler never get called so I don't think the handler is properly registered. It would have been nice if I would get an exception as oppose to a silent failure which is tough to debug. Need your help. Thanks in advance.

Here is the code that registers the handler:

QName portName = new QName( "http://com.test/wsdl", "CreatePeople");
Service service = new CreatePeople_Impl();
ArrayList handlers = new ArrayList();
handlers.add(new HandlerInfo( DefaultHandler.class, null, null ) );
service.getHandlerRegistry().setHandlerChain( portName, handlers );


Here is the content of my config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
   <wsdl location="http://localhost:8080/mjplus-deployable/create-people?WSDL"
          packageName="com.rhi.mjplus.service"/>
</configuration>

Here is the content of jaxrpc-ri.xml:

<?xml version="1.0" encoding="UTF-8"?>
<webServices
    xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/dd"
    version="1.0"
    targetNamespaceBase="http://com.test/wsdl"
    typeNamespaceBase="http://com.test/types"
    urlPatternBase="/ws">

    <endpoint
        name="CreatePeople"
        displayName="CreatePeople Service"
        description="CreatePeople Webservice"
        interface="com.rhi.mjplus.service.CreatePeopleService"
        implementation="com.rhi.mjplus.service.CreatePeopleServiceImpl"/>

    <endpointMapping
        endpointName="CreatePeople"
        urlPattern="/create-people"/>
</webServices>


Here is the Handler class:

package com.rhi.mjplus.ui.handler;

import java.util.Hashtable;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.handler.HandlerInfo;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.rpc.handler.Handler;

public class DefaultHandler implements Handler {

    public DefaultHandler() {
    }

    public void init(HandlerInfo config) {
        System.out.println(" In StockServerHandler.init ()");
    }

    public boolean handleFault(MessageContext context) {
        System.out.println(" In StockServerHandler.handleFault (), context=" + context);
        return true;
    }

    public boolean handleRequest (MessageContext context) {
        System.out.println(" In StockServerHandler.handleRequest ()");
        return true;
    }

    public boolean handleResponse (MessageContext context) {
        System.out.println(" In StockServerHandler.handleResponse ()");
        return true;
    }

    public javax.xml.namespace.QName[] getHeaders() {
        System.out.println(" In StockServerHandler.getHeaders ()");
        return null;
    }

    public void destroy() {
        System.out.println(" In StockServerHandler.destroy ()");
    }

}