Wednesday, April 16, 2008

SoapUI and WebLogic Web Services

I am assisting one of our clients who is using WebLogic Web Services to test these web services using SoapUI. I have used SoapUI for almost 4 years and had never found this bug. So, here is what's happening:

The weblogic.webservice.GenericHandler is extended to do some security checks. Within this special Class, the handleRequest method is overridden as such:


public boolean handleRequest(MessageContext mc) {
SOAPMessageContext messageContext = (SOAPMessageContext) mc;
SOAPBody soapBody = messageContext.getMessage().getSOAPPart()
.getEnvelope().getBody();
Iterator itBody = soapBody.getChildElements();
while (itBody.hasNext()) {
Object obj = itBody.next();
SOAPElement bodyElement = (SOAPElement) obj;
String name = bodyElement.getElementName().getLocalName();
}
}


The following line:
SOAPElement bodyElement = (SOAPElement) obj;

throws a ClassCastException, the stack trace is shown below:
java.lang.ClassCastException: weblogic.webservice.core.soap.SOAPTextElement
at weblogic.webservice.core.HandlerChainImpl.handleRequest(HandlerChainImpl.java:143)
at weblogic.webservice.core.DefaultOperation.process(DefaultOperation.java:549)
at weblogic.webservice.server.Dispatcher.process(Dispatcher.java:204)
at weblogic.webservice.server.Dispatcher.doDispatch(Dispatcher.java:176)
at weblogic.webservice.server.Dispatcher.dispatch(Dispatcher.java:96)
at weblogic.webservice.server.WebServiceManager.dispatch(WebServiceManager.java:100)
at weblogic.webservice.server.servlet.WebServiceServlet.serverSideInvoke(WebServiceServlet.java:297)
at weblogic.webservice.server.servlet.ServletBase.doPost(ServletBase.java:498)
at weblogic.webservice.server.servlet.WebServiceServlet.doPost(WebServiceServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7047)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)

I did read in just one post that any default spaces in the request is converted
to a SoapTextElement.

If I add a simple guardian to check for
weblogic.webservice.core.soap.SOAPTextElement
and skip the loop it works, but I know that's isn't the right solution.

If I create a simple Web Services Client using Axis(WSDL2Java),
I don't see the same exception.

Have you seen this, how did you fix this? Any ideas?
Here is the thread which I saw on bea web site.

1. bea site
And this one which I guess is related to Spring:

2. Spring site