use of org.springframework.web.client.RestTemplate in project portal by ixinportal.
the class WeixinUtil method initRestTemplate.
// 自定义restTemplate
// @PostConstruct
public void initRestTemplate() {
restTemplate = new RestTemplate(httpClientFactory);
List<HttpMessageConverter<?>> messageConverters = new ArrayList();
messageConverters.add(new ResourceHttpMessageConverter());
restTemplate.setMessageConverters(messageConverters);
}
use of org.springframework.web.client.RestTemplate in project portal by ixinportal.
the class RestTemplateUtils method main.
public static void main(String[] args) throws KeyManagementException, KeyStoreException, NoSuchAlgorithmException {
CloseableHttpClient httpClient = RestTemplateUtils.acceptsUntrustedCertsHttpClient();
HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory);
String result = restTemplate.getForObject("http://www.baidu.com", String.class);
System.out.println(result);
}
use of org.springframework.web.client.RestTemplate in project portal by ixinportal.
the class ClientWebControllerTest method testgetAllInfo3.
@Test
public void testgetAllInfo3() {
try {
String url = "https://ixin.itrus.com.cn/clientWeb/getProductInfo";
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
// 项目id
map.add("projectName", "宁波CA");
//
map.add("type", 2);
map.add("certSn", "4A52B8E3B7C7478BEDB2E7732496D699BA627F16");
map.add("keySn", "TW15031122021634");
map.add("isregister", 0);
// enterprise
map.add("enterprise_enterpriseName", "宁波高新区天威诚信数字证书技术服务有限公司");
map.add("enterprise_enterpriseSn", "91330201677673485L");
// map.add("enterprise_orgIndustry", 1);
map.add("enterprise_enterpriseNature", 1);
// userInfo
map.add("userInfo_realName", "张琼艳");
map.add("userInfo_trustMPhnoe", true);
map.add("userInfo_trustEmail", true);
map.add("userInfo_mPhone", "13123801307");
map.add("userInfo_email", "153312045@qq.com");
map.add("userInfo_telephone", "0574-87324610");
// map.add("userInfo_userPosition", "java");
map.add("userInfo_postalCode", "315000");
map.add("userInfo_regionCodes", "");
map.add("userInfo_userAdds", "宁波市海曙区华楼街8号");
map.add("userInfo_orgIndustry", 9);
// 营业执照businessLicense_
//
map.add("businessLicense_enterpriseName", "宁波高新区天威诚信数字证书技术服务有限公司");
//
map.add("businessLicense_licenseNo", "330215000008195");
// 是否三证合一,是否三证合一
map.add("businessLicense_isDateless", false);
// 住所
map.add("businessLicense_abode", "宁波高新区院士路66号创业大厦5-41室");
// 住所
map.add("businessLicense_businessScope", null);
//
map.add("businessLicense_regFund", "100万元");
//
map.add("businessLicense_operationStart", "2008-08-18 00:00:00");
//
map.add("businessLicense_operationEnd", "2018-08-17 23:59:59");
//
map.add("businessLicense_imgFile", ImageUtils.getImgBase64("/com/itrus/portal/controller/web/test/businessLicense_imgFile.txt"));
// 组织机构信息
//
map.add("orgCode_enterpriseName", "宁波高新区天威诚信数字证书技术服务有限公司");
//
map.add("orgCode_orgCode", "677673485");
//
map.add("orgCode_imgFile", ImageUtils.getImgBase64("/com/itrus/portal/controller/web/test/orgCode_imgFile.txt"));
// 税务登记信息taxregisterCert_
//
map.add("taxregisterCert_enterpriseName", "宁波高新区天威诚信数字证书技术服务有限公司");
//
map.add("taxregisterCert_certNo", "330207677673485");
//
map.add("taxregisterCert_imgFile", ImageUtils.getImgBase64("/com/itrus/portal/controller/web/test/taxregisterCert_imgFile.txt"));
// 法人信息
//
map.add("identityCard_enterpriseName", "宁波高新区天威诚信数字证书技术服务有限公司");
//
map.add("identityCard_idCode", "330103196504191647");
//
map.add("identityCard_name", "胥琳");
map.add("identityCard_cardType", 1);
//
map.add("identityCard_frontImg", ImageUtils.getImgBase64("/com/itrus/portal/controller/web/test/identityCard_frontImg.txt"));
//
map.add("identityCard_backImg", ImageUtils.getImgBase64("/com/itrus/portal/controller/web/test/identityCard_backImg.txt"));
CloseableHttpClient httpClient = RestTemplateUtils.acceptsUntrustedCertsHttpClient();
HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory);
String map2 = restTemplate.postForObject(url, map, String.class);
System.out.println(map2);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
use of org.springframework.web.client.RestTemplate in project openmrs-module-pihcore by PIH.
the class RestBiometricEngine method update.
@Override
public BiometricSubject update(BiometricSubject subject) {
RestTemplate restTemplate = new RestTemplate();
String url = getSubjectUrl();
ResponseEntity<BiometricSubject> response = restTemplate.exchange(url, HttpMethod.PUT, new HttpEntity<BiometricSubject>(subject), BiometricSubject.class);
if (HttpStatus.OK.equals(response.getStatusCode()) || HttpStatus.CREATED.equals(response.getStatusCode())) {
return response.getBody();
} else {
throw new IllegalStateException("Error updating biometric subject at URL <" + url + ">. Response status code: " + response.getStatusCode());
}
}
use of org.springframework.web.client.RestTemplate in project openmrs-module-pihcore by PIH.
the class RestBiometricEngine method enroll.
@Override
public BiometricSubject enroll(BiometricSubject subject) {
RestTemplate restTemplate = new RestTemplate();
String url = getSubjectUrl();
ResponseEntity<BiometricSubject> response = restTemplate.postForEntity(url, subject, BiometricSubject.class);
if (HttpStatus.OK.equals(response.getStatusCode()) || HttpStatus.CREATED.equals(response.getStatusCode())) {
return response.getBody();
} else {
throw new IllegalStateException("Error enrolling biometric subject at URL <" + url + ">. Response status code: " + response.getStatusCode());
}
}
Aggregations