If response object contains the xml data in string format then it shows response in improper format.
@ApiResponses(value = { @ApiResponse(responseCode = "404", description = "Resource name not found"),
@ApiResponse(responseCode = "415 ", description = "Unsupported Media Type"),
@ApiResponse(responseCode = "500 ", description = "Application Error") })
@GetMapping(value = "/validate-resource/{resourceName}", consumes = { MediaType.APPLICATION_JSON_VALUE,
MediaType.APPLICATION_XML_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE,
MediaType.APPLICATION_XML_VALUE })
public ResponseEntity<Response> connectionValidate(
@Parameter(description = "resourceName cannot be empty.", required = true) @PathVariable(value = "resourceName", required = true) String resourceName)
throws Throwable {
HelperService helperService = new HelperService();
if (resourceMap == null || resourceMap.get(resourceName) == null) {
Response response = new Response();
response.setStatus("error");
response.setMessage("Resource name not found");
return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
}
HashMap<String, String> resourceDataMap = resourceMap.get(resourceName);
String localResponse = helperService.execute(helperSettingsFilePath,filepath, resourceDataMap, "SAP ERP",
"validate-resource");
Response response = new Response();
response.setStatus("success");
response.setData(localResponse);
return new ResponseEntity<>(response, HttpStatus.OK);
}
When we call api it shows response in following format
<Response>
<status>success</status>
<message/>
<data>
<?xml version="1.0" encoding="UTF-8"?>
<Return>
<Status name="SUCCESS">0</Status>
<Description>Connection to the requested SapR3 Server was established successfully.</Description>
</Return>
</data>
</Response>
Expected out put
<Response>
<status>success</status>
<message/>
<data>
<?xml version="1.0" encoding="UTF-8"?>
<Return>
<Status name = "SUCCESS">0</Status>
<Description>Connection to the requested SapR3 Server was established successfully.</Description>
</Return>
</data>
</Response>
Please let me know what is going wrong here.