我有一些使用 JAX-RPC 构建的 SOAP Web 服务。这些工作正常。但是一旦我添加了一个处理程序,我就会得到一个异常。从 webservices.xml 中删除绑定后,一切都会再次正常运行。
奇怪的是,处理程序本身不包含在异常的堆栈跟踪中。我还注意到,在引发异常之前调用了处理程序的init
和方法。getHeaders
使用以下 xml 将处理程序添加到 webservices.xml:
<handler>
<handler-name>My Message Handler</handler-name>
<handler-class>kpn.MyMessageHandler</handler-class>
</handler>
处理程序本身只是一个存根,由 IDE 从接口生成,所以我不会包括整个实现:
public class MyMessageHandler implements javax.xml.rpc.handler.Handler {
@Override
public boolean handleRequest(MessageContext context) {
System.out.println("handel-Request");
return true;
}
...
}
这实际上在我的日志记录中生成了三个异常(具有完全相同的时间戳)。由于篇幅关系,我只包括一部分。
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
...
有人有解决这个问题的想法吗?