From 7cdbbe9f217f2c54a7a09cce42ad5364da1e9852 Mon Sep 17 00:00:00 2001 From: "zhanglei@ap-leasing.com.cn" Date: Wed, 20 Sep 2023 18:06:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A3=8E=E6=8E=A7=E4=B8=AD=E5=8F=B0-=E4=BF=AE?= =?UTF-8?q?=E6=94=B9esb=E6=8A=A5=E6=96=87=E5=91=BD=E5=90=8D=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=EF=BC=9B=E7=94=B1=E4=BA=8Eesb=E5=A4=96=E8=81=94?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E5=8D=87=E7=BA=A7=EF=BC=8C=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E4=B9=B1=E7=A0=81=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?esb=E8=BF=94=E5=9B=9E=E6=8A=A5=E6=96=87=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/baic.properties | 2 +- src/com/ample/esb/common/EsbCommon.java | 11 +++++------ src/com/ample/esb/controller/AfsResultServlet.java | 6 ++++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/config/baic.properties b/config/baic.properties index 5f20012c1..61c778c81 100644 --- a/config/baic.properties +++ b/config/baic.properties @@ -4,7 +4,7 @@ userid=TYJWBY7F AFS012_serviceid=N9LZG7J8OXSD90B4 AMP005_serviceid=24LITXVE9LKXANTD -log_path=D:/tmp/esb/log/ +log_path=/data/esb/log/ ## 反欺诈 afs_url=http://test-antifraud.baicfc.com/Instinct.UI.WebClient_5.3.1_2023/api/redirect? diff --git a/src/com/ample/esb/common/EsbCommon.java b/src/com/ample/esb/common/EsbCommon.java index 1947592aa..b6f90f57c 100644 --- a/src/com/ample/esb/common/EsbCommon.java +++ b/src/com/ample/esb/common/EsbCommon.java @@ -25,7 +25,6 @@ import org.apache.http.util.EntityUtils; import org.bouncycastle.crypto.digests.SM3Digest; import java.io.IOException; -import java.nio.charset.StandardCharsets; public class EsbCommon implements EsbServise { public Transaction createEsbTransaction() { @@ -96,8 +95,8 @@ public class EsbCommon implements EsbServise { HttpResponse response = client.execute(httppost); if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK){ result = EntityUtils.toString(response.getEntity()); - byte[] xmlByte = result.getBytes(StandardCharsets.ISO_8859_1); - result = new String(xmlByte,"utf-8"); + // byte[] xmlByte = result.getBytes(StandardCharsets.ISO_8859_1); + // result = new String(xmlByte,"utf-8"); System.out.println("ESB响应报文:\n"+result); } } catch (IOException e) { @@ -120,13 +119,13 @@ public class EsbCommon implements EsbServise { } @Override public Transaction transactionDo(){ - String logPath = BaicPropertiesUtil.get("log_path"); //.创建实体类 Transaction tranRequest = createEsbTransaction(); + String logPath = BaicPropertiesUtil.get("log_path")+tranRequest.getMessageEsbHead().getTranCode()+"_"+tranRequest.getMessageEsbHead().getGlobalSeqNo(); //.转换为xml请求报文 String xmlRrquest = XstreamUtil.xmlConvert(tranRequest); //.将xml请求报文存为文件 - FileUtil.writeFile(logPath+tranRequest.getMessageEsbHead().getGlobalSeqNo()+"_request.txt", xmlRrquest); + FileUtil.writeFile(logPath + "_request.txt", xmlRrquest); //.保存请求信息 saveEsbLog(tranRequest); //.获得url @@ -134,7 +133,7 @@ public class EsbCommon implements EsbServise { //.得到响应报文 String xmlResopnse= this.httpSend(url,xmlRrquest); //.将xml响应报文存为文件 - FileUtil.writeFile(logPath+tranRequest.getMessageEsbHead().getGlobalSeqNo()+"_response.txt", xmlResopnse); + FileUtil.writeFile(logPath+"_response.txt", xmlResopnse); //.转换为实体类 Transaction tranResponse = (Transaction)XstreamUtil.objectConvert(xmlResopnse); //.更新响应信息 diff --git a/src/com/ample/esb/controller/AfsResultServlet.java b/src/com/ample/esb/controller/AfsResultServlet.java index 478805b89..9bc0b7382 100644 --- a/src/com/ample/esb/controller/AfsResultServlet.java +++ b/src/com/ample/esb/controller/AfsResultServlet.java @@ -58,8 +58,10 @@ public class AfsResultServlet extends HttpServlet { Transaction tran = (Transaction)XstreamUtil.objectConvert(requestXml); String logPath = BaicPropertiesUtil.get("log_path"); String globalSeqNo = tran.getMessageEsbHead().getGlobalSeqNo(); + String tranCode = tran.getMessageEsbHead().getTranCode(); String projectNo = tran.getMessageBody().getAfsResultRequest().getApplyNo(); - FileUtil.writeFile(logPath + projectNo +"_"+ globalSeqNo +"_request.txt", requestXml); + String filePath = logPath + tranCode + "_" + projectNo +"_"+ globalSeqNo; + FileUtil.writeFile( filePath + "_request.txt", requestXml); String fraudAlert = tran.getMessageBody().getAfsResultRequest().getFraudAlert(); String actionTaken = tran.getMessageBody().getAfsResultRequest().getActionTaken(); @@ -103,7 +105,7 @@ public class AfsResultServlet extends HttpServlet { appHead.setTargetTranTime(DateUtils.TimeNowAccurate()); String responseXml = XstreamUtil.xmlConvert(tran); - FileUtil.writeFile(logPath + projectNo +"_"+ globalSeqNo + RetCommStatus +"_response.txt", responseXml); + FileUtil.writeFile(filePath + "_response.txt", responseXml); return responseXml;