我正在尝试使用以下结构创建soap消息:
我使用WebServiceMessageCallback来获取上述格式,但是当我尝试使用新源转换主体时,source具有以上格式:
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.transform(source,soapBody.getPayloadResult());
我收到以下错误:
[Fatal Error] :1:157: The markup in the document following the root element must be well-formed.
ERROR: 'The markup in the document following the root element must be well-formed.'
Exception in thread "main" org.springframework.ws.client.WebServiceTransformerException:Transformation error: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 157; The markup in the document following the root element must be well-formed.; nested exception is javax.xml.transform.TransformerException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 157; The markup in the document following the root element must be well-formed.
我的理解是,这个错误告诉我,正文不是格式良好的XML,因为它没有单个根元素.但是,这就是我需要的服务,我发送消息以期望上述结构.
这有什么办法吗?谢谢你的帮助.
编辑:
我应该提到我已经看过Spring Update SOAP Header with Two Elements,这是我想要做的但是在标题中.我已经尝试了他使用虚拟根的方法,但我不知道如何在他提到的转换后删除虚拟根.我没有足够的代表评论他的答案,找出…
最佳答案
元素< SOAP:Body>包含您要交换的消息.在< SOAP:Body>中加入两个元素因此是不可能的.您必须围绕两个项目包装一个根XML元素.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。