How to consume a message from a camel-cxf endpoint in POJO data format - 6.3

Talend ESB Mediation Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend ESB

The camel-cxf endpoint consumer POJO data format is based on the cxf invoker, so the message header has a property with the name of CxfConstants.OPERATION_NAME and the message body is a list of the SEI method parameters.

public class PersonProcessor implements Processor {

   private static final transient Logger LOG = 
      LoggerFactory.getLogger(PersonProcessor.class);

   @SuppressWarnings("unchecked")
   public void process(Exchange exchange) throws Exception {
      LOG.info("processing exchange in camel");

      BindingOperationInfo boi = 
         (BindingOperationInfo)exchange.getProperty(
         BindingOperationInfo.class.toString());
      if (boi != null) {
         LOG.info("boi.isUnwrapped" + boi.isUnwrapped());
      }
      // Get the parameters list which element is the holder.
      MessageContentsList msgList = (
         MessageContentsList)exchange.getIn().getBody();
            
      Holder<String> personId = (Holder<String>)msgList.get(0);
      Holder<String> ssn = (Holder<String>)msgList.get(1);
      Holder<String> name = (Holder<String>)msgList.get(2);

      if (personId.value == null || personId.value.length() == 0) {
         LOG.info("person id 123, so throwing exception");
         // Try to throw out the soap fault message
         org.apache.camel.wsdl_first.types.UnknownPersonFault personFault =
            new org.apache.camel.wsdl_first.types.UnknownPersonFault();
         personFault.setPersonId("");
         org.apache.camel.wsdl_first.UnknownPersonFault fault =
            new org.apache.camel.wsdl_first.UnknownPersonFault(
            "Get the null value of person name", personFault);
         // Since Camel has its own exception handler framework, we can't 
         // throw the exception to trigger it. We set the fault message
         // in the exchange for camel-cxf component handling and return
         exchange.getOut().setFault(true);
         exchange.getOut().setBody(fault);
         return;
      }

      name.value = "Bonjour";
      ssn.value = "123";
      LOG.info("setting Bonjour as the response");
      // Set the response message, first element is the return value of 
      // the operation, the others are the holders of method parameters
      exchange.getOut().setBody(new Object[] {null, personId, ssn, name});
   }
}