如何使用 Spring WS 和 Axiom 从带有大型 XOP 附件的 SOAP 消息中读取数据
我正在尝试构建一个 Web 服务,它将接收大文件并使用 SOAP 消息中指定的名称保存它们。 这是一个示例请求消息,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://mywebservice.com.ua/bait/schemas" xmlns:xm="http://www.w3.org/2005/05/xmlmime">
<soapenv:Header/>
<soapenv:Body>
<sch:SubmitProjectFileRequest>
<sch:ProjectName>MyADProject.xml</sch:ProjectName>
<sch:ProjectFile xm:contentType="text/text">cid:710420383131</sch:ProjectFile>
</sch:SubmitProjectFileRequest>
</soapenv:Body>
</soapenv:Envelope>
我已经构建了一些东西:我可以接收大型 XOP 文件而不会出现 OutOfMemoryError。 问题是我无法访问请求的 ProjectName 节点,因为任何获取它的尝试都会导致将附件内联到请求中。这本身会导致 OutOfMemoryError
这是我目前用于此目的的代码
@PayloadRoot(localPart = SUBMIT_PROJECT_FILE_REQUEST, namespace = NAMESPACE_URI)
public void handleSubmitProjectFileRequest(SoapMessage message) throws Exception {
String projectName = getProjectName(message.getDocument());
Attachment attachment = message.getAttachments().next();
projectFileService.storeProjectFile(projectName, attachment.getDataHandler());
}
private String getProjectName(Document xml) throws XPathExpressionException {
String prefix = xml.lookupPrefix(NAMESPACE_URI);
NodeList names = xml.getElementsByTagName(String.format("%s:%s", prefix, "ProjectName"));
String projectName = names.item(0).getTextContent();
return projectName;
}
有人可以帮助我使用 Spring WS 和 Axiom 提取大型 XOP 附件和 ProjectName 节点内容吗?
提前致谢
I'm trying to build a web-service, which will receive large files and save them with the name specified in SOAP message.
Here is an example request message
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://mywebservice.com.ua/bait/schemas" xmlns:xm="http://www.w3.org/2005/05/xmlmime">
<soapenv:Header/>
<soapenv:Body>
<sch:SubmitProjectFileRequest>
<sch:ProjectName>MyADProject.xml</sch:ProjectName>
<sch:ProjectFile xm:contentType="text/text">cid:710420383131</sch:ProjectFile>
</sch:SubmitProjectFileRequest>
</soapenv:Body>
</soapenv:Envelope>
I've build some stuff already: I can receive large XOP files without OutOfMemoryError.
The problem is that I can't access ProjectName node of the request, as any attempts to get it lead to inlining of an attachment into request. And that itself leads to OutOfMemoryError
Here is the code which I currently use for that purpose
@PayloadRoot(localPart = SUBMIT_PROJECT_FILE_REQUEST, namespace = NAMESPACE_URI)
public void handleSubmitProjectFileRequest(SoapMessage message) throws Exception {
String projectName = getProjectName(message.getDocument());
Attachment attachment = message.getAttachments().next();
projectFileService.storeProjectFile(projectName, attachment.getDataHandler());
}
private String getProjectName(Document xml) throws XPathExpressionException {
String prefix = xml.lookupPrefix(NAMESPACE_URI);
NodeList names = xml.getElementsByTagName(String.format("%s:%s", prefix, "ProjectName"));
String projectName = names.item(0).getTextContent();
return projectName;
}
Could anyone help me to extract both large XOP attachment and ProjectName node content using Spring WS and Axiom?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据我的阅读(抱歉只能发布 2 个链接):
并通过MTOM方法的详细定义:
虽然针对传输中,在基本处理程序(例如
SOAPHandler
)获取数据之前,附加到消息的 Base64 编码数据仍将被解组并放回到 SOAP 消息中。这似乎是该方法的局限性。使用您提到的技术可以让您走上解决方案的正确轨道(与我们这些被迫使用基本
SOAPMessage
和SOAPHandlers
的人相比)。如果您使用 AXIOM 和 spring 中的一些专用对象,您应该能够完成此任务。在这里查看这篇文章:http://forum.springsource.org/archive /index.php/t-48343.html谢谢,
KK
From what I read (Sorry could only post 2 links total):
And by the detailed definition of the MTOM method:
Although optimized for transport, the base64 encoded data that you attach to your message will still be unmarshalled and put back into the soap message before a basic handler (Like
SOAPHandler
for example) gets ahold of it. This seems to be a limitation of this methodology.Using the technologies you mentioned puts you on the right track for a solution (compared to those of us who were cornered into using basic
SOAPMessage
andSOAPHandlers
). If you use some of the specialized objects in AXIOM and spring, you should be able to accomplish this. CHeck this article out here: http://forum.springsource.org/archive/index.php/t-48343.htmlThanks,
KK