Problem with MTOM in Camel-CXF

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with MTOM in Camel-CXF

Kessler, Joerg
Hi,
we use CXF 3.1.9 together with Camel 2.17.4. We want to enable MTOM on the Camel-CXF producer. To test it I created a simple route using Camel test infrastructure where the producer uses a WSDL with base64 encoded payload parts. But in the log output of CXF I always get a payload like this
Http-Method: POST
Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:2a84a041-d9ce-4caf-a8e1-b4247e1ad6d6"; start="<[hidden email]>"; start-info="text/xml"
Headers: {Accept=[*/*], breadcrumbId=[ID-WDFN32392889A-65347-1494850621554-0-1], Cache-Control=[no-cache], connection=[keep-alive], Content-Length=[487], content-type=[multipart/related; type="application/xop+xml"; boundary="uuid:2a84a041-d9ce-4caf-a8e1-b4247e1ad6d6"; start="<[hidden email]>"; start-info="text/xml"], Host=[localhost:8770], Pragma=[no-cache], SOAPAction=[""], User-Agent=[Apache-CXF/3.1.9]}
Payload: --uuid:2a84a041-d9ce-4caf-a8e1-b4247e1ad6d6
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <[hidden email]>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><typ:testXop xmlns:typ="http://cxf.apache.org/mime/types"><typ:name>?</typ:name><typ:attachinfo>U1VDQ0VTUw==</typ:attachinfo></typ:testXop></soap:Body></soap:Envelope>
--uuid:2a84a041-d9ce-4caf-a8e1-b4247e1ad6d6--

This is not MTOM. The endpoint configuration is
    <cxf:cxfEndpoint id="clientEndpoint" address="http://localhost:8770/cxf/mtom" bus="ClientBus" wsdlURL="wsdl/mtom_xop.wsdl">
        <cxf:properties>
            <entry key="dataFormat" value="PAYLOAD" />
            <entry key="defaultOperationName" value="testXop" />
            <entry key="defaultOperationNamespace" value="http://cxf.apache.org/mime"/>
            <entry key="mtom-enabled" value="true" />
        </cxf:properties>
    </cxf:cxfEndpoint>
Here I even used a WSDL that is used in the CXF MTOM tests. Then I compared the execution of the relevant interceptors in Camel-CXF and CXF and found one difference:
In AbstractOutDatabindingInterceptor. writeToOutputStream() it is checked that the data binding is implemented by the class org.apache.cxf.jaxb.JAXBDataBinding. That is correct for CXF but Camel-CXF sets in CxfEndpoint the  binding to org.apache.camel.component.cxf.HybridSourceDataBinding which is derived from JAXBDataBinding but of course is a different class. This seems to prevent the completion of the MTOM conversion. My proposal is to change this hard check on the class in CXF  to instanceof.

Best Regards,

Jörg
Reply | Threaded
Open this post in threaded view
|

Re: Problem with MTOM in Camel-CXF

Dennis Kieselhorst-2
Hi Jörg,

is there a similar testcase in https://github.com/apache/camel/tree/master/components/camel-cxf/src/test/java/org/apache/camel/component/cxf that we can use to reproduce it?

According to comments in the CXF code this part of code was optimized to improve performance, so we need to discuss this before changing it. Can you please open an issue for it? https://issues.apache.org/jira/browse/CXF

Cheers
Dennis
Reply | Threaded
Open this post in threaded view
|

Re: Problem with MTOM in Camel-CXF

Aki Yoshida-3
I think Joerg's suggestion makes sense.
The comments in the code talks about utilizing CXF's data-binding code
and to do that, it is checking the class name. If anyone (e.g.,
camel-cxf) is extending CXF's data-binding code and use it in CXF, I
suppose it will make sense to provide the same behavior for them.

2017-05-23 10:10 GMT+02:00 Dennis Kieselhorst <[hidden email]>:
> Hi Jörg,
>
> is there a similar testcase in https://github.com/apache/camel/tree/master/components/camel-cxf/src/test/java/org/apache/camel/component/cxf that we can use to reproduce it?
>
> According to comments in the CXF code this part of code was optimized to improve performance, so we need to discuss this before changing it. Can you please open an issue for it? https://issues.apache.org/jira/browse/CXF
>
> Cheers
> Dennis
Reply | Threaded
Open this post in threaded view
|

Re: Problem with MTOM in Camel-CXF

Dennis Kieselhorst-2
> I think Joerg's suggestion makes sense.
> The comments in the code talks about utilizing CXF's data-binding code
> and to do that, it is checking the class name. If anyone (e.g.,
> camel-cxf) is extending CXF's data-binding code and use it in CXF, I
> suppose it will make sense to provide the same behavior for them.

At first I also thought the change would make sense. However HybridSourceDataBinding doesn't support OutputStream. Discussion continued in JIRA issue: https://issues.apache.org/jira/browse/CXF-7388