【问题标题】:Attachment with SOAP Handler using CXF使用 CXF 附加 SOAP 处理程序
【发布时间】:2016-07-06 04:56:18
【问题描述】:

我正在尝试使用 Apache CXF 使用 SOAP 处理程序附加文件,但它不起作用。

我的例子在这里。

https://github.com/emag-notes/cxf-soaphandler-demo

在本例中,我使用 SAAJ API 附加文件。

https://github.com/emag-notes/cxf-soaphandler-demo/blob/master/server/src/main/java/cxf/soaphandler/AttachmentHandler.java#L49-L54

但是,SOAP 消息响应只是一个 SOAP 信封,而不是多部分(不是 包括我附加的文件)。

我错过了什么吗?此代码适用于 Apache Axis2。

尽管我知道使用 MTOM 是最好的选择,但我现在还是想使用我现有的代码 AMAP(我正在从 Axis2 迁移)。

【问题讨论】:

    标签: java soap cxf


    【解决方案1】:

    尽管代码看起来不错,但我相信您需要启用 MTOM,即使您没有使用 MTOM 的全部功能。

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:soap="http://cxf.apache.org/bindings/soap"
           xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
    
      <jaxws:server id="Downloader" serviceClass="cxf.soaphandler.Downloader" address="downloader">
        <jaxws:serviceBean>
          <bean class="cxf.soaphandler.Downloader">
          </bean>
        </jaxws:serviceBean>
        <jaxws:binding>
            <soap:soapBinding mtomEnabled="true" />
        </jaxws:binding>
      </jaxws:server>
    
    </beans>
    

    【讨论】:

    • 非常感谢!这对我来说很神奇......虽然它看起来像 mtom 通信就看到数据包捕获(内容类型是 application/xop_xml),我的axis1客户端可以访问该服务。
    猜你喜欢
    • 1970-01-01
    • 2012-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多