如何在 Spring 中从 Soap 消息中提取附件

发布于 2024-09-19 06:47:05 字数 748 浏览 3 评论 0原文

肥皂消息成功到达,我可以很好地打印出信封,但附件始终为零。尽管我通过 SoapUI 提出了确切的请求,并且附件在其中显示得很好。也许这不是提取附件的有效方法。我将其添加到 sendandreceive 方法中。

private class AttachmentWebServiceMessageExtractorImpl implements WebServiceMessageExtractor {
    public Object extractData(WebServiceMessage webServiceMessage) throws IOException, TransformerException {
        Set<ZipFile> attachmentZipFiles = new HashSet<ZipFile>();
        Iterator attachmentIterator = ((SaajSoapMessage)webServiceMessage).getAttachments();
        if(attachmentIterator != null) {
            while(attachmentIterator.hasNext()){
                attachmentZipFiles.add((ZipFile) attachmentIterator.next());
            }
        }
        return attachmentZipFiles;
    }
}

The soap message successfully comes across, and I can print out the envelope just fine, but the attachments are always zero. Even though I put the exact request through SoapUI, and the attachments show up fine in that. Maybe this isn't a valid way to extract the attachments. I'm adding this to the sendandreceive method.

private class AttachmentWebServiceMessageExtractorImpl implements WebServiceMessageExtractor {
    public Object extractData(WebServiceMessage webServiceMessage) throws IOException, TransformerException {
        Set<ZipFile> attachmentZipFiles = new HashSet<ZipFile>();
        Iterator attachmentIterator = ((SaajSoapMessage)webServiceMessage).getAttachments();
        if(attachmentIterator != null) {
            while(attachmentIterator.hasNext()){
                attachmentZipFiles.add((ZipFile) attachmentIterator.next());
            }
        }
        return attachmentZipFiles;
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

假面具 2024-09-26 06:47:05

AXIOM 消息工厂与 DOM 消息工厂。 DOM 无法正确获取附件。

AXIOM message factory vs DOM Message Factory. DOM would not properly pick up attachments.

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