Spring Web Services
  1. Spring Web Services
  2. SWS-242

Allow for custom ErrorHandler in PayloadValidatingInterceptor

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.2
    • Fix Version/s: 2.0.1
    • Component/s: Core, OXM, XML
    • Labels:
      None

      Description

      Validating a SOAP request or response with PayloadValidatingInterceptor or Jaxb2Marshaller fails when using MTOM.

      The spring-ws MTOM sample fails when PayloadValidatingInterceptor is added to the endpoint interceptor chain.

      Schema:
      <element name="SendRequest" type="tns:SendMessage"/>

      <complexType name="SendMessage">
      <sequence>
      <element name="sender" type="string"/>
      <element name="recipient" type="string"/>
      <element name="content" type="base64Binary" xmime:expectedContentTypes="/"/>
      </sequence>
      </complexType>

      SOAP request:
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mail="http://www.enovation.nl/ems/mailwebservice">
      <soapenv:Header/>
      <soapenv:Body>
      <mail:SendRequest>
      <mail:sender>1</mail:sender>
      <mail:recipient>2</mail:recipient>
      <mail:content><inc:Include xmlns:inc="http://www.w3.org/2004/08/xop/include" href="cid:768176637073"/></mail:content>
      </mail:SendRequest>
      </soapenv:Body>
      </soapenv:Envelope>

      SOAP response:
      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
      <SOAP-ENV:Header/>
      <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
      <faultcode>SOAP-ENV:Client</faultcode>
      <faultstring xml:lang="en">Validation error</faultstring>
      <detail>
      <spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-type.3.1.2: Element 'mail:content' is a simple type, so it must have no element information item [children].</spring-ws:ValidationError>
      </detail>
      </SOAP-ENV:Fault>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

        Activity

        Hide
        Arjen Poutsma added a comment -

        I don't think this can't be fixed, because the underlying validation mechanism (i.e. javax.xml.validation) is not aware of XOM and MTOM.

        Unless a solution is suggested, I will resolve this as won't (or rather: can't) fix.

        Show
        Arjen Poutsma added a comment - I don't think this can't be fixed, because the underlying validation mechanism (i.e. javax.xml.validation) is not aware of XOM and MTOM. Unless a solution is suggested, I will resolve this as won't (or rather: can't) fix.
        Hide
        Albert van 't Hart added a comment -

        I already have looked in the source code for a possible fix and also think this can't be fixed easily.

        Show
        Albert van 't Hart added a comment - I already have looked in the source code for a possible fix and also think this can't be fixed easily.
        Hide
        Arjen Poutsma added a comment -

        Can't fix, unless we find a way to let JAXP deal with XOM.

        Show
        Arjen Poutsma added a comment - Can't fix, unless we find a way to let JAXP deal with XOM.
        Hide
        Esat Postaci added a comment -

        What about the suggested fix on this post.
        http://forum.springsource.org/showthread.php?t=71974

        Skip elements can be a workaround for this issue.

        Show
        Esat Postaci added a comment - What about the suggested fix on this post. http://forum.springsource.org/showthread.php?t=71974 Skip elements can be a workaround for this issue.
        Hide
        Arjen Poutsma added a comment -

        Perhaps that will work, I will take a look at it for 2.0.1

        Show
        Arjen Poutsma added a comment - Perhaps that will work, I will take a look at it for 2.0.1
        Hide
        Arjen Poutsma added a comment -

        You can now provide your own error handler for the PayloadValidationInterceptor (which should implement org.springframework.xml.validation.ValidationErrorHandler). In that error handler, you can do anything you like (including skipping elements).

        I did not provide a way to skip element by default, because it essentially comes down to stack-trace parsing, and I am reluctant to put fragile code like that in the SWS code base.

        Show
        Arjen Poutsma added a comment - You can now provide your own error handler for the PayloadValidationInterceptor (which should implement org.springframework.xml.validation.ValidationErrorHandler). In that error handler, you can do anything you like (including skipping elements). I did not provide a way to skip element by default, because it essentially comes down to stack-trace parsing, and I am reluctant to put fragile code like that in the SWS code base.
        Hide
        Arjen Poutsma added a comment -

        Closing old issues

        Show
        Arjen Poutsma added a comment - Closing old issues

          People

          • Assignee:
            Arjen Poutsma
            Reporter:
            Albert van 't Hart
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0d
              0d
              Logged:
              Time Spent - 44m
              44m