[SWS-242] Allow for custom ErrorHandler in PayloadValidatingInterceptor Created: 22/Nov/07  Updated: 04/May/12  Resolved: 24/Mar/11

Status: Closed
Project: Spring Web Services
Component/s: Core, OXM, XML
Affects Version/s: 1.0.2
Fix Version/s: 2.0.1

Type: Bug Priority: Major
Reporter: Albert van 't Hart Assignee: Arjen Poutsma
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 44m
Original Estimate: Not Specified


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.

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

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

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

SOAP response:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<faultstring xml:lang="en">Validation error</faultstring>
<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>

Comment by Arjen Poutsma [ 23/Nov/07 ]

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.

Comment by Albert van 't Hart [ 23/Nov/07 ]

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

Comment by Arjen Poutsma [ 23/Nov/07 ]

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

Comment by Esat Postaci [ 07/Jan/11 ]

What about the suggested fix on this post.

Skip elements can be a workaround for this issue.

Comment by Arjen Poutsma [ 07/Jan/11 ]

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

Comment by Arjen Poutsma [ 24/Mar/11 ]

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.

Comment by Arjen Poutsma [ 04/May/12 ]

Closing old issues

Generated at Sun Jun 24 03:32:52 UTC 2018 using JIRA 7.9.0#79000-sha1:3ca552e944c2fe83b21589bc06f155b9b428cc2b.