6 Replies Latest reply on Oct 3, 2011 5:16 AM by Javier Alperte

    Getting ClassCast Exception in case of malformed webservice

    Gandulf Kohlweiss Newbie

      Hi, i'm using jbowss ws native with validation turned on to ensure the requests and responses are valid. In case of a xml-valid document the validation is working fine and I'm getting validation errors from the validator. But if i'm sending back a totally corrupt xml message, missing closing tags, etc. then i'm getting the following exception which is not very intuitive:

      Caused by: javax.xml.ws.WebServiceException: java.lang.ClassCastException: org.jboss.ws.core.soap.TextImpl cannot be cast to org.jboss.ws.core.soap.SOAPElementI
      mpl
       at org.jboss.ws.core.jaxws.client.ClientImpl.handleRemoteException(ClientImpl.java:404)
       at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:314)
       at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:172)
       at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:152)
       at $Proxy311.bookOrders(Unknown Source)
       at com.skidata.dta.server.co.v3_0.classic.impl.BookOrdersHelper.invoke(BookOrdersHelper.java:46)
       ... 12 more
      Caused by: java.lang.ClassCastException: org.jboss.ws.core.soap.TextImpl cannot be cast to org.jboss.ws.core.soap.SOAPElementImpl
       at org.jboss.ws.core.CommonSOAPBinding.getParameterFromMessage(CommonSOAPBinding.java:894)
       at org.jboss.ws.core.CommonSOAPBinding.unbindResponseMessage(CommonSOAPBinding.java:634)
       at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:380)
       at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:302)
       ... 16 more
      


      I digged into the code a little bit and found out that the actual XML parser exception which i'd like to get is ignored because the SOAPMessageUnMarshallerHTTP is creating a MessageFactory with ignoreParseErrors = true. (line 82 in 3.1.1 source)
       MimeHeaders mimeHeaders = getMimeHeaders(metadata);
       soapMsg = getMessageFactory().createMessage(mimeHeaders, inputStream, true);
      

      Which catches the Parse Excpetion and simply returns null in case of a parse error.

      Is there another way than changing the source code to change this behaviour, because i'd like to use the original distribution and not apatched one which will be a mess to update later...

      thanks gandulf