|
@@ -0,0 +1,70 @@
|
|
|
+package org.springblade.archive.controller;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import lombok.val;
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
+import org.apache.http.HttpEntity;
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
+import org.apache.http.client.HttpClient;
|
|
|
+import org.apache.http.client.methods.HttpGet;
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
|
|
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
|
|
|
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
+import org.apache.http.impl.client.HttpClientBuilder;
|
|
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
+import org.apache.http.ssl.SSLContexts;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
+import org.springblade.archive.utils.HttpUtil;
|
|
|
+
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.security.KeyManagementException;
|
|
|
+import java.security.KeyStoreException;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
+
|
|
|
+public class JinlinApiPush {
|
|
|
+
|
|
|
+ private static final String CLIENTID="hqs_veams01";
|
|
|
+ private static final String CLIENTSECRETKEY="E54F640850C946E7A660402B85FBF0C7";
|
|
|
+ private static final String SYSTEMID="9";
|
|
|
+ public static void main(String[] args) throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
|
|
|
+ //获取发送get请求的校验码
|
|
|
+ String s = "clientSecretKey="+CLIENTSECRETKEY+"&clientId="+CLIENTID;
|
|
|
+ String signature = "EB90C86BE03917A0EC5EE8CE86E81C76";
|
|
|
+ System.out.println(signature);
|
|
|
+ //创建http连接
|
|
|
+ //信任所有证书,关闭主机名校验
|
|
|
+// SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
|
|
|
+// SSLContexts.custom().loadTrustMaterial
|
|
|
+// (null,new TrustSelfSignedStrategy()).build(),
|
|
|
+// NoopHostnameVerifier.INSTANCE);
|
|
|
+ // 创建Httpclient对象
|
|
|
+ HttpClient httpClient =HttpClientBuilder.create().build();
|
|
|
+ // String url = "https://hgqs.jtyst.jl.gov.cn:6100/dock/openapi/hqsws/hqsprojpact/query";
|
|
|
+ String url = "https://hgqs.jtyst.jl.gov.cn:6100/dock/openapi/hqsws/hqsprojpact/query";
|
|
|
+ HttpGet httpGet = new HttpGet(url);
|
|
|
+ httpGet.setHeader("Content-Type", "application/json");
|
|
|
+ httpGet.setHeader("clientId",CLIENTID);
|
|
|
+ httpGet.setHeader("signature",signature);
|
|
|
+ httpGet.setHeader("systemId",SYSTEMID);
|
|
|
+ try {
|
|
|
+ HttpResponse response = httpClient.execute(httpGet);
|
|
|
+ InputStream inputStream = response.getEntity().getContent();
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
+ int index = 0;
|
|
|
+ while ((index = inputStream.read(buffer)) != -1) {
|
|
|
+ outputStream.write(buffer, 0, index);
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = JSON.parseObject(outputStream.toString());
|
|
|
+ System.out.println(jsonObject);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|