JAX-WS和SWA附件

我正在与SOAP API建立集成。另一面迫使我使用SWA(带有附件https://www.w3.org/TR/SOAP-attachments的SOAP)。我不能使用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定义的attachemnts部分:

<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>
chang661537 回答:JAX-WS和SWA附件

根据JAX-WS documentation

  在JAX-WS 2.0 RI FCS版本中添加了

MTOM和 swaRef 支持。 JAX-WS 2.0规范需要MTOM和swaref支持。

根据this

  

WS-I Attachment Profile 1.0定义了使用swaRef引用MIME附件部分的机制。在这种机制中,类型wsi:swaRef的XML元素的内容作为MIME附件发送,并且SOAP Body中的元素在RFC 2111定义的CID URI方案中保留对该附件的引用。 JAXB 2.0定义了wsi:swaRef模式类型到 javax.activation.DataHandler 的映射。应用程序将使用数据和适当的MIME类型构造DataHandler,并且JAX-WS将与JAXB和SAAJ协调,以将其作为附件MIME部分发送。

Here,您可以找到一个示例来完成此操作。

本文链接:https://www.f2er.com/3124832.html

大家都在问