Why are custom transformations not triggered in Camel route?
krivko Jun 28, 2013 3:12 AMHi!
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
-
switchyard-soap-camel.zip 17.5 KB
-
sy_graphic.png 12.2 KB