[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


 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>



 Comments   
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.
http://forum.springsource.org/showthread.php?t=71974

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 Fri Sep 22 22:26:58 UTC 2017 using JIRA 6.4.14#64029-sha1:ae256fe0fbb912241490ff1cecfb323ea0905ca5.