I'm trying to consume a webservice from ceps but it always returns me 403 and it's public.
WebService Test Running:
My Controller
@Controller
@RequestMapping("/busca-cep")
public class BuscaCEPController {
private static final Logger LOG = LoggerFactory.getLogger(BuscaCEPController.class);
@Autowired
private LogService logService;
@Autowired
private BuscaCEPService buscaCEPService;
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<CEPResult> buscaCEP(String code) {
try {
logService.info(LOG, "action=buscaCEPIniciado, cep={}", code);
CEPResult result = buscaCEPService.buscarCEP(code);
logService.info(LOG, "action=buscaCEPConcluido, cep={}", code);
return new ResponseEntity<CEPResult>(result, HttpStatus.OK);
} catch (Exception e) {
logService.error(LOG, "action=buscaCEPErro, cep={}, e={}", code, e.getMessage());
return new ResponseEntity<CEPResult>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
}
My Consumer Service
@Service
public class BuscaCEPService {
public CEPResult buscarCEP(String code) {
RestTemplate restTemplate = new RestTemplate();
CEPResult result = restTemplate.getForObject("http://apps.widenet.com.br/busca-cep/api/cep.json?code=" + code, CEPResult.class);
return result;
}
}