Client-side handler problem

From: Łabno, Bernard <>
Date: Sun, 14 Oct 2007 13:27:15 +0200

Hello, this problem is also described on my website :
I have included there sources of sample application.

I have run into a problem concerning jax.xml.rpc.handler.Handler. A
third-party Webservice I wanted to interact with did not define business
exceptions in their WSDL file, so when they were thrown i got strange
exception and could not determine the true reason of exception.
class java.rmi.RemoteException
Cause:class com.sun.xml.rpc.encoding.DeserializationException
java.rmi.RemoteException: Runtime exception; nested exception is:
deserialization error: XML reader error: unexpected character
content: "doSearch - Wrong session"
 I decided to use handlers to parse SOAP messages before they get to JAX-RPC.
If they would contain undefined business exception, than handler would throw
known exception with details from intercepted messsage.
 Unfortunately I recived strange exceptions when I tried to get HandlerChaing
from the service. Sometimes it was java.lang.UnsupportedOperationException
and sometimes IllegalAccessException.
 After building my project with various configurations I found out that the
problem disappeares when client does not use JavaEE container generated stub.
Below are sources of simple "Hello service" and two client web applications.
The only difference between those clients is that one uses ide-generated stub
and the other uses container-generated stub.
 Just to clarify I explain that ide-generated stub is made using "wscompile"
with "-gen:client" option. Container-generated stub is made using "wscompile"
with "-import" option.

Code differences
Following code is in Test servlet's processRequest method.

From client with container-generated stub :
JAX_RPCSampleService service = getJAX_RPCSampleService();
//this method is of course not in processRequest but next to it
private JAX_RPCSampleService getJAX_RPCSampleService() {
        JAX_RPCSampleService jAX_RPCSampleService = null;
        try {
            javax.naming.InitialContext ic = new
            jAX_RPCSampleService = (JAX_RPCSampleService)
        } catch(javax.naming.NamingException ex) {
            // TODO handle JNDI naming exception
        return jAX_RPCSampleService;
From client with ide-generated stub
JAX_RPCSampleService service = new JAX_RPCSampleService_Impl();
Common code
//here goes code from one of two previous codes
final QName serviceName = new QName("urn:JAX_RPCSampleService/wsdl",
final QName ns1_JAX_RPCSampleServiceSEIPort_QNAME =
new QName("urn:JAX_RPCSampleService/wsdl", "JAX_RPCSampleServiceSEIPort");
HandlerInfo hi = new HandlerInfo();
try {
    JAX_RPCSampleServiceSEI sei = service.getJAX_RPCSampleServiceSEIPort();
} catch (RemoteException ex) {
    throw new ServletException(ex);
} catch (WrongArgumentException ex) {
    out.println("Exception : "+ex.getMessage());
} catch (ServiceException ex) {
    throw new ServletException(ex);
 1. Is it possible to use container-generated stub and attach a client-side
handler to it ?
 2. If it is possible than what is wrong with presented client ?
Bernard Łabno