camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Enritsche ...@kabsi.at>
Subject MTOM proxy via cxf MESSAGE mode to http4
Date Mon, 13 Mar 2017 13:53:44 GMT
Hi.

I am struggling to get an MTOM attached soap message through my camel proxy.
It seems the content type is changed somewhere in the route. The
"multipart/related" with the multipart boundary gets lost. I am using the
MESSAGE data format for transferring the whole request. Without MTOM
everything works ok.

My Spring config is as follows:

<?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:camel="http://camel.apache.org/schema/spring"
	xmlns:cxf="http://camel.apache.org/schema/cxf"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
		http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
		http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf-spring.xsd">

	<camelContext id="myContext" xmlns="http://camel.apache.org/schema/spring">
		<route id="myRoute" streamCache="true">
			<from uri="cxf:bean:myCxfEndpoint" />
			<to
uri="http4://realwebservice&amp;bridgeEndpoint=true&amp;okStatusCodeRange=200-499&amp;throwExceptionOnFailure=false"
/>
		</route>
	</camelContext>

	<cxf:cxfEndpoint id="myCxfEndpoint"
		publishedEndpointUrl="https://somewhere"
		address="/path/to/adress"
		endpointName="e:Production"
		serviceName="e:Service"
		wsdlURL="wsdl/myService.wsdl"
		xmlns:e="https://namespace">
		<cxf:properties>
			<entry key="dataFormat" value="MESSAGE" />
			<entry key="mtom-enabled" value="true" /> 
		</cxf:properties>
	</cxf:cxfEndpoint>
</beans>

My current workaround is to set the content-type manually via a processor in
between to the content-type out of the CamelCxfMessage:

public class CxfPropagateContentTypeProcessor implements Processor {

    @Override
    public void process(final Exchange exchange) throws Exception {
        final Map<String, Object> properties = exchange.getProperties();
        if (properties.containsKey(CxfConstants.DATA_FORMAT_PROPERTY)) {
            final DataFormat dataFormat = (DataFormat)
properties.get(CxfConstants.DATA_FORMAT_PROPERTY);
            // this is not supported normally, we use it just as a marker
            final String mtomProperty = (String)
properties.get("mtom-enabled");

            if (exchange.getFromEndpoint() instanceof CxfEndpoint &&
dataFormat == DataFormat.MESSAGE && "true".equals(mtomProperty)) {
                final Message message = exchange.getIn();
                final Map<String, Object> messageHeaders =
message.getHeaders();

                // extract the CXF message (TODO there may be an official
way to
                // get this)
                final SoapMessage soapMessage = (SoapMessage)
messageHeaders.get(CxfConstants.CAMEL_CXF_MESSAGE);
                if (soapMessage != null) {
                    message.setHeader(Exchange.CONTENT_TYPE,
soapMessage.get(Exchange.CONTENT_TYPE));
                }
            }
        }
    }
}

I think there should be a simpler approach. Could this be a bug in the cxf
component?

BR
Erich



--
View this message in context: http://camel.465427.n5.nabble.com/MTOM-proxy-via-cxf-MESSAGE-mode-to-http4-tp5795363.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message