|
|
|
@ -3,12 +3,18 @@ package org.jeecg.common.util;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.jeecg.config.RestTemplateConfig;
|
|
|
|
|
import org.springframework.http.*;
|
|
|
|
|
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
|
|
|
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
|
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.security.KeyManagementException;
|
|
|
|
|
import java.security.KeyStoreException;
|
|
|
|
|
import java.security.NoSuchAlgorithmException;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@ -260,4 +266,25 @@ public class RestUtil {
|
|
|
|
|
return urlVariables.substring(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static JSONObject postTest(String httpUrl,JSONObject requestBodyJson,JSONObject headerJson){
|
|
|
|
|
RestTemplate restTemplate = null;
|
|
|
|
|
try {
|
|
|
|
|
restTemplate = new RestTemplate(RestTemplateConfig.generateHttpRequestFactory());
|
|
|
|
|
} catch (NoSuchAlgorithmException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (KeyManagementException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (KeyStoreException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
MultiValueMap<String, Object> headers =(MultiValueMap) headerJson.getInnerMap();;
|
|
|
|
|
headers.add("Accept", "*/*");
|
|
|
|
|
headers.add("Content-Type", "application/json");
|
|
|
|
|
String requestBody = requestBodyJson.toJSONString();
|
|
|
|
|
HttpEntity entity = new HttpEntity(requestBody, headers);
|
|
|
|
|
ResponseEntity<String> responseEntity=restTemplate.postForEntity(httpUrl,entity,String.class);
|
|
|
|
|
//获取返回结果
|
|
|
|
|
String result= responseEntity.getBody();
|
|
|
|
|
return JSONObject.parseObject(result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|