|
@@ -10,6 +10,7 @@ import java.nio.charset.Charset;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import cn.newfeifan.mall.framework.common.exception.ErrorCode;
|
|
|
import lombok.Setter;
|
|
|
import org.apache.commons.httpclient.HttpClient;
|
|
|
import org.apache.commons.httpclient.methods.PostMethod;
|
|
@@ -17,6 +18,8 @@ import org.apache.commons.httpclient.methods.StringRequestEntity;
|
|
|
import org.apache.commons.httpclient.params.HttpMethodParams;
|
|
|
import org.apache.commons.httpclient.protocol.Protocol;
|
|
|
|
|
|
+import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* @author Administrator
|
|
@@ -55,7 +58,8 @@ public class FuiouHttpPoster {
|
|
|
try {
|
|
|
postMethod.setRequestEntity(new StringRequestEntity(body,"application/json","UTF-8"));
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ ErrorCode err = new ErrorCode(1, e.getMessage());
|
|
|
+ throw exception(err);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -119,13 +123,15 @@ public class FuiouHttpPoster {
|
|
|
Protocol.unregisterProtocol("https");
|
|
|
return responseString;
|
|
|
} catch (IOException ex2) {
|
|
|
- ex2.printStackTrace();
|
|
|
- System.out.println("报文发送到[" + url + "]失败:" + ex2.getMessage());
|
|
|
- throw new Exception("报文发送异常");
|
|
|
+ ErrorCode err = new ErrorCode(1, ex2.getMessage());
|
|
|
+// throw exception(err);
|
|
|
+// System.out.println("报文发送到[" + url + "]失败:" + ex2.getMessage());
|
|
|
+// throw new Exception("报文发送异常");
|
|
|
} catch (Exception ex) {
|
|
|
- ex.printStackTrace();
|
|
|
- System.out.println("报文发送到[" + url + "]失败:" + ex.getMessage());
|
|
|
- throw new Exception("报文发送异常");
|
|
|
+ ErrorCode err = new ErrorCode(1, ex.getMessage());
|
|
|
+ throw exception(err);
|
|
|
+// System.out.println("报文发送到[" + url + "]失败:" + ex.getMessage());
|
|
|
+// throw new Exception("报文发送异常");
|
|
|
} finally {
|
|
|
try {
|
|
|
if(xmlpost != null)
|
|
@@ -133,9 +139,12 @@ public class FuiouHttpPoster {
|
|
|
if(httpclient != null)
|
|
|
httpclient.getHttpConnectionManager().closeIdleConnections(0);
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ ErrorCode err = new ErrorCode(1, e.getMessage());
|
|
|
+ throw exception(err);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|