Announcement Announcement Module
Collapse
No announcement yet.
SPRING-WS BUG: Spring-WS Passes on Un-Marshalling Exception that can't be Resolved Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SPRING-WS BUG: Spring-WS Passes on Un-Marshalling Exception that can't be Resolved

    If a request is sent to a SOAP service with poorly formed XML a stacktrace is sent to the client and an exception resolver is never hit.

    Code:
    org.xml.sax.SAXParseException: The element type "soapenv:ody" must be terminated by the matching end-tag "</soapenv:ody>".
            at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1231)
            at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
            at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterImpl.java:333)
            at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:432)
            at com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer.transform(EfficientStreamingTransformer.java:393)
            at com.sun.xml.internal.messaging.saaj.soap.EnvelopeFactory.createEnvelope(EnvelopeFactory.java:102)
            at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1Impl.java:70)
            at com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl.getEnvelope(SOAPPartImpl.java:122)
            at org.springframework.ws.soap.saaj.support.SaajUtils.getSaajVersion(SaajUtils.java:159)
            at org.springframework.ws.soap.saaj.SaajSoapMessage.getImplementation(SaajSoapMessage.java:251)
            at org.springframework.ws.soap.saaj.SaajSoapMessage.<init>(SaajSoapMessage.java:84)
            at org.springframework.ws.soap.saaj.SaajSoapMessage.<init>(SaajSoapMessage.java:70)
            at org.springframework.ws.soap.saaj.SaajSoapMessageFactory.createWebServiceMessage(SaajSoapMessageFactory.java:168)
            at org.springframework.ws.transport.AbstractWebServiceConnection.receive(AbstractWebServiceConnection.java:90)
            at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:86)
            at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:57)
            at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:230)
            at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
            at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
            at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
            at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
            at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
            at java.lang.Thread.run(Thread.java:619)
    Not only is there no documentation on handling exceptions when recieving SOAP messages like this, but the exception resolvers that can be configured are never invoked. Making this worse, when you try and create a generic error using the WEB.XML, the response is already being written and therefore it's impossible to stop the client from getting a large stacktrace with "springframework" littered throughout the whole thing.

    This needs a fix ASAP, or at least a workaround, otherwise Spring-WS is unusable to any commercial firm that wants to have a professional SOAP web service.

    Please tell me I'm wrong and that there is some mistake in my (extremely basic and simple) code. I am using annotation endpoint resolvers, and castor as a marshaller, but this marshalling isn't being done by castor, it's before the soap message is fully received and passed on to the configured "marshaller".

    Please help.

    Thanks in advance.

  • #2
    same with jaxb

    I have the same issue with spring-ws 1.5.9 using jaxb for oxm. My ws method is supposed to be one way I want to handle exceptions by just replying a 500 http status header. Instead the ws client has the whole stack trace.

    Is a fix already in sight? is there a bug report for it?


    Cheers

    Comment


    • #3
      SWS-671 created for this issue

      Comment


      • #4
        I had to extend the servlet to get around this issue, wasted good part of my day on this.

        public class ErrorHandlingMessageDispatcherServlet extends MessageDispatcherServlet {
        protected void doService(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
        throws Exception {
        try {
        super.doService(httpServletRequest, httpServletResponse);
        } catch (Throwable e) {
        logger.error("problem processing request", e);
        SaajSoapMessage soapMessage = new SaajSoapMessage(MessageFactory.newInstance().creat eMessage());
        SoapHeader header = soapMessage.getSoapHeader();

        StringSource headerSource = new StringSource("\n" +
        "<imsx_syncResponseHeaderInfo>\n" +
        "<imsx_version></imsx_version>\n" +
        "<imsx_messageIdentifier></imsx_messageIdentifier>\n" +
        "<imsx_statusInfo>\n" +
        "<imsx_codeMajor>Failure</imsx_codeMajor>\n" +
        "<imsx_severity>Status</imsx_severity>\n" +
        "<imsx_messageRefIdentifier></imsx_messageRefIdentifier>\n" +
        "<imsx_operationRefIdentifier></imsx_operationRefIdentifier>\n" +
        "<imsx_description>" + e.getMessage() + "</imsx_description>\n" +
        "<imsx_codeMinor>\n" +
        "<imsx_codeMinorField>\n" +
        "<imsx_codeMinorFieldName>TargetEndSystem</imsx_codeMinorFieldName>\n" +
        "<imsx_codeMinorFieldValue>linkfailure</imsx_codeMinorFieldValue>\n" +
        "</imsx_codeMinorField>\n" +
        "</imsx_codeMinor>\n" +
        "</imsx_statusInfo>\n" +
        "</imsx_syncResponseHeaderInfo>");

        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.transform(headerSource, header.getResult());
        soapMessage.writeTo(httpServletResponse.getOutputS tream());
        }
        }
        }

        Comment

        Working...
        X