金山WPS在线编辑
This commit is contained in:
@ -10,7 +10,6 @@ import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentDetail;
|
|||||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentEntity;
|
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentEntity;
|
||||||
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.UploadObject;
|
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.UploadObject;
|
||||||
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.SecurityEntity;
|
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.SecurityEntity;
|
||||||
import com.chinaunicom.mall.ebtp.cloud.userinfo.starter.client.UnifastOAuthClient;
|
|
||||||
import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService;
|
import com.chinaunicom.mall.ebtp.common.base.service.IBaseCacheUserService;
|
||||||
import com.chinaunicom.mall.ebtp.common.exception.common.CommonExceptionEnum;
|
import com.chinaunicom.mall.ebtp.common.exception.common.CommonExceptionEnum;
|
||||||
import com.chinaunicom.mall.ebtp.common.log.OperationLogDetail;
|
import com.chinaunicom.mall.ebtp.common.log.OperationLogDetail;
|
||||||
@ -28,11 +27,11 @@ import com.chinaunicom.mall.ebtp.extend.wps.entity.KingSoftWpsRet;
|
|||||||
import com.chinaunicom.mall.ebtp.extend.wps.entity.KingSoftWpsVo;
|
import com.chinaunicom.mall.ebtp.extend.wps.entity.KingSoftWpsVo;
|
||||||
import com.chinaunicom.mall.ebtp.extend.wps.enums.WpsExceptionEnum;
|
import com.chinaunicom.mall.ebtp.extend.wps.enums.WpsExceptionEnum;
|
||||||
import com.chinaunicom.mall.ebtp.extend.wps.service.WpsService;
|
import com.chinaunicom.mall.ebtp.extend.wps.service.WpsService;
|
||||||
|
import com.chinaunicom.mall.ebtp.extend.wps.util.HttpUtils;
|
||||||
import com.chinaunicom.mall.ebtp.extend.wps.util.HttpsUtils;
|
import com.chinaunicom.mall.ebtp.extend.wps.util.HttpsUtils;
|
||||||
import com.chinaunicom.mall.ebtp.extend.wps.util.MdConstants;
|
import com.chinaunicom.mall.ebtp.extend.wps.util.MdConstants;
|
||||||
import com.chinaunicom.mall.ebtp.extend.wps.vo.*;
|
import com.chinaunicom.mall.ebtp.extend.wps.vo.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import lombok.val;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@ -503,8 +502,8 @@ public class WpsServiceImpl implements WpsService {
|
|||||||
vo.setStaffCode("ebtp");
|
vo.setStaffCode("ebtp");
|
||||||
vo.setFileKey(in.getFileId());
|
vo.setFileKey(in.getFileId());
|
||||||
String fileName = in.getFileName();
|
String fileName = in.getFileName();
|
||||||
vo.setFillName(fileName);
|
vo.setFillName(fileName.substring(0,fileName.lastIndexOf(".")));
|
||||||
vo.setFillExtension(fileName.substring(fileName.lastIndexOf("."),fileName.length()));
|
vo.setFillExtension(fileName.substring(fileName.lastIndexOf(".")+1,fileName.length()));
|
||||||
vo.setVersion(1);
|
vo.setVersion(1);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -524,8 +523,10 @@ public class WpsServiceImpl implements WpsService {
|
|||||||
vo.setHost(kswhost);
|
vo.setHost(kswhost);
|
||||||
vo.setLastModifiedTime(time);
|
vo.setLastModifiedTime(time);
|
||||||
|
|
||||||
String json = JSON.toJSONString(vo);
|
Map<String,Object> map = JSON.parseObject(JSON.toJSONString(vo), Map.class);
|
||||||
String retJson = HttpsUtils.httpPost(kswpsurl,json);
|
String retJson = HttpsUtils.UrlPost(kswpsurl, "utf-8", map);//httpPost(kswpsurl,json);
|
||||||
|
|
||||||
|
//String retJson = HttpUtils.httpPost(kswpsurl,json);
|
||||||
|
|
||||||
KingSoftWpsRet ret = JSON.parseObject(retJson,KingSoftWpsRet.class);
|
KingSoftWpsRet ret = JSON.parseObject(retJson,KingSoftWpsRet.class);
|
||||||
|
|
||||||
|
@ -0,0 +1,144 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.wps.util;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import javax.net.ssl.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.Proxy;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class HttpUtils {
|
||||||
|
|
||||||
|
public static String httpGet(String path) {
|
||||||
|
String str = "";
|
||||||
|
try {
|
||||||
|
URL url = new URL(path);
|
||||||
|
//打开和url之间的连接
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
PrintWriter out = null;
|
||||||
|
|
||||||
|
/**设置URLConnection的参数和普通的请求属性****start***/
|
||||||
|
|
||||||
|
conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
|
||||||
|
conn.setRequestProperty("Accept", "application/json");
|
||||||
|
conn.setRequestProperty("Accept-Encoding", "");
|
||||||
|
|
||||||
|
/**设置URLConnection的参数和普通的请求属性****end***/
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
conn.setDoInput(true);
|
||||||
|
|
||||||
|
//conn.setRequestMethod("POST");//GET和POST必须全大写
|
||||||
|
/**GET方法请求*****start*/
|
||||||
|
/**
|
||||||
|
* 如果只是发送GET方式请求,使用connet方法建立和远程资源之间的实际连接即可;
|
||||||
|
* 如果发送POST方式的请求,需要获取URLConnection实例对应的输出流来发送请求参数。
|
||||||
|
* */
|
||||||
|
conn.connect();
|
||||||
|
|
||||||
|
/**GET方法请求*****end*/
|
||||||
|
|
||||||
|
/***POST方法请求****start*/
|
||||||
|
// out = new PrintWriter(conn.getOutputStream());//获取URLConnection对象对应的输出流
|
||||||
|
//
|
||||||
|
// out.print(data);//发送请求参数即数据
|
||||||
|
//
|
||||||
|
// out.flush();//缓冲数据
|
||||||
|
|
||||||
|
/***POST方法请求****end*/
|
||||||
|
|
||||||
|
//获取URLConnection对象对应的输入流
|
||||||
|
InputStream is = conn.getInputStream();
|
||||||
|
//构造一个字符流缓存
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||||
|
|
||||||
|
String line = br.readLine();
|
||||||
|
while (line != null) {
|
||||||
|
str = new String(line.getBytes(), "UTF-8");//解决中文乱码问题
|
||||||
|
System.out.println(str);
|
||||||
|
line = br.readLine();
|
||||||
|
}
|
||||||
|
//关闭流
|
||||||
|
is.close();
|
||||||
|
//断开连接,最好写上,disconnect是在底层tcp socket链接空闲时才切断。如果正在被其他线程使用就不切断。
|
||||||
|
//固定多线程的话,如果不disconnect,链接会增多,直到收发不出信息。写上disconnect后正常一些。
|
||||||
|
conn.disconnect();
|
||||||
|
//System.out.println("完整结束");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("错误信息",e);
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
public static String httpPost(String path,String data) {
|
||||||
|
String str = "";
|
||||||
|
try {
|
||||||
|
log.info("path:"+path);
|
||||||
|
log.info("data:"+data);
|
||||||
|
URL url = new URL(path);
|
||||||
|
|
||||||
|
//打开和url之间的连接
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
PrintWriter out = null;
|
||||||
|
|
||||||
|
/**设置URLConnection的参数和普通的请求属性****start***/
|
||||||
|
|
||||||
|
conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
|
||||||
|
conn.setRequestProperty("Accept", "application/json");
|
||||||
|
conn.setRequestProperty("Accept-Encoding", "");
|
||||||
|
|
||||||
|
/**设置URLConnection的参数和普通的请求属性****end***/
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
conn.setDoInput(true);
|
||||||
|
|
||||||
|
conn.setRequestMethod("POST");//GET和POST必须全大写
|
||||||
|
/**GET方法请求*****start*/
|
||||||
|
/**
|
||||||
|
* 如果只是发送GET方式请求,使用connet方法建立和远程资源之间的实际连接即可;
|
||||||
|
* 如果发送POST方式的请求,需要获取URLConnection实例对应的输出流来发送请求参数。
|
||||||
|
* */
|
||||||
|
conn.connect();
|
||||||
|
|
||||||
|
/**GET方法请求*****end*/
|
||||||
|
|
||||||
|
/***POST方法请求****start*/
|
||||||
|
out = new PrintWriter(conn.getOutputStream());//获取URLConnection对象对应的输出流
|
||||||
|
|
||||||
|
out.print(data);//发送请求参数即数据
|
||||||
|
|
||||||
|
out.flush();//缓冲数据
|
||||||
|
|
||||||
|
/***POST方法请求****end*/
|
||||||
|
|
||||||
|
//获取URLConnection对象对应的输入流
|
||||||
|
InputStream is = conn.getInputStream();
|
||||||
|
//构造一个字符流缓存
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||||
|
|
||||||
|
String line = br.readLine();
|
||||||
|
while (line != null) {
|
||||||
|
str = new String(line.getBytes(), "UTF-8");//解决中文乱码问题
|
||||||
|
System.out.println(str);
|
||||||
|
line = br.readLine();
|
||||||
|
}
|
||||||
|
//关闭流
|
||||||
|
is.close();
|
||||||
|
//断开连接,最好写上,disconnect是在底层tcp socket链接空闲时才切断。如果正在被其他线程使用就不切断。
|
||||||
|
//固定多线程的话,如果不disconnect,链接会增多,直到收发不出信息。写上disconnect后正常一些。
|
||||||
|
conn.disconnect();
|
||||||
|
//System.out.println("完整结束");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("错误信息",e);
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package com.chinaunicom.mall.ebtp.extend.wps.util;
|
package com.chinaunicom.mall.ebtp.extend.wps.util;
|
||||||
|
|
||||||
|
import cn.hutool.http.ssl.TrustAnyHostnameVerifier;
|
||||||
|
import com.chinaunicom.mall.ebtp.common.exception.common.CommonExceptionEnum;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import javax.net.ssl.*;
|
import javax.net.ssl.*;
|
||||||
@ -18,105 +20,47 @@ import java.util.Map;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class HttpsUtils {
|
public class HttpsUtils {
|
||||||
|
|
||||||
public static String httpGet(String path) {
|
public static String UrlPost(String url,String charSet, Map map){
|
||||||
|
return UrlPost(url,charSet,map,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String UrlPost(String url,String charSet, Map map,Proxy proxy){
|
||||||
String str = "";
|
String str = "";
|
||||||
try {
|
try {
|
||||||
URL url = new URL(path);
|
SSLContext sc = SSLContext.getInstance("SSL");
|
||||||
//打开和url之间的连接
|
sc.init(null, new TrustManager[]{new TrustAnyTrustManager()}, new java.security.SecureRandom());
|
||||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
URL console = new URL(url);
|
||||||
PrintWriter out = null;
|
|
||||||
|
|
||||||
/**设置URLConnection的参数和普通的请求属性****start***/
|
// StringBuffer postData = new StringBuffer();
|
||||||
|
|
||||||
conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
|
|
||||||
conn.setRequestProperty("Accept", "application/json");
|
|
||||||
conn.setRequestProperty("Accept-Encoding", "");
|
|
||||||
|
|
||||||
/**设置URLConnection的参数和普通的请求属性****end***/
|
|
||||||
conn.setDoOutput(true);
|
|
||||||
conn.setDoInput(true);
|
|
||||||
|
|
||||||
//conn.setRequestMethod("POST");//GET和POST必须全大写
|
|
||||||
/**GET方法请求*****start*/
|
|
||||||
/**
|
|
||||||
* 如果只是发送GET方式请求,使用connet方法建立和远程资源之间的实际连接即可;
|
|
||||||
* 如果发送POST方式的请求,需要获取URLConnection实例对应的输出流来发送请求参数。
|
|
||||||
* */
|
|
||||||
conn.connect();
|
|
||||||
|
|
||||||
/**GET方法请求*****end*/
|
|
||||||
|
|
||||||
/***POST方法请求****start*/
|
|
||||||
// out = new PrintWriter(conn.getOutputStream());//获取URLConnection对象对应的输出流
|
|
||||||
//
|
//
|
||||||
// out.print(data);//发送请求参数即数据
|
// Iterator it = map.entrySet().iterator();
|
||||||
//
|
// while (it.hasNext()) {
|
||||||
// out.flush();//缓冲数据
|
// Map.Entry pairs = (Map.Entry) it.next();
|
||||||
|
// postData.append(pairs.getKey()).append("=")
|
||||||
/***POST方法请求****end*/
|
// .append(URLEncoder.encode(pairs != null && pairs.getValue() != null ? pairs.getValue().toString() : "", charSet)).append("&");
|
||||||
|
// }
|
||||||
//获取URLConnection对象对应的输入流
|
// System.out.println("请求参数:" + postData);
|
||||||
InputStream is = conn.getInputStream();
|
System.out.println("请求参数:" + map);
|
||||||
//构造一个字符流缓存
|
HttpsURLConnection conn = null;
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
if (proxy != null) {
|
||||||
|
System.out.println("proxy信息=======:" + proxy);
|
||||||
String line = br.readLine();
|
conn = (HttpsURLConnection) console.openConnection(proxy);
|
||||||
while (line != null) {
|
} else {
|
||||||
str = new String(line.getBytes(), "UTF-8");//解决中文乱码问题
|
conn = (HttpsURLConnection) console.openConnection();
|
||||||
System.out.println(str);
|
|
||||||
line = br.readLine();
|
|
||||||
}
|
}
|
||||||
//关闭流
|
|
||||||
is.close();
|
|
||||||
//断开连接,最好写上,disconnect是在底层tcp socket链接空闲时才切断。如果正在被其他线程使用就不切断。
|
|
||||||
//固定多线程的话,如果不disconnect,链接会增多,直到收发不出信息。写上disconnect后正常一些。
|
|
||||||
conn.disconnect();
|
|
||||||
//System.out.println("完整结束");
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("错误信息",e);
|
|
||||||
//e.printStackTrace();
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
public static String httpPost(String path,String data) {
|
|
||||||
String str = "";
|
|
||||||
try {
|
|
||||||
log.info("path:"+path);
|
|
||||||
log.info("data:"+data);
|
|
||||||
URL url = new URL(path);
|
|
||||||
//打开和url之间的连接
|
|
||||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
||||||
PrintWriter out = null;
|
|
||||||
|
|
||||||
/**设置URLConnection的参数和普通的请求属性****start***/
|
conn.setSSLSocketFactory(sc.getSocketFactory());
|
||||||
|
conn.setHostnameVerifier(new TrustAnyHostnameVerifier());
|
||||||
|
|
||||||
conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
|
|
||||||
conn.setRequestProperty("Accept", "application/json");
|
|
||||||
conn.setRequestProperty("Accept-Encoding", "");
|
|
||||||
|
|
||||||
/**设置URLConnection的参数和普通的请求属性****end***/
|
|
||||||
conn.setDoOutput(true);
|
|
||||||
conn.setDoInput(true);
|
conn.setDoInput(true);
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
|
||||||
conn.setRequestMethod("POST");//GET和POST必须全大写
|
PrintWriter out = new PrintWriter(conn.getOutputStream());//获取URLConnection对象对应的输出流
|
||||||
/**GET方法请求*****start*/
|
|
||||||
/**
|
|
||||||
* 如果只是发送GET方式请求,使用connet方法建立和远程资源之间的实际连接即可;
|
|
||||||
* 如果发送POST方式的请求,需要获取URLConnection实例对应的输出流来发送请求参数。
|
|
||||||
* */
|
|
||||||
conn.connect();
|
|
||||||
|
|
||||||
/**GET方法请求*****end*/
|
out.print(map);//发送请求参数即数据
|
||||||
|
|
||||||
/***POST方法请求****start*/
|
|
||||||
out = new PrintWriter(conn.getOutputStream());//获取URLConnection对象对应的输出流
|
|
||||||
|
|
||||||
out.print(data);//发送请求参数即数据
|
|
||||||
|
|
||||||
out.flush();//缓冲数据
|
out.flush();//缓冲数据
|
||||||
|
|
||||||
/***POST方法请求****end*/
|
|
||||||
|
|
||||||
//获取URLConnection对象对应的输入流
|
//获取URLConnection对象对应的输入流
|
||||||
InputStream is = conn.getInputStream();
|
InputStream is = conn.getInputStream();
|
||||||
//构造一个字符流缓存
|
//构造一个字符流缓存
|
||||||
@ -133,11 +77,104 @@ public class HttpsUtils {
|
|||||||
//断开连接,最好写上,disconnect是在底层tcp socket链接空闲时才切断。如果正在被其他线程使用就不切断。
|
//断开连接,最好写上,disconnect是在底层tcp socket链接空闲时才切断。如果正在被其他线程使用就不切断。
|
||||||
//固定多线程的话,如果不disconnect,链接会增多,直到收发不出信息。写上disconnect后正常一些。
|
//固定多线程的话,如果不disconnect,链接会增多,直到收发不出信息。写上disconnect后正常一些。
|
||||||
conn.disconnect();
|
conn.disconnect();
|
||||||
//System.out.println("完整结束");
|
|
||||||
} catch (Exception e) {
|
// System.out.println("https连接信息======:" + conn);
|
||||||
|
// BufferedOutputStream hurlBufOus = new BufferedOutputStream(conn.getOutputStream());
|
||||||
|
//
|
||||||
|
// hurlBufOus.write(postData.toString().getBytes("iso8859-1"));// 这里面已经将RequestMethod设置为POST.前面设置无效
|
||||||
|
// hurlBufOus.flush();
|
||||||
|
|
||||||
|
// conn.connect();
|
||||||
|
// System.out.println("返回结果状态码:" + conn.getResponseCode());
|
||||||
|
// System.out.println("Set-COOKIE:" + conn.getHeaderField("Set-Cookie"));
|
||||||
|
// printHeaderFields(conn);
|
||||||
|
// InputStream in = conn.getInputStream();
|
||||||
|
//
|
||||||
|
// BufferedReader reader = new BufferedReader(new InputStreamReader(in, charSet));
|
||||||
|
//
|
||||||
|
// String line = reader.readLine();
|
||||||
|
// while (line != null) {
|
||||||
|
// str = new String(line.getBytes(), "UTF-8");//解决中文乱码问题
|
||||||
|
// System.out.println(str);
|
||||||
|
// line = reader.readLine();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// reader.close();
|
||||||
|
// in.close();
|
||||||
|
// conn.disconnect();
|
||||||
|
}catch (Exception e) {
|
||||||
log.error("错误信息",e);
|
log.error("错误信息",e);
|
||||||
//e.printStackTrace();
|
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("https请求异常", true);
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class TrustAnyTrustManager implements X509TrustManager {
|
||||||
|
@Override
|
||||||
|
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
|
return new X509Certificate[] {};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class TrustAnyHostnameVerifier implements HostnameVerifier {
|
||||||
|
@Override
|
||||||
|
public boolean verify(String hostname, SSLSession session) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void printHeaderFields(HttpsURLConnection conn) {
|
||||||
|
Map<String, List<String>> fields = conn.getHeaderFields();
|
||||||
|
Iterator<String> keys = fields.keySet().iterator();
|
||||||
|
System.out.println("------------heard print start --------------");
|
||||||
|
while (keys.hasNext()) {
|
||||||
|
String key = keys.next();
|
||||||
|
List<String> lists = fields.get(key);
|
||||||
|
System.out.println("---" + key + " = " + lists);
|
||||||
|
}
|
||||||
|
System.out.println("------------heard print end --------------");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String to2HttpPost(String path, Map<String,String> data) {
|
||||||
|
String str = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
URL url = new URL(path);
|
||||||
|
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
||||||
|
PrintWriter out = null;
|
||||||
|
conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
|
||||||
|
conn.setRequestProperty("Accept", "application/json");
|
||||||
|
conn.setRequestProperty("Accept-Encoding", "");
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
conn.setDoInput(true);
|
||||||
|
conn.setRequestMethod("POST");
|
||||||
|
out = new PrintWriter(conn.getOutputStream());
|
||||||
|
out.print(data);
|
||||||
|
out.flush();
|
||||||
|
InputStream is = conn.getInputStream();
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||||
|
|
||||||
|
for(String line = br.readLine(); line != null; line = br.readLine()) {
|
||||||
|
str = new String(line.getBytes(), "UTF-8");
|
||||||
|
System.out.println(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
is.close();
|
||||||
|
conn.disconnect();
|
||||||
|
} catch (Exception var9) {
|
||||||
|
var9.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user