Hapi xml解析器在使用Hapi Xml Parser编码HL7 v2.7消息时给出以下异常 .
ca.uhn.hl7v2.HL7Exception:无法对GenericMessage进行XML编码 . 消息必须具有已识别的结构 .
下面是我用于编码消息的代码片段
HapiContext context = new DefaultHapiContext(modelClassFactory)
PipeParser pipeParser = context.getPipeParser();
pipeParser.setValidationContext(new NoValidation());
pipeParser.getParserConfiguration().setAllowUnknownVersions(true);
Message msg = pipeParser.parse(document);
Parser xmlParser = context.getXMLParser();
return xmlParser.encode(msg);
有什么建议/解决方案吗?
1 回答
如果您尝试编码的消息没有特定类型但是为
GenericMessage
,则抛出此异常 . 似乎HAPI无法确定document
的正确消息类型 . 如果将HAPI的日志级别增加到DEBUG
,它可能会为您提供一个线索,以便PipeParser
无法创建特定消息类型的实例 .