I want to implement Spring endpoint in which I can return XML object NotificationEchoResponse and http status code. I tried this:
@PostMapping(value = "/v1/notification", produces = "application/xml")
  public ResponseEntity<?> handleNotifications(@RequestParam MultiValueMap<String, Object> keyValuePairs) {
   if (!tnx_sirnature.equals(signature)) 
     {
         return new ResponseEntity<>("Please contact technical support!", HttpStatus.INTERNAL_SERVER_ERROR);
     }         
    return new ResponseEntity<>(new NotificationEchoResponse(unique_id), HttpStatus.OK);
  }
But I get error: Cannot infer type arguments for ResponseEntity<> at this line: return new ResponseEntity<>("Please contact technical support!", HttpStatus.INTERNAL_SERVER_ERROR); Do you know know how I can fix this issue?
You can use the
    ResponseEntity<Object> 
like that
OR
You can make you own custom class like ResponseData and in that class put a field like paylod
  public class ResponseData {
      private Object payload;
   } 
and use like that ResponseEntity and set that value.
Now your controller will look like that
    @PostMapping(value = "/v1/notification", produces = "application/xml")
    public ResponseEntity<ResponseData> handleNotifications(@RequestParam 
    MultiValueMap<String, Object> keyValuePairs) {
   if (!tnx_sirnature.equals(signature)) 
   {
     return new ResponseEntity<ResponseData>(new ResponseData("Please contact to technical support"), 
    HttpStatus.INTERNAL_SERVER_ERROR);
   }         
   return new ResponseEntity<ResponseData>(new ResponseData(new NotificationEchoResponse(unique_id)), 
   HttpStatus.OK);
   }
You can replace the response data with Object also , then the
  @PostMapping(value = "/v1/notification", produces = "application/xml")
    public ResponseEntity<Object> handleNotifications(@RequestParam 
    MultiValueMap<String, Object> keyValuePairs) {
   if (!tnx_sirnature.equals(signature)) 
   {
     return new ResponseEntity<Object>("Please contact to technical support", 
    HttpStatus.INTERNAL_SERVER_ERROR);
   }         
   return new ResponseEntity<Object>(new NotificationEchoResponse(unique_id), 
   HttpStatus.OK);
   }
                        public ResponseEntity<BasicCreateUpdateResponse> deleteProductPrefix(@RequestBody ProductPrefixEntity inputFields) {
    if(inputFields.getRecid().isEmpty()) {
        throw new ApplicationException(NPIConstants.ERR_500, HttpStatus.OK, null, null);
    }
    logger.info("Inside resources updateProduct method() .........");
    return new ResponseEntity<>(productPrefixService.deleteProductPrefix(inputFields),HttpStatus.OK);
}
in this code return type of "productPrefixService.deleteProductPrefix(inputFields)" must be ResponseEntity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With