统一httpclient版本
This commit is contained in:
parent
21fff9b403
commit
b20fd06bb7
10
pom.xml
10
pom.xml
|
|
@ -212,11 +212,11 @@
|
|||
<artifactId>qcloud-sdk-2.2.7-jar-with-dependencies</artifactId>
|
||||
<version>2.2.7-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>agw</groupId>
|
||||
<artifactId>service-client</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>agw</groupId>-->
|
||||
<!-- <artifactId>service-client</artifactId>-->
|
||||
<!-- <version>2.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.dtflys.forest</groupId>
|
||||
<artifactId>forest-spring-boot-starter</artifactId>
|
||||
|
|
|
|||
|
|
@ -12,10 +12,12 @@ import com.chinaweal.aiccs.crgs.movein.service.TbZcEntityMoveinService;
|
|||
import com.chinaweal.aiccs.crgs.moveinDetails.entity.*;
|
||||
import com.chinaweal.aiccs.crgs.moveinDetails.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
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.dom4j.Document;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
|
|
@ -29,6 +31,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
|
|
@ -650,17 +653,14 @@ public class DownLoadTask {
|
|||
" </soapenv:Body>\n" +
|
||||
"</soapenv:Envelope>";
|
||||
|
||||
try {
|
||||
PostMethod postMethod = new PostMethod(downloadPath);
|
||||
byte[] b = soapRequestData.getBytes("utf-8");
|
||||
InputStream is = new ByteArrayInputStream(b, 0, b.length);
|
||||
//这里不能用 application/soap+xml 要改为text/xml,与soap版本有关
|
||||
RequestEntity re = new InputStreamRequestEntity(is, b.length, "text/xml; charset=utf-8");
|
||||
postMethod.setRequestEntity(re);
|
||||
try (CloseableHttpClient client = HttpClients.createDefault()) {
|
||||
HttpPost postMethod = new HttpPost(downloadPath);
|
||||
postMethod.setHeader("Content-Type", "text/xml; charset=utf-8");
|
||||
postMethod.setEntity(new StringEntity(soapRequestData, StandardCharsets.UTF_8));
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
int statusCode = httpClient.executeMethod(postMethod);
|
||||
String soapResponseData = postMethod.getResponseBodyAsString();
|
||||
CloseableHttpResponse response = client.execute(postMethod);
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
String soapResponseData = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
|
||||
|
||||
// String soapResponseData = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
|
||||
// " <soap:Body>" +
|
||||
|
|
|
|||
|
|
@ -9,12 +9,14 @@ import com.chinaweal.aiccs.crgs.transfor.sdk.XzxkWsBO;
|
|||
import com.chinaweal.aiccs.crgs.transfor.service.OtNcaseDownloadLogService;
|
||||
import com.chinaweal.aiccs.crgs.transfor.service.OtNpermitDownloadLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||
import org.apache.cxf.aegis.databinding.AegisDatabinding;
|
||||
import org.apache.cxf.frontend.ClientProxyFactoryBean;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
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.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
|
@ -25,6 +27,7 @@ import org.springframework.stereotype.Component;
|
|||
import javax.activation.DataHandler;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -221,24 +224,23 @@ public class DownloadSchedule {
|
|||
" </jog:downloadCreditInfoByXzcf>\n" +
|
||||
" </soapenv:Body>\n" +
|
||||
"</soapenv:Envelope>";
|
||||
PostMethod postMethod = new PostMethod(String.format(caseDownloadUrl, userName, password));
|
||||
byte[] b = soapRequestData.getBytes("utf-8");
|
||||
InputStream contentis = new ByteArrayInputStream(b, 0, b.length);
|
||||
//这里用 text/xml 或者 application/xml,与soap版本有关
|
||||
RequestEntity re = new InputStreamRequestEntity(contentis, b.length, "application/xml; charset=utf-8");
|
||||
postMethod.setRequestEntity(re);
|
||||
try (CloseableHttpClient client = HttpClients.createDefault()) {
|
||||
HttpPost postMethod = new HttpPost(String.format(caseDownloadUrl, userName, password));
|
||||
postMethod.setHeader("Content-Type", "application/xml; charset=utf-8");
|
||||
postMethod.setEntity(new StringEntity(soapRequestData, StandardCharsets.UTF_8));
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
int statusCode = httpClient.executeMethod(postMethod);
|
||||
String soapResponseData = postMethod.getResponseBodyAsString();
|
||||
//200说明正常返回数据
|
||||
if (statusCode == 200) {
|
||||
log.info("{}异地流转行政处罚请求下载接口,返回结果:{}", uploadDateto,soapResponseData);
|
||||
int z = soapResponseData.indexOf("<ns1:return>");
|
||||
int j = soapResponseData.indexOf("</ns1:return>");
|
||||
returnStr = soapResponseData.substring(z + "<ns1:return>".length(), j);
|
||||
} else {
|
||||
log.info("{}异地流转行政处罚请求下载接口失败,状态值:{}",uploadDateto ,statusCode);
|
||||
CloseableHttpResponse response = client.execute(postMethod);
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
String soapResponseData = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
|
||||
//200说明正常返回数据
|
||||
if (statusCode == 200) {
|
||||
log.info("{}异地流转行政处罚请求下载接口,返回结果:{}", uploadDateto, soapResponseData);
|
||||
int z = soapResponseData.indexOf("<ns1:return>");
|
||||
int j = soapResponseData.indexOf("</ns1:return>");
|
||||
returnStr = soapResponseData.substring(z + "<ns1:return>".length(), j);
|
||||
} else {
|
||||
log.info("{}异地流转行政处罚请求下载接口失败,状态值:{}", uploadDateto, statusCode);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
@ -437,24 +439,23 @@ public class DownloadSchedule {
|
|||
" </jog:downloadCreditInfoByXzxk>\n" +
|
||||
" </soapenv:Body>\n" +
|
||||
"</soapenv:Envelope>";
|
||||
PostMethod postMethod = new PostMethod(String.format(permitDownloadUrl, userName, password));
|
||||
byte[] b = soapRequestData.getBytes("utf-8");
|
||||
InputStream contentis = new ByteArrayInputStream(b, 0, b.length);
|
||||
//这里用 text/xml 或者 application/xml,与soap版本有关
|
||||
RequestEntity re = new InputStreamRequestEntity(contentis, b.length, "application/xml; charset=utf-8");
|
||||
postMethod.setRequestEntity(re);
|
||||
try (CloseableHttpClient client = HttpClients.createDefault()) {
|
||||
HttpPost postMethod = new HttpPost(String.format(permitDownloadUrl, userName, password));
|
||||
postMethod.setHeader("Content-Type", "application/xml; charset=utf-8");
|
||||
postMethod.setEntity(new StringEntity(soapRequestData, StandardCharsets.UTF_8));
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
int statusCode = httpClient.executeMethod(postMethod);
|
||||
String soapResponseData = postMethod.getResponseBodyAsString();
|
||||
//200说明正常返回数据
|
||||
if (statusCode == 200) {
|
||||
log.info("{}异地流转行政许可请求下载接口,返回结果:{}", uploadDateto,soapResponseData);
|
||||
int z = soapResponseData.indexOf("<ns1:return>");
|
||||
int j = soapResponseData.indexOf("</ns1:return>");
|
||||
returnStr = soapResponseData.substring(z + "<ns1:return>".length(), j);
|
||||
} else {
|
||||
log.info("{}异地流转行政许可请求下载接口失败,状态值:{}",uploadDateto ,statusCode);
|
||||
CloseableHttpResponse response = client.execute(postMethod);
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
String soapResponseData = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
|
||||
//200说明正常返回数据
|
||||
if (statusCode == 200) {
|
||||
log.info("{}异地流转行政许可请求下载接口,返回结果:{}", uploadDateto, soapResponseData);
|
||||
int z = soapResponseData.indexOf("<ns1:return>");
|
||||
int j = soapResponseData.indexOf("</ns1:return>");
|
||||
returnStr = soapResponseData.substring(z + "<ns1:return>".length(), j);
|
||||
} else {
|
||||
log.info("{}异地流转行政许可请求下载接口失败,状态值:{}", uploadDateto, statusCode);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
|
|
@ -2,19 +2,25 @@ package com.chinaweal.aiccs.crgs.transfor.sdk;
|
|||
|
||||
import cn.hutool.core.codec.Base64Encoder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.RequestEntity;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.cxf.aegis.databinding.AegisDatabinding;
|
||||
import org.apache.cxf.frontend.ClientProxyFactoryBean;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
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.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.activation.FileDataSource;
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author <a href="https://blog.lroyia.top">lroyia</a>
|
||||
|
|
@ -79,16 +85,14 @@ public class UploadSDK {
|
|||
" </upl:uploadCreditInfoByCase>\n" +
|
||||
" </soapenv:Body>\n" +
|
||||
"</soapenv:Envelope>";
|
||||
try {
|
||||
PostMethod postMethod = new PostMethod(String.format(uploadUrl, userName, password));
|
||||
byte[] b = str.getBytes("utf-8");
|
||||
InputStream is = new ByteArrayInputStream(b, 0, b.length);
|
||||
try (CloseableHttpClient client = HttpClients.createDefault()){
|
||||
HttpPost postMethod = new HttpPost(String.format(uploadUrl, userName, password));
|
||||
postMethod.setHeader("Content-Type", "text/xml; charset=utf-8");
|
||||
|
||||
RequestEntity re = new InputStreamRequestEntity(is, b.length, "text/xml; charset=utf-8");
|
||||
postMethod.setRequestEntity(re);
|
||||
HttpClient httpClient = new HttpClient();
|
||||
int statusCode = httpClient.executeMethod(postMethod);
|
||||
String soapResponseData = postMethod.getResponseBodyAsString();
|
||||
postMethod.setEntity(new StringEntity(str));
|
||||
CloseableHttpResponse execute = client.execute(postMethod);
|
||||
int statusCode = execute.getStatusLine().getStatusCode();
|
||||
String soapResponseData = EntityUtils.toString(execute.getEntity(), StandardCharsets.UTF_8);
|
||||
//200说明正常返回数据
|
||||
if (statusCode == 200) {
|
||||
log.info("{}异地流转行政处罚上传接口,返回结果:{}", filePath, soapResponseData);
|
||||
|
|
@ -99,7 +103,7 @@ public class UploadSDK {
|
|||
log.info("{}异地流转行政处罚上传接口,状态值:{}", filePath, statusCode);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("上传报错", e);
|
||||
}
|
||||
return fileStr;
|
||||
}
|
||||
|
|
@ -148,16 +152,13 @@ public class UploadSDK {
|
|||
" </upl:uploadCreditInfoByPermit>\n" +
|
||||
" </soapenv:Body>\n" +
|
||||
"</soapenv:Envelope>";
|
||||
try {
|
||||
PostMethod postMethod = new PostMethod(String.format(uploadUrl, userName, password));
|
||||
byte[] b = str.getBytes("utf-8");
|
||||
InputStream is = new ByteArrayInputStream(b, 0, b.length);
|
||||
|
||||
RequestEntity re = new InputStreamRequestEntity(is, b.length, "text/xml; charset=utf-8");
|
||||
postMethod.setRequestEntity(re);
|
||||
HttpClient httpClient = new HttpClient();
|
||||
int statusCode = httpClient.executeMethod(postMethod);
|
||||
String soapResponseData = postMethod.getResponseBodyAsString();
|
||||
try (CloseableHttpClient client = HttpClients.createDefault()){
|
||||
HttpPost postMethod = new HttpPost(String.format(uploadUrl, userName, password));
|
||||
postMethod.setHeader("Content-Type", "text/xml; charset=utf-8");
|
||||
postMethod.setEntity(new StringEntity(str));
|
||||
CloseableHttpResponse response = client.execute(postMethod);
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
String soapResponseData = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
|
||||
//200说明正常返回数据
|
||||
if (statusCode == 200) {
|
||||
log.info("{}异地流转行政处罚上传接口,返回结果:{}", filePath, soapResponseData);
|
||||
|
|
|
|||
Loading…
Reference in New Issue