|
@@ -1,42 +0,0 @@
|
|
|
-package com.fdkankan.manage.test;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.fdkankan.manage.common.ResultData;
|
|
|
-import com.fdkankan.manage.util.RsaUtils;
|
|
|
-import org.apache.http.HttpEntity;
|
|
|
-import org.apache.http.HttpResponse;
|
|
|
-import org.apache.http.client.methods.HttpPost;
|
|
|
-import org.apache.http.entity.StringEntity;
|
|
|
-import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
-import org.apache.http.impl.client.HttpClients;
|
|
|
-import org.apache.http.util.EntityUtils;
|
|
|
-import org.junit.jupiter.api.Test;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import java.io.IOException;
|
|
|
-
|
|
|
-public class Test1 {
|
|
|
-
|
|
|
- @org.junit.jupiter.api.Test
|
|
|
- public void test1() throws IOException {
|
|
|
- String url = "http://192.168.0.25/service/manage/external/getByRyId";
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("ryId","13800138001");
|
|
|
- String encipher = RsaUtils.encipher(jsonObject.toJSONString());
|
|
|
-
|
|
|
- HttpPost httpPost = new HttpPost(url);
|
|
|
- CloseableHttpClient client = HttpClients.createDefault();
|
|
|
- StringEntity entity = new StringEntity(encipher,"utf-8");//解决中文乱码问题
|
|
|
- entity.setContentEncoding("utf-8");
|
|
|
- entity.setContentType("application/json");
|
|
|
- httpPost.setEntity(entity);
|
|
|
- HttpResponse response = client.execute(httpPost);
|
|
|
- if(response.getStatusLine().getStatusCode() == 200){
|
|
|
- HttpEntity httpEntity = response.getEntity();
|
|
|
- String result = EntityUtils.toString(httpEntity, "utf-8");
|
|
|
- System.out.println(result);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|