Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance SoapDecoder by using Content Type from Response as Mime Type #1732

Open
StefanFellinger opened this issue Aug 25, 2022 · 2 comments
Open
Labels
help wanted Issues we need help with tackling proposal Proposed Specification or API change

Comments

@StefanFellinger
Copy link

By sending a soap request to an external service, i've found that the response of that soap call contains the Content-Type "multipart/related; type="application/xop+xml"; boundary=...".

The result is that the soap Message unmarshalling fails with some error "Unexpected content...".
I've fixed that by creating a copy of SoapDecoder and propagate the Content-Type of the response to the MessageFactory.
After that the Soap Envelope was unmarshalled as expected.

The relevant part that i've changed is:

final MimeHeaders mimeHeaders = new MimeHeaders();
final String contentType = response.headers().get("Content-Type").stream().collect(Collectors.joining(";"));
mimeHeaders.setHeader("Content-Type", contentType);
SOAPMessage message = MessageFactory.newInstance(soapProtocol)
                                    .createMessage(mimeHeaders, response.body().asInputStream());

Would be nice if it's possible to always use the Content-Type from the Response, but i don't know if there are any other pitfalls when doing that in general.

Kind regards,

Stefan

@kdavisk6 kdavisk6 added help wanted Issues we need help with tackling proposal Proposed Specification or API change labels Oct 7, 2022
@kdavisk6
Copy link
Member

kdavisk6 commented Oct 7, 2022

We welcome contributions from all users. Check the CONTRIBUTING guide in our repository for information on how to submit a PR.

For something like this, consider a configuration property for the SoapDecoder that allows for Content-Type propagation, but implement is as disabled by default. This will enable the feature for those that want it and keep it backward compatible.

@zaenk
Copy link

zaenk commented Nov 12, 2022

In addition to MimeHeaders propagation javax.xml.bind.Unmarshaller#setAttachmentUnmarshaller must also be set to properly support SOAP MTOM & XOP. For an example, see this SO answer: https://stackoverflow.com/a/24417032

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues we need help with tackling proposal Proposed Specification or API change
Projects
None yet
Development

No branches or pull requests

3 participants