Disable Encoding Process on RestTemplate Springboot XML Request

31 Views Asked by At

Is it possible to disable encoding process when request XML with RestTemplate?

I need to send my value like this ud=HELLOOOO YEYEYE©À¥¥didiwawa©yayuÀ

ud=HELLOOOO YEYEYE🥺🥺©À¥¥didi🥺wawa©yayuÀ

This is my request

  defaultUriBuilderFactory.setEncodingMode(DefaultUriBuilderFactory.EncodingMode.NONE);
  restTemplate.setUriTemplateHandler(defaultUriBuilderFactory);
  HttpHeaders headers = new HttpHeaders();
  headers.setAccept(Collections.singletonList(MediaType.TEXT_XML));
  headers.setContentType(MediaType.TEXT_XML);
  HttpEntity<Message> httpEntity = new HttpEntity<>(request, headers);

   ResponseEntity<String> responseEntity = restTemplate.postForEntity(uriComponentsBuilder.toUriString(), httpEntity, String.class);

when I check the log, my request look like this on restTemplate process

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ud type="text">HELLOOOO YEYEYE&amp;#x1f97a;&amp;#x1f97a;&amp;#xa9;&amp;#xc0;&amp;#xa5;&amp;#xa5;didi&amp;#x1f97a;wawa&amp;#xa9;yayu&amp;#xc0;</ud>

I want my value parse to xml but without encoding process.

0

There are 0 best solutions below