Browse Source

关闭client

master
CMM 1 year ago
parent
commit
707108083d
1 changed files with 7 additions and 5 deletions
  1. +7
    -5
      pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java

+ 7
- 5
pmapi/src/main/java/com/ningdatech/pmapi/irs/sign/IRSAPIRequest.java View File

@@ -6,6 +6,7 @@ import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.util.StrPool; import com.ningdatech.basic.util.StrPool;
import com.ningdatech.pmapi.irs.config.IrsSealPlatformProperties; import com.ningdatech.pmapi.irs.config.IrsSealPlatformProperties;
import com.ningdatech.pmapi.todocenter.model.dto.SignReqDTO; import com.ningdatech.pmapi.todocenter.model.dto.SignReqDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
@@ -34,7 +35,7 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j
public class IRSAPIRequest { public class IRSAPIRequest {


/** /**
@@ -121,21 +122,22 @@ public class IRSAPIRequest {
.setSocketTimeout(5000) .setSocketTimeout(5000)
.build(); .build();
// 通过 HttpClientBuilder 的 custom() 方法创建自定义的 HttpClient // 通过 HttpClientBuilder 的 custom() 方法创建自定义的 HttpClient
HttpClient customHttpClient = HttpClients.custom()
CloseableHttpClient customHttpClient = HttpClients.custom()
.setDefaultRequestConfig(requestConfig) .setDefaultRequestConfig(requestConfig)
.build(); .build();
HttpResponse res = customHttpClient.execute(req); HttpResponse res = customHttpClient.execute(req);
int statusCode = res.getStatusLine().getStatusCode(); int statusCode = res.getStatusLine().getStatusCode();
System.out.println(statusCode);
log.info(String.valueOf(statusCode));
if (200 != statusCode) { if (200 != statusCode) {
System.out.println(statusCode);
log.info(String.valueOf(statusCode));
} }
// 获取响应 // 获取响应
InputStream in = res.getEntity().getContent(); InputStream in = res.getEntity().getContent();


byte[] resp = readStream(in); byte[] resp = readStream(in);
String strRes = new String(resp, StandardCharsets.UTF_8); String strRes = new String(resp, StandardCharsets.UTF_8);
System.out.println(strRes);
log.info(strRes);
customHttpClient.close();
return strRes; return strRes;
} }




Loading…
Cancel
Save