使用Hapi XML解析器将Hapi编码为HL7 v2.7消息到xml

使用Hapi XML解析器将Hapi编码为HL7 v2.7消息到xml

问题描述:

Hapi xml解析器在使用Hapi Xml解析器编码HL7 v2.7消息时给出以下异常。使用Hapi XML解析器将Hapi编码为HL7 v2.7消息到xml

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); 

任何建议/解决方案?

+0

我用hl7-v2标记了它...希望有人可以帮助你... –

如果您尝试编码的消息没有特定类型,但是代之以GenericMessage,则会抛出此异常。看起来好像HAPI无法为您的document确定正确的消息类型。如果将HAPI的日志级别提高到DEBUG,它可能会给您一个线索,为什么PipeParser无法创建特定消息类型的实例。