4 Replies Latest reply on Nov 8, 2012 10:17 AM by Ivo Bek

    Transformation doesn't work when a component uses camel routing

    Ivo Bek Newbie

      Hi,

       

      I'm not able to do xslt transformation of soap messages in switchyard when the soap message is routed. I think that any other transformation wouldn't work either. When I use camel's transformation (<to uri="xslt:orderReq_To_productOrderReq.xslt"/>), it works ... but I really would like to use the switchyard transformations. I'm no sure if it's a bug or I do something wrong or it's not possible yet.

       

      This is my working switchyard.xml with camel's transformations but if I remove them, the soap messages aren't transformed through switchyard:

       

      <switchyard xmlns="urn:switchyard-config:switchyard:1.0"
                  xmlns:soap="urn:switchyard-component-soap:config:1.0"
                  xmlns:camel="urn:switchyard-component-camel:config:1.0">
          <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="transform_xslt_bpel" targetNamespace="urn:switchyard-soa:transform_xslt_bpel:0.1.0">
              <service name="GenericOrder" promote="GenericOrder">
                  <interface.wsdl interface="GenericOrderArtifacts.wsdl#wsdl.porttype(GenericOrderService)"/>
                  <soap:binding.soap>
                      <soap:wsdl>GenericOrderArtifacts.wsdl</soap:wsdl>
                      <soap:socketAddr>:18001</soap:socketAddr>
                      <soap:contextPath>GenericOrder</soap:contextPath>
                  </soap:binding.soap>
              </service>
              
              <reference multiplicity="1..1" name="ProductOrderServiceRef" promote="ProductOrderService">
                  <soap:binding.soap>
                      <soap:wsdl>ProductOrderArtifacts.wsdl</soap:wsdl>
                  </soap:binding.soap>
              </reference>
              
              <component name="GenericOrder">
                <camel:implementation.camel>
                      <route xmlns="http://camel.apache.org/schema/spring">
                          <from uri="switchyard://GenericOrder"/>
                          <to uri="xslt:orderReq_To_productOrderReq.xslt"/>
                          <to uri="switchyard://ProductOrderServiceRef"/>
                          <to uri="xslt:productOrderResp_To_orderResp.xslt"/>
                      </route>
                  </camel:implementation.camel>
                  <reference name="ProductOrderServiceRef">
                      <interface.wsdl interface="ProductOrderArtifacts.wsdl#wsdl.porttype(ProductOrderService)"/>
                  </reference>
                  <service name="GenericOrder">
                      <interface.wsdl interface="GenericOrderArtifacts.wsdl#wsdl.porttype(GenericOrderService)"/>
                  </service>
              </component>
              
          </composite>
          
          <transforms>
          
              <transform.xslt xmlns="urn:switchyard-config:transform:1.0"
                      from="{http://www.jboss.org/bpel/examples}orderReq"
                      to="{http://www.jboss.org/bpel/examples/product}productOrderReq"
                      xsltFile="orderReq_To_productOrderReq.xslt"/>
              <transform.xslt xmlns="urn:switchyard-config:transform:1.0"
                      from="{http://www.jboss.org/bpel/examples/product}productOrderResp"
                      to="{http://www.jboss.org/bpel/examples}orderResp"
                      xsltFile="productOrderResp_To_orderResp.xslt"/>
                      
          </transforms>
          
      </switchyard>
      

       

      Thanks, Ivo

        • 1. Re: Transformation doesn't work when a component uses camel routing
          Keith Babo Master

          In order for declarative transformation to kick in, the message types in the service contract need to be different.  In the switchyard.xml you posted above, the contracts appear to be the same for GenericOrderService and ProductOrderService.

          • 2. Re: Transformation doesn't work when a component uses camel routing
            Ivo Bek Newbie

            Hi Keith

             

            The message types are really different ... I looked at the MessageTraceHandler and the message content types changed but not the content. I put the message content types to from and to transform attributes ... I suppose that it's right way. To be sure, I attach the wsdls if the messages are bad that they cannot be recognized as different.

             

            Thank you

            • 3. Re: Transformation doesn't work when a component uses camel routing
              Keith Babo Master

              Can you explain a bit more about how the message types are different?  If you are referring to the mapping of the types in GenericOrderService to ProductOrderService, then that's not represented in your switchyard.xml.  Declarative transformation kicks in when the message types for a consumer and a provider are different.  If you look at the invocation in your Camel route, the consumer has an invocation contract (represented by the component reference) of ProductOrderService and the provider (represented by the composite reference) uses the same contract (through inheritance).  No declarative transformation will kick in on this path.  There are two paths here:

               

              Path 1 is what you have now.  You accept a message type into your service as defined in GenericOrderService.  You then want to invoke ProductOrderService using it's contract, so you need to convert the message type inside your service implementation.  For Camel routes, this would be accomplished by invoking the transformation explicitly as you have done.

               

              Path 2 is to use your own contract for the component reference, which is equivalent to saying that you haven't changed the message type in your service implementation.  On this path, declarative transformation will kick in.  Here's an example of what that switchyard.xml could look like:

               

              <reference multiplicity="1..1" name="ProductOrderServiceRef" promote="ProductOrderService">
                 <reference name="ProductOrderServiceRef">
                    <interface.wsdl interface="ProductOrderArtifacts.wsdl#wsdl.porttype(ProductOrderService)"/>
                 </reference>
                 <soap:binding.soap>
                    <soap:wsdl>ProductOrderArtifacts.wsdl</soap:wsdl>
                 </soap:binding.soap>
              </reference>
              
              <component name="GenericOrder">
                 <camel:implementation.camel>
                    <route xmlns="http://camel.apache.org/schema/spring">
                       <from uri="switchyard://GenericOrder"/>
                       <to uri="switchyard://ProductOrderServiceRef"/>
                    </route>
                 </camel:implementation.camel>
                 <reference name="ProductOrderServiceRef">
                    <interface.wsdl interface="GenericOrderArtifacts.wsdl#wsdl.porttype(GenericOrderService)"/>
                 </reference>
                 <service name="GenericOrder">
                    <interface.wsdl interface="GenericOrderArtifacts.wsdl#wsdl.porttype(GenericOrderService)"/>
                 </service>
              </component>
              
              • 4. Re: Transformation doesn't work when a component uses camel routing
                Ivo Bek Newbie

                Oh ok then.

                 

                Thank you Keith, the Path2 really works ... that's great , I just had to change your reference to:

                <reference multiplicity="1..1" name="ProductOrderServiceRef" promote="ProductOrderService">
                   <interface.wsdl interface="ProductOrderArtifacts.wsdl#wsdl.porttype(ProductOrderService)"/>
                   <soap:binding.soap>
                      <soap:wsdl>ProductOrderArtifacts.wsdl</soap:wsdl>
                   </soap:binding.soap>
                </reference>
                1 of 1 people found this helpful