OpenFeign / OpenFeign/feign

Enhance SoapDecoder by using Content Type from Response as Mime Type

Open
#1,732 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted proposal
Dominant language
Java
Stars
9.8k
Forks
1.9k
Avg merge
1d 2h
Merged PRs (30d)
41

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in SoapDecoder and trace how the HTTP response is passed to MessageFactory.newInstance(soapProtocol). Reproduce the multipart/related response with its Content-Type header, then verify that the header reaches SOAP message creation and the envelope unmarshals successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.