I have some SOAP webservices build with JAX-RPC. These work fine. But as soon as I add a handler, I get an exception. When the binding is removed from the webservices.xml, everything works fine again.
The weird thing is, the handler itself isn't included in the stacktrace of the exception. I also noticed, the init
and getHeaders
methods of the handler are called, before the exception is raised.
The handler is added to webservices.xml with the following xml:
<handler>
<handler-name>My Message Handler</handler-name>
<handler-class>kpn.MyMessageHandler</handler-class>
</handler>
The handler itself is just a stub, generated by the IDE from the interface, so I won't include the whole implementation:
public class MyMessageHandler implements javax.xml.rpc.handler.Handler {
@Override
public boolean handleRequest(MessageContext context) {
System.out.println("handel-Request");
return true;
}
...
}
This actually generates three exceptions in my logging (with the exact same timestamp). Because of the length, I only include a portion.
Log Level WARNING
Logger javax.enterprise.system.container.web
Message ID preWebHandlerError java.lang.ClassCastException
Complete Message com.sun.xml.messaging.saaj.soap.impl.TextImpl cannot be cast to javax.xml.soap.SOAPElement at
com.sun.xml.rpc.server.StreamingHandler.getOpcodeForRequestMessage(StreamingHandler.java:657) at
com.sun.enterprise.webservice.WsUtil.getInvMethod(WsUtil.java:1277) at
com.sun.enterprise.webservice.ServletPreHandler.handleRequest(ServletPreHandler.java:86) at
com.sun.xml.rpc.client.HandlerChainImpl.handleRequest(HandlerChainImpl.java:103) at
com.sun.xml.rpc.server.StreamingHandler.callRequestHandlers(StreamingHandler.java:962) at
com.sun.xml.rpc.server.StreamingHandler.preHandlingHook(StreamingHandler.java:868) at
kpn.kpc.SOAPKPCReadCustomerClassification_v01PortType_Tie.preHandlingHook(SOAPKPCReadCustomerClassification_v01PortType_Tie.java:242) at
com.sun.xml.rpc.server.StreamingHandler.handle(StreamingHandler.java:127) at
com.sun.xml.rpc.server.http.JAXRPCServletDelegate.doPost(JAXRPCServletDelegate.java:467) at
com.sun.enterprise.webservice.JAXRPCServlet.doPost(JAXRPCServlet.java:119) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:738) at
...
Log Level SEVERE
Logger com.sun.xml.rpc.server
Message ID com.sun.xml.messaging.saaj.soap.impl.TextImpl cannot be cast to javax.xml.soap.SOAPBodyElement java.lang.ClassCastException
Complete Message com.sun.xml.messaging.saaj.soap.impl.TextImpl cannot be cast to javax.xml.soap.SOAPBodyElement at
com.sun.enterprise.webservice.WsUtil.throwSOAPFaultException(WsUtil.java:1312) at
com.sun.enterprise.webservice.WsUtil.throwSOAPFaultException(WsUtil.java:1288) at
com.sun.enterprise.webservice.ServletPreHandler.handleRequest(ServletPreHandler.java:99) at
...
Log Level SEVERE
Logger com.sun.xml.rpc.server
Message ID JAXRPCTIE01
Complete Message caught exception while handling request: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl cannot be cast to javax.xml.soap.SOAPBodyElement java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.impl.TextImpl cannot be cast to javax.xml.soap.SOAPBodyElement at
com.sun.enterprise.webservice.WsUtil.throwSOAPFaultException(WsUtil.java:1312) at
com.sun.enterprise.webservice.WsUtil.throwSOAPFaultException(WsUtil.java:1288) at
com.sun.enterprise.webservice.ServletPreHandler.handleRequest(ServletPreHandler.java:99) at
...
Anyone got some ideas to solve this?