From 849e8b6601c0e08b84833114cc1d8f3e39e4f0a0 Mon Sep 17 00:00:00 2001 From: "haoeliu@foxmail.com" Date: Wed, 15 Mar 2023 15:29:56 +0800 Subject: [PATCH] add packing logic of heaader.response --- .../bdware/sc/engine/hook/DOOPAfterExecHandler.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/bdware/sc/engine/hook/DOOPAfterExecHandler.java b/src/main/java/org/bdware/sc/engine/hook/DOOPAfterExecHandler.java index db35a9b..3bcf474 100644 --- a/src/main/java/org/bdware/sc/engine/hook/DOOPAfterExecHandler.java +++ b/src/main/java/org/bdware/sc/engine/hook/DOOPAfterExecHandler.java @@ -3,10 +3,7 @@ package org.bdware.sc.engine.hook; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import org.bdware.doip.codec.doipMessage.DoipMessage; -import org.bdware.doip.codec.doipMessage.DoipMessageFactory; -import org.bdware.doip.codec.doipMessage.DoipResponseCode; -import org.bdware.doip.codec.doipMessage.MessageHeader; +import org.bdware.doip.codec.doipMessage.*; import org.bdware.doip.codec.operations.BasicOperations; import org.bdware.sc.JSEngine; import org.bdware.sc.bean.ContractRequest; @@ -76,6 +73,12 @@ public class DOOPAfterExecHandler implements AnnotationHook { // 和HTTP一样,所有需要的字段自己封装,校验规则也比较简单,这里只做简单的包装返回即可!!! if(header != null) { originDoipMsg.header = JsonUtil.fromJson(header, MessageHeader.class); + // response字段根据白皮书上的规定,处于header下,人为包装到parameters的response中 + String headerRespCode = header.get("response") != null ? header.get("response").getAsString() : null; + if(headerRespCode != null) { + if (originDoipMsg.header.parameters == null) originDoipMsg.header.parameters = new HeaderParameter(null, null); + originDoipMsg.header.parameters.response = DoipResponseCode.valueOf(headerRespCode); + } } if(body != null) {