Skip to content

fix(saaj): sync header changes before getDocument() - #1849

Open
arimu1 wants to merge 1 commit into
spring-projects:mainfrom
arimu1:fix/1153-saaj-header-document
Open

fix(saaj): sync header changes before getDocument()#1849
arimu1 wants to merge 1 commit into
spring-projects:mainfrom
arimu1:fix/1153-saaj-header-document

Conversation

@arimu1

@arimu1 arimu1 commented Aug 15, 2026

Copy link
Copy Markdown

Summary

  • Call saveChanges() in SaajSoapMessage.getDocument() before serializing the backing SAAJ message
  • Ensures header elements added via SoapHeader.addHeaderElement() are reflected in the returned Document (fixes MockWebServiceServer / SoapEnvelopeDiffMatcher mismatches)

Fixes #1153

Root cause

getDocument() serializes the SAAJ message via writeTo() without first calling saveChanges(). In-memory header mutations from addHeaderElement() are therefore omitted from the serialized DOM even though they appear when the message is sent via writeTo() (which already calls saveChanges()).

Test plan

  • ./gradlew :spring-ws-core:test --tests "org.springframework.ws.soap.saaj.SaajSoap11MessageTests.getDocumentReflectsAddedHeaderElement"
  • ./gradlew :spring-ws-core:test --tests "org.springframework.ws.soap.saaj.SaajSoap12MessageTests.getDocumentReflectsAddedHeaderElement"
  • ./gradlew :spring-ws-core:test --tests "org.springframework.ws.soap.saaj.*"

Signed-off-by: arimu1 19286898+arimu1@users.noreply.github.com

Made with Cursor

Call saveChanges() in SaajSoapMessage.getDocument() before serializing
the SAAJ message so header elements added via SoapHeader.addHeaderElement
are reflected in the returned Document.

Fixes spring-projects#1153

Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding header element is not reflected in Document [SWS-1087]

2 participants