From e163cf4d202e7fe8fb35e29999eeb53e4f525a71 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Thu, 6 Jul 2023 15:18:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=B5=B7=E5=BA=B7=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E5=9C=A8address=E5=AD=97=E6=AE=B5=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84<=E6=88=96>=E7=A0=B4=E5=9D=8Fxml?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E7=9A=84=E6=83=85=E5=86=B5=EF=BC=8C=20#903?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/SIPRequestProcessorParent.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java index 0a7eb2c9..d52f4f6a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java @@ -199,7 +199,24 @@ public abstract class SIPRequestProcessorParent { Byte[] bytes = new Byte[0]; byte[] bytesResult = ArrayUtils.toPrimitive(result.toArray(bytes)); - Document xml = reader.read(new ByteArrayInputStream(bytesResult)); + Document xml; + try { + xml = reader.read(new ByteArrayInputStream(bytesResult)); + }catch (DocumentException e) { + logger.warn("[xml解析异常]: 愿文如下: \r\n{}", new String(bytesResult)); + logger.warn("[xml解析异常]: 愿文如下: 尝试兼容性处理"); + String[] xmlLineArray = new String(bytesResult).split("\\r?\\n"); + + // 兼容海康的address字段带有<破换xml结构导致无法解析xml的问题 + StringBuilder stringBuilder = new StringBuilder(); + for (String s : xmlLineArray) { + if (s.startsWith("