4 Replies Latest reply on Apr 12, 2013 2:11 PM by plambrecht

    Transformation help

    plambrecht

      Hello,

       

      I am new to switchyard and am having trouble with a specific case of transformation. Is it possible to do declarative transformation inside the composite between two beans? The only examples I am seeing of transformation is when you are coming in and out of the composite.

       

      So to give an example: I have a promoted service that builds a POJO and I want to send it to another service that makes an external request that accepts a different POJO. This creates compile errors in the way I imagine it....

       

      So POJO -> POJO. Do I need Camel routing?

       

      I was asked to look into this for a reference framework as a POC. Am I thinking about this correctly?

       

      Thanks,

      Peter

        • 1. Re: Transformation help
          kcbabo

          Just to confirm - same application, two beans: bean A invokes bean B.  You want the consumer contract for bean A to be different than the provider contract for bean B, thus invoking declarative transformation.  Is that right?

          • 2. Re: Transformation help
            plambrecht

            exactly.

            • 3. Re: Transformation help
              kcbabo

              Yep.  See attached for an example I just whipped up with our awesome tooling.  If you run mvn test or execute the unit test from within the IDE, you should see something like this in the output:

               

              11:07:26,161 WARN  [internal.ExchangeImpl] Fault generated during exchange without a handler: org.switchyard.HandlerException: Transformations not applied.  Required payload type of 'java:com.example.switchyard.pojo2pojo.B'.  Actual payload type is 'java:com.example.switchyard.pojo2pojo.A'.  You must define and register a Transformer to transform between these types.

               

              Add the transformer and it will go away.

              • 4. Re: Transformation help
                plambrecht

                Thanks Keith!

                 

                I will play around with that. I never thought of having a 3rd contract.

                 

                EDIT: This works as I wanted it to.