0 Replies Latest reply on Sep 29, 2014 6:45 PM by Ethan Stein

    ClassCastException for Message1_1Impl Thrown on JBOSS 7.1.1

    Ethan Stein Newbie

      All,

       

      I posted this question here as well, but there hasn't been much movement.  I'm hoping that someone here might know the answer.

       

      http://stackoverflow.com/questions/26107485/classcastexception-for-message1-1impl-thrown-on-jboss-7-1-1

       

      use a client call to a web service using the basic SOAPMessage dispatch, and it worked perfectly in WebSphere 7 and JBOSS 6.1 and before.  However, now with JBOSS 7.1.1, when I try to use the call, it creates a SAAJ soap message which it can't then transform into an XML Transform source, hence the error below.  I've tried disabling the web service part of JBOSS 7.1.1, but that didn't do anything.  Is there any way to get it to not use CXF?  Or is there something I'm doing wrong?  I need to generate a SOAPMessage so I can catch the fault and handle it accordingly.  Processing it as a DOMSource would require a whole lot of other steps instead.

      Please help!

       

      import javax.xml.namespace.QName;

      import javax.xml.parsers.ParserConfigurationException;

      import javax.xml.soap.*;

      import javax.xml.ws.Dispatch;

      import javax.xml.ws.Service;

      import javax.xml.ws.soap.SOAPFaultException;

       

      ...

       

      String namespace = JBOSSUtility.getQuickDocNamespace();

      QName serviceQName =

              new QName(namespace, JBOSSUtility.getQuickDocServiceName());

      QName portQName = new QName(namespace, JBOSSUtility.getQuickDocPortName());

      URL wsdlLocation = new URL(JBOSSUtility.getQuickDocEndpoint());

       

      Service service = Service.create(wsdlLocation, serviceQName);

      service.setHandlerResolver(new SOAPHandler());

      Dispatch<SOAPMessage> dispatch =

              service.createDispatch(portQName, SOAPMessage.class,

              Service.Mode.MESSAGE);

      MessageFactory factory = MessageFactory.newInstance();

       

      SOAPMessage request = factory.createMessage();

      SOAPEnvelope envelope = request.getSOAPPart().getEnvelope();

      SOAPElement body = request.getSOAPBody().

              addBodyElement(envelope.createName("categoriesForUser", VogueConstants.XPRESSION_WS_NMSP,

              namespace));

      body.addChildElement(envelope.createName(VogueConstants.REQUEST_CONTEXT, VogueConstants.XPRESSION_WS_NMSP, namespace)).addTextNode(rqContextDecoded);

      request.saveChanges();

       

      SOAPMessage response = dispatch.invoke(request);

       

      And when the dispatch is invoked, the server reports:

       

      Caused by: java.lang.ClassCastException:  com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl cannot be cast  to javax.xml.transform.Source     at  org.apache.cxf.databinding.source.XMLStreamDataWriter.write(XMLStreamDataWriter.java:83)  ~[na:na]  at  org.apache.cxf.databinding.source.XMLStreamDataWriter.write(XMLStreamDataWriter.java:50)  ~[na:na]  at  org.apache.cxf.databinding.source.XMLStreamDataWriter.write(XMLStreamDataWriter.java:46)  ~[na:na]  at  org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:119)  ~[na:na]  at  org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)  ~[na:na]  at  org.apache.cxf.binding.xml.interceptor.XMLMessageOutInterceptor.handleMessage(XMLMessageOutInterceptor.java:74)  ~[na:na]  at  org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)  ~[na:na]  at  org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531)  ~[na:na]  at  org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:461)  ~[na:na]  at  org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:364)  ~[na:na]  at  org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:317)  ~[na:na]  at  org.apache.cxf.endpoint.ClientImpl.invokeWrapped(ClientImpl.java:352)  ~[na:na]  at  org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:381)  ~[na:na]