IClearApiApplicationTests.java
3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package com.erry.iclear.dateInterface;
import com.alibaba.fastjson.JSONObject;
import com.arronlong.httpclientutil.HttpClientUtil;
import com.arronlong.httpclientutil.builder.HCB;
import com.arronlong.httpclientutil.common.HttpConfig;
import com.arronlong.httpclientutil.common.HttpHeader;
import com.arronlong.httpclientutil.common.SSLs;
import com.arronlong.httpclientutil.exception.HttpProcessException;
import com.erry.iclear.dateInterface.api.request.ConsignmentCode;
import com.erry.iclear.dateInterface.util.SHA256Util;
import com.google.gson.Gson;
import org.apache.http.Header;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import java.util.*;
@RunWith(SpringRunner.class)
@SpringBootTest
@WebAppConfiguration
@ActiveProfiles("dev")
class IClearApiApplicationTests {
public static void main(String[] args) throws HttpProcessException {
Gson gson = new Gson();
String str = "{\"consignmentCode\":\"" +
"201907105," +
"202018092," +
"202108026," +
"192770847591," +
"201907099," +
"202017062," +
"770194186721," +
"201907109," +
"201907092," +
"201907096," +
"201907103," +
"201907093," +
"774439601," +
"774439602," +
"201907097," +
"281382086345," +
"202108100," +
"192770847477," +
"192770847478," +
"149148215190\"}";
// String str = "{\"consignmentCode\":\"110000011\"}";
String timeStamp = "1634697153697";
//String timeStamp = "1624263798669";
System.out.println(new Date(Long.valueOf(timeStamp)));
//String token = SHA256Util.getSHA256String("IDE" + "iClearExport" + "b92131f03f19a348" + timeStamp);
String token = SHA256Util.getSHA256String("BASF" + "iClearExportC" + "6db193cb4165a71b" + timeStamp);
System.out.println(token);
Header[] headers = HttpHeader.custom()
.other("Content-Type", "application/json")
.other("Appid", "BASF")
.other("appKey", "iClearExportC")
.other("TimeStamp", timeStamp)
.other("token", "2D9F60B9ACE7A559CF1C21F34D543522F3520C7FF0F4A94FEC5A9700BC8589B8")
.build();
HCB hcb = HCB.custom()
.timeout(20000)
.pool(100, 10)
.sslpv(SSLs.SSLProtocolVersion.TLSv1_2)
.ssl()
.retry(3);
//String url = "https://40.73.78.157:8780/customs/sendMawb";
String url = "https://40.73.78.157:8780/basf/selectDecListBasf";
//String url = "https://40.73.78.157:8780/basf/selectChmListBasf";
HttpConfig config = HttpConfig.custom()
.headers(headers)
.url(url)
.encoding("utf-8")
.client(hcb.build())
// .json(new Gson().toJson(createMawb()));
.json(str);
System.out.println(HttpClientUtil.post(config));
}
}