Mixing of POJO and PAYLOAD is probably fine but you have to do some conversion (e.g. in a processor). You know the message body for POJO mode is List<Object> and for PAYLOAD mode is CxfPayload. So, it needs conversion from a List<Object> to CxfPayload for the request and convert back from CxfPayload to List<Object> on the response.

from(cxf://...?dataFormat=POJO).process(convertRequest).to(cxf://...?dataFormat=PAYLOAD).process(convertResponse)

As to whether mixing mode is necessary, you might want to consider leverage JAXWS handler to access SOAP header and perform any pre/post processing. Here is an example of using JAXWS in Camel.


https://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/wsdl_first/JaxwsTestHandler.java

https://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/WsdlFirstProcessor.xml

https://svn.apache.org/repos/asf/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstProcessorTest.java

HTH


On 12/07/2010 03:35 AM, Thomas KRIECHBAUM wrote:
Hello,

in my integration prototype an existing web-service should be adapted to
an other contract. Therefore, I have a cxf:consumer(dataFormat=PAYLOAD;
the associated cxf:endpoint definition references a WSDL but no service
class) and a cxf:producer (the associated cxf:endpoint references a
service class that has been generated from a WSDL). In this scenario, I?m
getting an exception, when the response is send back within the
cxf:consumer (XMLStreamDataWriter.write expects DataSource, Node or
Source) .
After doing some debugging, binding.populateCxfResponseFromExchange
extracts the data format from the current exchange (in my case
cxf:producer with data format POJO) and not the current endpoint (in my
case cxf:consumer with data format PAYLOAD).

What's the correct interaction between those components? The mix of data
formats is needed, because
1.) the SOAP headers should be inspected
2.) the incoming SOAP message can contain invalid type representation
(e.g. timestamp) that have to be corrected before =>  POJO can not be used
in this case

code from org.apache.camel.component.cxf.CxfConsumer

@SuppressWarnings("unchecked")
private void setResponseBack(Exchange cxfExchange,
org.apache.camel.Exchange camelExchange) {
     CxfEndpoint endpoint = (CxfEndpoint)getEndpoint();
     CxfBinding binding = endpoint.getCxfBinding();

     checkFailure(camelExchange);

     // bind the Camel response into a CXF response
     if (camelExchange.getPattern().isOutCapable()) {
         binding.populateCxfResponseFromExchange(camelExchange,
cxfExchange);
     }

     // check failure again as fault could be discovered by converter
     checkFailure(camelExchange);

     // copy the headers javax.xml.ws header back
     binding.copyJaxWsContext(cxfExchange, (Map<String,
Object>)camelExchange.getProperty(CxfConstants.JAXWS_CONTEXT));
}

I?m using camel-cxf 2.5.0

Thanks,
Thomas



Der Austausch von Nachrichten mit o.a. Absender via e-mail dient ausschließlich 
Informationszwecken. Rechtsgeschäftliche Erklärungen dürfen über dieses Medium 
nicht ausgetauscht werden.

Correspondence with a.m. sender via e-mail is only for information purposes. 
This medium is not to be used for the exchange of legally-binding 
communications.

Reply via email to