gpt4 book ai didi

java - JAX-WS 和 SWA 附件

转载 作者:太空宇宙 更新时间:2023-11-04 09:17:29 25 4
gpt4 key购买 nike

我正在构建与 SOAP API 的集成。第二方强制我使用 SWA(带有附件的 SOAP https://www.w3.org/TR/SOAP-attachments )。我无法使用 MTOM。它也不是 SWA-Ref(?)。我使用 eclipse 和 Apache CXF 成功生成了 SOAP 客户端和 SOAP 服务器。简单的消息与基本身份验证和 HTTPS 完美配合。

我需要处理附件。我的 SOAP 客户端必须发送文件,我的服务器必须接收和保存文件。JAX-WS 可以处理 MIME 附件吗?

以下是示例 SOAP 消息的一部分:

<ns3:attachments>
<ns0:attachment href="cid:5d1499240031a00380006998" contentId="cid:5d1499240031a00380006998" action="add" name="example.txt" type="text/plain" len="88" />
</ns3:attachments>

这里是定义附件部分的 WSDL pars:

<xs:complexType name="AttachmentType">
<xs:attribute name="href" type="xs:string" use="optional"/>
<xs:attribute name="contentId" type="xs:string" use="optional"/>
<xs:attribute name="action" type="xs:string" use="optional"/>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="len" type="xs:int" use="optional"/>
<xs:attribute name="charset" type="xs:string" use="optional"/>
<xs:attribute name="upload.by" type="xs:string" use="optional"/>
<xs:attribute name="upload.date" type="xs:string" use="optional"/>
<xs:attribute name="attachmentType" type="xs:string" use="optional"/>
</xs:complexType>
<xs:complexType name="AttachmentsType">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="attachment" type="AttachmentType"/>
</xs:sequence>
</xs:complexType>

最佳答案

根据JAX-WS documentation :

MTOM and swaRef support was added in JAX-WS 2.0 RI FCS release. MTOM and swaref support is required by the JAX-WS 2.0 specification.

根据this :

WS-I Attachment Profile 1.0 defines mechanism to reference MIME attachment parts using swaRef. In this mechanism the content of XML element of type wsi:swaRef is sent as MIME attachment and the element inside SOAP Body holds the reference to this attachment in the CID URI scheme as defined by RFC 2111. JAXB 2.0 defines mapping of wsi:swaRef schema type to javax.activation.DataHandler. An application will construct the DataHandler with the data and the appropriate MIME type and JAX-WS will coordinate with JAXB and SAAJ to send it as attachment MIME part.

Here您可以找到如何实现此目的的示例。

关于java - JAX-WS 和 SWA 附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58799945/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com