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 990e788b..bfc7e23b 100755 --- 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 @@ -170,10 +170,14 @@ public abstract class SIPRequestProcessorParent { } public Element getRootElement(RequestEvent evt, String charset) throws DocumentException { + byte[] rawContent = evt.getRequest().getRawContent(); + if (rawContent == null) { + return null; + } + if (charset == null) { charset = "gb2312"; } - Request request = evt.getRequest(); SAXReader reader = new SAXReader(); reader.setEncoding(charset); // 对海康出现的未转义字符做处理。 @@ -182,10 +186,6 @@ public abstract class SIPRequestProcessorParent { char despChar = '&'; byte destBye = (byte) despChar; List result = new ArrayList<>(); - byte[] rawContent = request.getRawContent(); - if (rawContent == null) { - return null; - } for (int i = 0; i < rawContent.length; i++) { if (rawContent[i] == destBye) { boolean resul = false; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index 39d04c13..acdff1ce 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -68,6 +68,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme Element rootElement = getRootElement(evt); if (rootElement == null) { log.error("处理SUBSCRIBE请求 未获取到消息体{}", evt.getRequest()); + responseAck(request, Response.BAD_REQUEST); return; } String cmd = XmlUtil.getText(rootElement, "CmdType"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java index 8ad042bb..237eab16 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java @@ -102,11 +102,6 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement sipEvent.getErrorEvent().response(eventResult); } }else { - byte[] rawContent = request.getRawContent(); - if (rawContent == null) { - responseAck(request, Response.BAD_REQUEST, "content is null"); - return; - } Element rootElement; try { rootElement = getRootElement(evt);