加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

java – 具有两个元素的SOAP主体

发布时间:2020-12-15 01:26:51 所属栏目:大数据 来源:网络整理
导读:我正在尝试使用以下结构创建soap消息: 我使用WebServiceMessageCallback来获取上述格式,但是当我尝试使用新源转换主体时,source具有以上格式: TransformerFactory transformerFactory = TransformerFactory.newInstance();Transformer transformer = trans

我正在尝试使用以下结构创建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元素.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读