Announcement Announcement Module
Collapse
No announcement yet.
Exception handling: how to catch invalid client XML exceptions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception handling: how to catch invalid client XML exceptions

    Hi,

    I have a question about Exception handling in Spring WS. Currently, we receive a lengthy SAAJ/SAX stack trace when clients post invalid XML to one of our endpoints. How can we catch this exception to return a normal soap fault?

    We have an EndpointExceptionResolver registered that works for all exceptions other than these. (Its internals are very similar to the SimpleSoapExceptionResolver, but with some custom business logic.)

    We are using Spring WS 2.0 RC2.

    Thank much in advance

    Ted
    Last edited by tedpennings; Jan 5th, 2011, 03:32 PM.

  • #2
    An example stack trace from this issue is

    org.springframework.ws.soap.saaj.SaajSoapEnvelopeE xception: Could not access envelope: Unable to create envelope from given source: ; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionI mpl: Unable to create envelope from given source:
    at org.springframework.ws.soap.saaj.SaajSoapMessage.g etSaajVersion(SaajSoapMessage.java:260)
    at org.springframework.ws.soap.saaj.SaajSoapMessage.g etImplementation(SaajSoapMessage.java:342)
    at org.springframework.ws.soap.saaj.SaajSoapMessage.& lt;init>(SaajSoapMessage.java:117)
    at org.springframework.ws.soap.saaj.SaajSoapMessageFa ctory.createWebServiceMessage(SaajSoapMessageFacto ry.java:184)
    at org.springframework.ws.soap.saaj.SaajSoapMessageFa ctory.createWebServiceMessage(SaajSoapMessageFacto ry.java:58)
    at org.springframework.ws.transport.AbstractWebServic eConnection.receive(AbstractWebServiceConnection.j ava:90)
    at org.springframework.ws.transport.support.WebServic eMessageReceiverObjectSupport.handleConnection(Web ServiceMessageReceiverObjectSupport.java:86)
    at org.springframework.ws.transport.http.WebServiceMe ssageReceiverHandlerAdapter.handle(WebServiceMessa geReceiverHandlerAdapter.java:57)
    at org.springframework.ws.transport.http.MessageDispa tcherServlet.doService(MessageDispatcherServlet.ja va:222)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:644)
    at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:560)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:820)
    at org.mortbay.jetty.servlet.ServletHolder.handle(Ser vletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler.handle(Se rvletHandler.java:390)
    at org.mortbay.jetty.security.SecurityHandler.handle( SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(Se ssionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(Co ntextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebA ppContext.java:418)
    at org.mortbay.jetty.servlet.Dispatcher.forward(Dispa tcher.java:327)
    at org.mortbay.jetty.servlet.Dispatcher.forward(Dispa tcher.java:126)
    at org.tuckey.web.filters.urlrewrite.NormalRewrittenU rl.doRewrite(NormalRewrittenUrl.java:195)
    at org.tuckey.web.filters.urlrewrite.RuleChain.handle Rewrite(RuleChain.java:159)
    at org.tuckey.web.filters.urlrewrite.RuleChain.doRule s(RuleChain.java:141)
    at org.tuckey.web.filters.urlrewrite.UrlRewriter.proc essRequest(UrlRewriter.java:90)
    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter .doFilter(UrlRewriteFilter.java:417)
    at org.mortbay.jetty.servlet.ServletHandler$CachedCha in.doFilter(ServletHandler.java:1157)
    [...trimmed...]
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run (QueuedThreadPool.java:582)
    Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionI mpl: Unable to create envelope from given source:
    at com.sun.xml.internal.messaging.saaj.soap.EnvelopeF actory.createEnvelope(EnvelopeFactory.java:114)
    at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SO APPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1 Impl.java:70)
    at com.sun.xml.internal.messaging.saaj.soap.SOAPPartI mpl.getEnvelope(SOAPPartImpl.java:122)
    at org.springframework.ws.soap.saaj.support.SaajUtils .getSaajVersion(SaajUtils.java:155)
    at org.springframework.ws.soap.saaj.SaajSoapMessage.g etSaajVersion(SaajSoapMessage.java:257)
    ... 42 more
    Caused by: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Content is not allowed in prolog.
    at org.apache.xalan.transformer.TransformerIdentityIm pl.transform(TransformerIdentityImpl.java:502)
    at com.sun.xml.internal.messaging.saaj.util.transform .EfficientStreamingTransformer.transform(Efficient StreamingTransformer.java:393)
    at com.sun.xml.internal.messaging.saaj.soap.EnvelopeF actory.createEnvelope(EnvelopeFactory.java:102)
    ... 46 more
    Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
    at com.sun.org.apache.xerces.internal.parsers.Abstrac tSAXParser.parse(AbstractSAXParser.java:1231)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserI mpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterI mpl.java:333)
    at org.apache.xalan.transformer.TransformerIdentityIm pl.transform(TransformerIdentityImpl.java:485)
    ... 48 more</pre>
    <h3>Caused by:</h3>
    <pre>com.sun.xml.internal.messaging.saaj.SOAPExcep tionImpl: Unable to create envelope from given source:
    at com.sun.xml.internal.messaging.saaj.soap.EnvelopeF actory.createEnvelope(EnvelopeFactory.java:114)
    at com.sun.xml.internal.messaging.saaj.soap.ver1_1.SO APPart1_1Impl.createEnvelopeFromSource(SOAPPart1_1 Impl.java:70)
    at com.sun.xml.internal.messaging.saaj.soap.SOAPPartI mpl.getEnvelope(SOAPPartImpl.java:122)
    at org.springframework.ws.soap.saaj.support.SaajUtils .getSaajVersion(SaajUtils.java:155)
    at org.springframework.ws.soap.saaj.SaajSoapMessage.g etSaajVersion(SaajSoapMessage.java:257)
    at org.springframework.ws.soap.saaj.SaajSoapMessage.g etImplementation(SaajSoapMessage.java:342)
    at org.springframework.ws.soap.saaj.SaajSoapMessage.& lt;init>(SaajSoapMessage.java:117)
    at org.springframework.ws.soap.saaj.SaajSoapMessageFa ctory.createWebServiceMessage(SaajSoapMessageFacto ry.java:184)
    at org.springframework.ws.soap.saaj.SaajSoapMessageFa ctory.createWebServiceMessage(SaajSoapMessageFacto ry.java:58)
    at org.springframework.ws.transport.AbstractWebServic eConnection.receive(AbstractWebServiceConnection.j ava:90)
    at org.springframework.ws.transport.support.WebServic eMessageReceiverObjectSupport.handleConnection(Web ServiceMessageReceiverObjectSupport.java:86)
    at org.springframework.ws.transport.http.WebServiceMe ssageReceiverHandlerAdapter.handle(WebServiceMessa geReceiverHandlerAdapter.java:57)
    at org.springframework.ws.transport.http.MessageDispa tcherServlet.doService(MessageDispatcherServlet.ja va:222)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:644)
    at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:560)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:820)
    at org.mortbay.jetty.servlet.ServletHolder.handle(Ser vletHolder.java:511)
    [...trimmed...]
    at org.mortbay.io.nio.SelectChannelEndPoint.run(Selec tChannelEndPoint.java:410)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run (QueuedThreadPool.java:582)
    Caused by: javax.xml.transform.TransformerException: org.xml.sax.SAXParseException: Content is not allowed in prolog.
    at org.apache.xalan.transformer.TransformerIdentityIm pl.transform(TransformerIdentityImpl.java:502)
    at com.sun.xml.internal.messaging.saaj.util.transform .EfficientStreamingTransformer.transform(Efficient StreamingTransformer.java:393)
    at com.sun.xml.internal.messaging.saaj.soap.EnvelopeF actory.createEnvelope(EnvelopeFactory.java:102)
    ... 46 more
    Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
    at com.sun.org.apache.xerces.internal.parsers.Abstrac tSAXParser.parse(AbstractSAXParser.java:1231)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserI mpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at org.xml.sax.helpers.XMLFilterImpl.parse(XMLFilterI mpl.java:333)
    at org.apache.xalan.transformer.TransformerIdentityIm pl.transform(TransformerIdentityImpl.java:485)
    ... 48 more

    Comment


    • #3
      Can anyone provide any guidance or clarification about how these kinds of exceptions can be handled? They appear to be outside the scope of an EndpointExceptionResolver

      Thanks!

      Comment


      • #4
        Same issue here.

        org.springframework.ws.soap.saaj.SaajSoapEnvelopeE xception: Could not access envelope: Unable to create envelope from given source: ; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionI mpl:

        Need some way of controlling the response what malformed xml is sent.

        Comment

        Working...
        X