2 Replies Latest reply on Jun 28, 2013 3:12 AM by krivko

    Why are custom transformations not triggered in Camel route?

    krivko

      Hi!

       

      I've been asking similiar question in some other post (https://community.jboss.org/thread/229708?tstart=0) lately. Since there was no answer I'm posting a much straight forward example.

       

      The case is simple - a SOAP service receives message, Camel route (implemented as Java class) then sends message to SY Bean component.

      This is the Camel route configuration:

       

      package com.example.switchyard.soap.camel;
      
      
      import org.apache.camel.builder.RouteBuilder;
      import org.apache.camel.converter.jaxb.JaxbDataFormat;
      
      
      public class CamelServiceRoute extends RouteBuilder {
      
      
                /**
                 * The Camel route is configured via this method.  The from:
                 * endpoint is required to be a SwitchYard service.
                 */
                public void configure() {
                          JaxbDataFormat jaxb = new JaxbDataFormat("si.ajpes.wsprs.prsinfo"); 
      
                          from("switchyard://PrsInfoSoap") 
                          //.log("Received message for 'PrsInfoSoap' : ${body}");
                          .to("switchyard://CheckOne");
                }
      }
      

       

      As you can see I deliberately skiped the marshaling in Camel route. Should it be done here? Which transformation will be triggered when I call the SY Bean (i.e. CheckOne) ?

       

      Some transformations are in order. In example I've prepared this one (SOAP to Java object):

       

      <transforms>
           <transform.java xmlns="urn:switchyard-config:transform:1.0" class="com.example.switchyard.soap.transform.Transformator" from="{http://www.ajpes.si/wsPrs/PrsInfo}PrsDataGet" to="java:si.ajpes.wsprs.prsinfo.PrsDataGet"/>
      </transforms>
      

       

      but it never gets triggered when SOAP message arrives. I've also added some other custom transformations (skiped in example) and they also never got triggered, even though they seem cofigured ok.

       

      This is the full switchyard.xml

       

      <?xml version="1.0" encoding="UTF-8"?>
      <switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:bean="urn:switchyard-component-bean:config:1.0" xmlns:camel="urn:switchyard-component-camel:config:1.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:soap="urn:switchyard-component-soap:config:1.0" name="switchyard-soap-camel" targetNamespace="urn:com.example.switchyard:switchyard-soap-camel:1.0">
          <sca:composite name="switchyard-soap-camel" targetNamespace="urn:com.example.switchyard:switchyard-soap-camel:1.0">
              <sca:service name="PrsInfoSoap" promote="CamelServiceRoute/PrsInfoSoap">
                  <sca:interface.wsdl interface="PrsInfo.wsdl#wsdl.porttype(PrsInfoSoap)"/>
                  <soap:binding.soap>
                      <soap:messageComposer/>
                      <soap:wsdl>PrsInfo.wsdl</soap:wsdl>
                      <soap:contextPath>switchyard-soap-camel</soap:contextPath>
                  </soap:binding.soap>
              </sca:service>
              <sca:component name="CamelServiceRoute">
                  <camel:implementation.camel>
                      <camel:java class="com.example.switchyard.soap.camel.CamelServiceRoute"/>
                  </camel:implementation.camel>
                  <sca:service name="PrsInfoSoap">
                      <sca:interface.wsdl interface="PrsInfo.wsdl#wsdl.porttype(PrsInfoSoap)"/>
                  </sca:service>
                  <sca:reference name="CheckOne">
                      <sca:interface.java interface="com.example.switchyard.soap.camel.CheckOne"/>
                  </sca:reference>
              </sca:component>
              <sca:component name="CheckOneBean">
                  <bean:implementation.bean class="com.example.switchyard.soap.camel.CheckOneBean"/>
                  <sca:service name="CheckOne">
                      <sca:interface.java interface="com.example.switchyard.soap.camel.CheckOne"/>
                  </sca:service>
              </sca:component>
          </sca:composite>
          <transforms>
              <transform.java xmlns="urn:switchyard-config:transform:1.0" class="com.example.switchyard.soap.transform.Transformator" from="{http://www.ajpes.si/wsPrs/PrsInfo}PrsDataGet" to="java:si.ajpes.wsprs.prsinfo.PrsDataGet"/>
          </transforms>
          <domain>
              <handlers>
                  <handler class="org.switchyard.handlers.MessageTrace" name="MessageTrace"/>
              </handlers>
          </domain>
      </switchyard>
      
      

       

      When I run the SOAP request the Camel throws the exception attached.

       

      Does this mean that custom transformations aren't used when there is Camel route defined? Is Camel doing the transformations? What's the correct approach to using Camel route and SY Bean components?

       

      btw - I've been testing this on SY 1.0.0.Alpha1 & EAP 6.1 (both build from Github tag) & source code is attached

       

      Thank you in advance!

       

      Regards,

      Krivko

        • 1. Re: Why are custom transformations not triggered in Camel route?
          kcbabo

          Thanks for the detailed info and your patience in getting a reply.  Everyone on the team is working long hours to get the 1.0 release out, so our response time in the forums is suffering recently.

           

          Transformations in SwitchYard allow you to declaratively resolve differences in message formats based on the contracts for a service consumer and provider.  As an example, if the consumer has a WSDL interface with an XML data type and the provider has a Java type, then SY will lookup a transformer definition to map between those two data types.

           

          In your application, you have a reference defined in your camel route with an interface of "com.example.switchyard.soap.camel.CheckOne".  This reference is used to invoke the CheckOne service which also has an interface type of "com.example.switchyard.soap.camel.CheckOne".  Since the interfaces are identical, there is no need for transformation to kick in.

          • 2. Re: Why are custom transformations not triggered in Camel route?
            krivko

            Thanks Keith!

             

            You were spot on. I've been stuck with this problem for a while.

             

            I've corrected and attached the example (see switchyard-soap-camel_working.zip).

             

            Godspeed with 1.0 release!

             

            Regards,

            Krivko