@RequestMapping(method = RequestMethod.POST, produces = "application/json; charset=utf-8")
public @ResponseBody Map<String, String> getTest(@RequestBody Map<String, Long> params) {
Map<String, String> response = new HashMap<>();
response.put("name", "My Service");
return response;
}
@Configuration
public class PublicAPIConfiguration {
@LoadBalanced
@Bean
RestTemplate restTemplate() {
return new RestTemplate();
}
}
@Service
public class MyServiceService {
@Autowired
private RestTemplate restTemplate;
private final String serviceUrl;
public MyServiceService() {
this.serviceUrl = "http://my-service";
}
public Map<String, String> gettest() {
Map<String, Long> vars = new HashMap<>();
vars.put("id", 1L);
return restTemplate.postForObject(serviceUrl+"/test", vars, Map.class);
}
}