开发者

How to read data from SOAP message with large XOP attachment using Spring WS and Axiom

开发者 https://www.devze.com 2023-03-25 13:46 出处:网络
I\'m trying to build a web-service, which will receive large files and save them with the name specified in SOAP message.

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开发者_JAVA技巧, "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


From what I read (Sorry could only post 2 links total):

  • http://www.java.net/node/690763
  • markmail.org/message/utd5ineljlvvugse

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

0

精彩评论

暂无评论...
验证码 换一张
取 消