I have problem with this case, hope somebody will help me.
So I have mocked get server:
@GetMapping(value = "/getMsgFileExt",
produces = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<MultiValueMap<String, Object>> getMsgFileExt() throws IOException {
MultiValueMap<String, Object> formData = new LinkedMultiValueMap<>();
Path path = Paths.get("C:\Users\User\IdeaProjects\ccgw_sources\TKmock\src\main\resources\test.txt.zip.total.zip");
formData.add("xml", respDataMsgInfo);
formData.add("zip", Base64.getEncoder().encodeToString(Files.readAllBytes(path)));
return new ResponseEntity<>(formData, HttpStatus.OK);
}
And Receiver on client side :
String uri = String.format("%s/getMsgFileExt", customsUrl);
UriComponents builder = UriComponentsBuilder.fromHttpUrl(uri)
.queryParam("id", id)
.build();
ResponseEntity<MultiValueMap<String, Object>> response = customsCardRestTemplate.exchange(builder.toUriString(), HttpMethod.GET,
null,
new ParameterizedTypeReference<>() {});
MultiValueMap<String, Object> map = response.getBody();
But i got this exception :
Could not extract response: no suitable HttpMessageConverter found for response type [org.springframework.util.MultiValueMap<java.lang.String, java.lang.Object>] and content type [multipart/form-data]
I already read this topic RestTemplate & multipart/form-data response, but I am sure that spring boot has another solution.
Or Maybe we have another way to send/receive multipart with xml and zip?