calling a Webservice returns JsonMappingException

2019-09-15 01:20发布

问题:

I am working on spring based application. Below is the rest webservice method.

@RequestMapping(value = MyRequestMapping.GET_SIG_DATA, method = RequestMethod.GET)
@ResponseBody
public List<String> getSigDataValues(@PathVariable final String acc, final HttpServletResponse response)
            throws Exception {
        List<String> dataList = null;
        try {
             //logic goes here
        } catch (Exception e) {
             LOG.error("Exception" + e);
        }
        return dataList;
    }

The above webservice is not returning any responseDTO object, it just returns a list of String type.

I want to call above webservice from another application.Below is my code.

 public List<String> getSigData(String acc){

       try{
    list= (List<String>)restTemplate.postForObject(DataURL.GET_SIG_DATA.value(), MyRequestDTO.class,MyResponseDTO.class, acc);
        }
        catch (final RestClientException e)
        {
            LOG.info("RestClientException :" + e);
             String errorMsg = StringUtils.EMPTY;
            if (e instanceof HttpStatusCodeException)
            {
                errorMsg = ((HttpStatusCodeException) e).getResponseBodyAsString();
            }
            else
            {
                errorMsg = e.getMessage();
            }
            LOG.error("error message : : " + errorMsg);
          }
}

When i am calling the above webservice call, its giving me below exception message:

 RestClientException : org.springframework.web.client.HttpServerErrorException: 500 Internal Server Error
 INFO  [STDOUT] error message : {"type":"JsonMappingException","message":"General error"}

Please suggest, as the webservice call returns list as JSON object, do i need to handle at client side? How can i call the above mention webservice in getSigData(..) method.