如何使用 Spring WS 和 Axiom 从带有大型 XOP 附件的 SOAP 消息中读取数据

发布于 2024-11-27 10:11:10 字数 1581 浏览 3 评论 0原文

我正在尝试构建一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

百思不得你姐 2024-12-04 10:11:10

根据我的阅读(抱歉只能发布 2 个链接):

并通过MTOM方法的详细定义:

  • www.crosschecknet.com/intro_to_mtom.php

虽然针对传输中,在基本处理程序(例如 SOAPHandler)获取数据之前,附加到消息的 Base64 编码数据仍将被解组并放回到 SOAP 消息中。这似乎是该方法的局限性。

使用您提到的技术可以让您走上解决方案的正确轨道(与我们这些被迫使用基本 SOAPMessageSOAPHandlers 的人相比)。如果您使用 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:

  • www.crosschecknet.com/intro_to_mtom.php

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 and SOAPHandlers). 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.html

Thanks,
KK

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文