users@jax-rpc.java.net

JAX-WS 2.0: SOAP handlers don't work

From: Dmytro Rud <unixoid_at_web.de>
Date: Wed, 5 Oct 2005 19:41:36 +0200 (CEST)

Hi!

I wrote a web service with a server side SOAP handler using
JAXWS_SI_20050929 and deployed it on Apache Tomcat 5.5.9. There are no
error messages in Tomcat logs and client applications work too, but the
handler doesn't work, as if its methods were simply not called at all.

What do I make wrong?


Here are some excerpts from the sources, the complete tarball is
attached.

---------- service3/MeasuredWebService.java ----------
package service3;

import javax.jws.*;

@WebService( targetNamespace = "http://dmytropc.cs.uni-magdeburg.de/WS/service3" )
@HandlerChain( file = "handlers.xml",name = "Chain1" )
public class MeasuredWebService {

    @WebMethod public int method0( int n ) { return n + 10; }
    // more methods...
}

---------- etc/handlers.xml ----------
<?xml version="1.0" encoding="UTF-8"?>

<handler-config>
    <handler-chain>
        <handler-chain-name>Chain1</handler-chain-name>
    
        <handler>
            <handler-class>service3.handlers.SimpleHandler</handler-class>
        </handler>
        
    </handler-chain>
</handler-config>


---------- service3/handlers/SimpleHandler.java ----------
package service3.handlers;

import java.util.Map;
import java.util.Set;
import javax.xml.namespace.QName;

import javax.xml.ws.handler.*;
import javax.xml.ws.handler.soap.*;

public class SimpleHandler implements SOAPHandler<SOAPMessageContext> {
    
    private Map<String,Object> config;
    
    public void init( Map<String,Object> config ) {
        this.config = config;
    }

    public Set<QName> getHeaders() {
        return null;
    }
    
    public void destroy() {
    }
    
    public void close( MessageContext context ) {
    }
    
    public boolean handleFault( SOAPMessageContext context ) {
        return true;
    }

    public boolean handleMessage( SOAPMessageContext context ) {
        throw new RuntimeException();
        // or something else... doesn't matter...
    }
}
----------------------------------------------------------

-- 
        rnd.