|
|
@@ -26,7 +26,7 @@ public class HttpClientUtil {
|
|
|
* @param data
|
|
|
* @return
|
|
|
*/
|
|
|
- public static JSONObject sendPOST(String apiUrl, String data) {
|
|
|
+ public static JSONObject sendPOST(String apiUrl, String data) throws Exception{
|
|
|
StringBuffer strBuffer = null;
|
|
|
JSONObject obj = null;
|
|
|
try {
|
|
|
@@ -70,15 +70,13 @@ public class HttpClientUtil {
|
|
|
MessageFormat.format("POST请求失败,失败原因: Http状态码 = {0} , {1}", http_StatusCode,
|
|
|
http_ResponseMessage));
|
|
|
}
|
|
|
- } catch (MalformedURLException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw e;
|
|
|
}
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
- public static JSONObject sendPOST(String apiUrl) {
|
|
|
+ public static JSONObject sendPOST(String apiUrl) throws Exception {
|
|
|
StringBuffer strBuffer = null;
|
|
|
JSONObject obj = null;
|
|
|
try {
|
|
|
@@ -116,15 +114,13 @@ public class HttpClientUtil {
|
|
|
MessageFormat.format("POST请求失败,失败原因: Http状态码 = {0} , {1}", http_StatusCode,
|
|
|
http_ResponseMessage));
|
|
|
}
|
|
|
- } catch (MalformedURLException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw e;
|
|
|
}
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
- public static JSONObject sendPOSTWithHeader(String apiUrl, String data, Map<String, String> map) {
|
|
|
+ public static JSONObject sendPOSTWithHeader(String apiUrl, String data, Map<String, String> map) throws Exception {
|
|
|
StringBuffer strBuffer = null;
|
|
|
JSONObject obj = null;
|
|
|
try {
|
|
|
@@ -169,15 +165,13 @@ public class HttpClientUtil {
|
|
|
MessageFormat.format("POST请求失败,失败原因: Http状态码 = {0} , {1}", http_StatusCode,
|
|
|
http_ResponseMessage));
|
|
|
}
|
|
|
- } catch (MalformedURLException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw e;
|
|
|
}
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
- public static String sendOaGET_USERNAME(String apiUrl) {
|
|
|
+ public static String sendOaGET_USERNAME(String apiUrl) throws Exception{
|
|
|
StringBuffer strBuffer = null;
|
|
|
String obj = null;
|
|
|
try {
|
|
|
@@ -218,15 +212,13 @@ public class HttpClientUtil {
|
|
|
MessageFormat.format("GET请求失败,失败信息:Http状态码 = {0} , {1}", http_StatusCode,
|
|
|
http_ResponseMessage));
|
|
|
}
|
|
|
- } catch (MalformedURLException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw e;
|
|
|
}
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
- public static JSONArray sendGETWithHeader_Arr(String apiUrl, Map<String, String> map) {
|
|
|
+ public static JSONArray sendGETWithHeader_Arr(String apiUrl, Map<String, String> map) throws Exception{
|
|
|
StringBuffer strBuffer = null;
|
|
|
JSONArray obj = null;
|
|
|
try {
|
|
|
@@ -268,15 +260,13 @@ public class HttpClientUtil {
|
|
|
MessageFormat.format("GET请求失败,失败信息:Http状态码 = {0} , {1}", http_StatusCode,
|
|
|
http_ResponseMessage));
|
|
|
}
|
|
|
- } catch (MalformedURLException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw e;
|
|
|
}
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
- public static JSONObject sendGETWithHeader_Obj(String apiUrl, Map<String, String> map) {
|
|
|
+ public static JSONObject sendGETWithHeader_Obj(String apiUrl, Map<String, String> map) throws Exception{
|
|
|
StringBuffer strBuffer = null;
|
|
|
JSONObject obj = null;
|
|
|
try {
|
|
|
@@ -318,16 +308,14 @@ public class HttpClientUtil {
|
|
|
MessageFormat.format("GET请求失败,失败信息:Http状态码 = {0} , {1}", http_StatusCode,
|
|
|
http_ResponseMessage));
|
|
|
}
|
|
|
- } catch (MalformedURLException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw e;
|
|
|
}
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
public static void sendGETWithHeader_OutputStream(String apiUrl, Map<String, String> map,
|
|
|
- HttpServletRequest request,HttpServletResponse response, String fileName) {
|
|
|
+ HttpServletRequest request,HttpServletResponse response, String fileName)throws Exception {
|
|
|
int byteread = 0;
|
|
|
try {
|
|
|
// 建立连接
|
|
|
@@ -374,10 +362,8 @@ public class HttpClientUtil {
|
|
|
http_ResponseMessage));
|
|
|
}
|
|
|
|
|
|
- } catch (MalformedURLException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw e;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -386,7 +372,7 @@ public class HttpClientUtil {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public static JSONObject sendGET(String apiUrl) {
|
|
|
+ public static JSONObject sendGET(String apiUrl) throws Exception{
|
|
|
StringBuffer strBuffer = null;
|
|
|
JSONObject obj = null;
|
|
|
try {
|
|
|
@@ -427,10 +413,8 @@ public class HttpClientUtil {
|
|
|
MessageFormat.format("GET请求失败,失败信息:Http状态码 = {0} , {1}", http_StatusCode,
|
|
|
http_ResponseMessage));
|
|
|
}
|
|
|
- } catch (MalformedURLException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw e;
|
|
|
}
|
|
|
return obj;
|
|
|
}
|