Fix Jaxb2Marshaller when mtomEnabled and schema validation are both set - #37120
Open
arimu1 wants to merge 1 commit into
Open
Fix Jaxb2Marshaller when mtomEnabled and schema validation are both set#37120arimu1 wants to merge 1 commit into
arimu1 wants to merge 1 commit into
Conversation
When mtomEnabled and a Schema are both configured, validate the logical infoset first (non-XOP base64Binary simple content, SWA placeholders), then MTOM-encode without Schema so xop:Include children do not fail cvc-type.3.1.2. Fixes spring-projects/spring-ws#1030 (SWS-958). Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
When
Jaxb2Marshallerhas bothmtomEnabled=trueand a configuredschema/schemas, marshalling fails with:XOP packaging replaces
xs:base64Binarysimple content withxop:Includeelement children. JAXB applies theSchemato the XOP-encoded stream, so validation rejects valid logical content.Reported via spring-projects/spring-ws#1030 (SWS-958); sample: https://github.com/mpeterka/spring-ws-mtom (
testMarshallMtom).The bug lives in
spring-oxm(Jaxb2Marshaller), not in Spring WS itself.Fix
When MTOM is active and a schema is configured:
AttachmentMarshaller(isXOPPackage() == false) sobase64Binarystays simple content and@XmlAttachmentRef/SWA still get a placeholder content id.MimeContainerattachment marshaller soxop:Includeis written without re-validating the XOP package.This matches the expected order from the issue: validate → replace with MTOM includes → send.
Tests
marshalAttachmentsWithSchema— MTOM + matching XSD succeeds and still adds attachmentsmarshalAttachmentsWithSchemaRejectsInvalidGraph— wrong schema still fails before attachments are addedmarshalAttachmentsunchanged24 + 12 tests green (Temurin 25).
Related
PayloadValidatingInterceptorcan be a follow-up if needed.