We are in the process of migrating to Spring 6 and are trying to leverage the new HTTP interface for WebClient. We have a CustomCodec to add form fields to every outbound request (see screenshot). However, it seems to us that this behavior is not working when wrapped with the new HTTP interface.
Here is a demo project that reproduces this issue: https://github.com/matthenry87/http-interface-form-fields-codec-bug
If you run the tests in the project, you can see the test that uses WebClient alone works as intended and the test that uses InterfaceClient does not.
Additionally, we are also curious about whether we are setting up our MultiValueMap correctly. Spring Docs says we can pass one string value. Does it support passing multiple if they are annotated with @RequestParam?
We are using Spring 6 and Spring Boot 3.
Comment From: rstoyanchev
Thanks for the demo project!
HttpRequestValues
serializes form data, and sets the body to a byte[]
, and that's why FormHttpMessageWriter
doesn't get involved. There is no reason to do it this way, however, and we could just as well set the body to a MultiValueMap
instead, and let the configured codecs serialize it.
we are also curious about whether we are setting up our MultiValueMap correctly. Spring Docs says we can pass one string value. Does it support passing multiple if they are annotated with
@RequestParam
?
Yes it does and your sample is fine the way it is. Both the Javadoc for @RequestParam
and the reference docs mention that you can pass a MultiValueMap
. Are you looking at another place where this is not documented correctly?
Comment From: li0180
Thank you for your response!
We want to know if we can pass more than 1 string param annotated with @RequestParam, i.e. (@RequestParam String someString, @RequestParam String someOtherString).
Comment From: rstoyanchev
Yes, you can.
Comment From: matthenry87
@rstoyanchev Hello,
Would this not be considered a bug? Would we not expect that we would get the same behavior as a stand-alone WebClient when wrapping it in the ServiceProxy?
Comment From: matthenry87
Ah, nevermind I see the commit :)