14 Replies Latest reply on Mar 31, 2013 9:33 AM by tadayosi

    JBoss ESB's SOAPClient equivalents in SwitchYard?

    tadayosi

      Hello all,

       

      I'm looking for SOAPClient (http://docs.jboss.org/jbossesb/docs/4.11/manuals/html/Programmers_Guide/index.html#sect-webservicessoap-soapclient-1) equivalents in SwitchYard. However, as far as I researched there seems to be no such features yet. Is there any plan to provide such features in SY in the future?  Or if I can achieve similar things with the current offerings, please tell me how.

       

      For clarification, what I'm looking for is such a feature that I can put a Map with request data in a Message and a SOAP request is automatically generated from WSDL and is populated with that data, which then can be sent to a SCA reference with WSDL interface and SOAP binding. Currently, it appears to me that SOAPMessageComposer expect only messages which already contains the populated SOAP message.

       

      Here is what I'd like to do in switchyard.xml:

       

           <sca:composite name="webservice_consumer1" targetNamespace="urn:switchyard-quickstart:webservice_consumer1:0.1.0">
              <sca:service name="WebserviceConsumer1" promote="MyServiceCategory/WebserviceConsumer1">
                  <jms:binding.jms>
                      <jms:queue>quickstart_webservice_consumer1_Request</jms:queue>
                      <jms:connectionFactory>#ConnectionFactory</jms:connectionFactory>
                  </jms:binding.jms>
              </sca:service>
              <sca:component name="MyServiceCategory">
                  <sca:service name="WebserviceConsumer1">
                      <interface.esb inputType="java:java.lang.String" />
                  </sca:service>
                  <camel:implementation.camel>
                      <spring:route id="org.switchyard.quickstarts.webservice.consumer1.WebserviceConsumer1">
                          <spring:bean beanType="org.switchyard.quickstarts.webservice.consumer1.MyRequestAction" method="process" />
                          <spring:to uri="switchyard://HelloWorldWS" />
                          <spring:bean beanType="org.switchyard.quickstarts.webservice.consumer1.MyResponseAction" method="process" />
                      </spring:route>
                  </camel:implementation.camel>
                  <sca:reference name="HelloWorldWS">
                      <sca:interface.wsdl interface="http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS?wsdl#wsdl.porttype(HelloWorld)" />
                  </sca:reference>
              </sca:component>
              <sca:reference name="HelloWorldWS" promote="MyServiceCategory/HelloWorldWS" multiplicity="1..1">
                  <soap:binding.soap>
                      <soap:contextMapper />
                      <soap:wsdl>http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS?wsdl</soap:wsdl>
                      <soap:endpointAddress>http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS</soap:endpointAddress>
                  </soap:binding.soap>
              </sca:reference>
          </sca:composite>
      
      

       

      Best regards,

      Tadayoshi

        • 1. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
          mageshbk

          Hi Tadayoshi,

           

          The conversion of SOAP Message to Java Objects and vice-versa is effective now in SwitchYard with the help of Transformers. Have a look at sample transformer in the bean-service QS. In fact the users can use any utility available for generating the SOAP Messages. This gives more flexibility in transformation, rather than sticking to one implementation that could be limited.

           

          Please note that although the configuration of bean-service QS mentions the transformers explicitly, it would be generated when building the project. So just including the transformer class should be sufficient and the build will append the configuration.

          1 of 1 people found this helpful
          • 2. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
            tadayosi

            Thanks, Magesh!  I'm now trying to use transformers to achieve my intent. I'll update the results once I succeed.

            • 3. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
              tadayosi

              Hi Magesh,

               

              I made the following transformer, but it doesn't seem to work as expected on the switchyard.xml I pasted in my initial post. Can you give me any advices on how to make it work please?  My intent here is receiving a java.lang.String message via JMS, then hopefully transforming it to a SOAP message, and finally sending it to the "switchyard://HelloWorldWS" web service endpoint. Originally I did the transformation in the "org.switchyard.quickstarts.webservice.consumer1.MyRequestAction" bean inside of the camel route; now I'd like to do the same more SwitchYard way.

               

              public class Transformers {
              
                  private static String SOAP_TEMPLATE =
                            "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns2=\"http://webservice_consumer1/helloworld\">"
                          + "    <S:Body>"
                          + "        <ns2:sayHello>"
                          + "            <toWhom>%s</toWhom>"
                          + "        </ns2:sayHello>"
                          + "    </S:Body>"
                          + "</S:Envelope>";
                  
                  @Transformer(to = "{http://webservice_consumer1/helloworld}sayHello")
                  public Element transform(String message) throws Exception {
                      return toElement(String.format(SOAP_TEMPLATE, message));
                  }
                  
                  @Transformer(from = "{http://webservice_consumer1/helloworld}sayHelloResponse")
                  public String transform(Element soap) throws Exception {
                      return getElementValue(soap, "return");
                  }
                  
                  private String getElementValue(Element parent, String elementName) {
                      String value = null;
                      NodeList nodes = parent.getElementsByTagName(elementName);
                      if (nodes.getLength() > 0) {
                          value = nodes.item(0).getChildNodes().item(0).getNodeValue();
                      }
                      return value;
                  }
                  
                  private Element toElement(String xml) {
                      DOMResult dom = new DOMResult();
                      try {
                          TransformerFactory.newInstance().newTransformer().transform(new StreamSource(new StringReader(xml)), dom);
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                      return ((Document) dom.getNode()).getDocumentElement();
                  }
              }
              

               

              Thank you!

              • 4. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
                kcbabo

                If you are using the SOAP gateway, you don't need to construct the SOAP envelope in your transformer.  Just include the content of the body and the SOAP gateway will take care of creating the envelope and body wrappers.  So your transformer would look something like this:

                 

                private static String SOAP_TEMPLATE =
                            + "        <ns2:sayHello xmlns:ns2=\"http://webservice_consumer1/helloworld\">"
                            + "            <toWhom>%s</toWhom>"
                            + "        </ns2:sayHello>";

                1 of 1 people found this helpful
                • 5. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
                  tadayosi

                  Thanks, Keith. It's really nice to know that!

                   

                  Even with that change in the transformer, however, I still get the same error as before like below. Note that I am running the configuration from a SY test. I attached my current switchyard.xml and the test case for your reference.

                   

                   

                  09:48:24,559 INFO  [org.switchyard.quickstarts.webservice.consumer1.WebserviceConsumer1] [request] 'Jimbo'
                  [Fatal Error] :1:1: Content is not allowed in prolog.
                  09:48:24,579 ERROR [org.apache.camel.processor.DefaultErrorHandler] Failed delivery for (MessageId: ID-reunion-37367-1364518100572-2-3 on ExchangeId: ID-reunion-37367-1364518100572-2-4). Exhausted after delivery attempt: 1 caught: org.switchyard.HandlerException: Unexpected exception handling SOAP Message
                  org.switchyard.HandlerException: Unexpected exception handling SOAP Message
                            at org.switchyard.component.soap.OutboundHandler.handleMessage(OutboundHandler.java:177)
                            at org.switchyard.bus.camel.processors.ProviderProcessor.process(ProviderProcessor.java:39)
                            at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.switchyard.bus.camel.audit.FaultProcessor.process(FaultProcessor.java:52)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:330)
                            at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)
                            at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
                            at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
                            at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:122)
                            at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:61)
                            at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
                            at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
                            at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63)
                            at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:360)
                            at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:331)
                            at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:227)
                            at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:331)
                            at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:169)
                            at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:111)
                            at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:97)
                            at org.switchyard.bus.camel.ExchangeDispatcher.dispatch(ExchangeDispatcher.java:64)
                            at org.switchyard.internal.ExchangeImpl.sendInternal(ExchangeImpl.java:203)
                            at org.switchyard.internal.ExchangeImpl.send(ExchangeImpl.java:114)
                            at org.switchyard.component.camel.SwitchYardProducer.process(SwitchYardProducer.java:103)
                            at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:120)
                            at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:292)
                            at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:115)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:330)
                            at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)
                            at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
                            at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
                            at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
                            at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
                            at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
                            at org.switchyard.component.camel.SwitchYardConsumer.invokeCamelProcessor(SwitchYardConsumer.java:91)
                            at org.switchyard.component.camel.SwitchYardConsumer.handleMessage(SwitchYardConsumer.java:62)
                            at org.switchyard.bus.camel.processors.ProviderProcessor.process(ProviderProcessor.java:39)
                            at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.switchyard.bus.camel.audit.FaultProcessor.process(FaultProcessor.java:52)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:330)
                            at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)
                            at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
                            at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
                            at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:122)
                            at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:61)
                            at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
                            at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
                            at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63)
                            at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:360)
                            at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:331)
                            at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:227)
                            at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:331)
                            at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:169)
                            at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:111)
                            at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:97)
                            at org.switchyard.bus.camel.ExchangeDispatcher.dispatch(ExchangeDispatcher.java:64)
                            at org.switchyard.internal.ExchangeImpl.sendInternal(ExchangeImpl.java:203)
                            at org.switchyard.internal.ExchangeImpl.send(ExchangeImpl.java:114)
                            at org.switchyard.component.camel.SwitchYardProducer.process(SwitchYardProducer.java:103)
                            at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:120)
                            at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:292)
                            at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:115)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:330)
                            at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)
                            at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
                            at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
                            at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
                            at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
                            at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
                            at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
                            at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
                            at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
                            at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:104)
                            at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:560)
                            at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:498)
                            at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467)
                            at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)
                            at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)
                            at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1058)
                            at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1050)
                            at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:947)
                            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
                            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
                            at java.lang.Thread.run(Thread.java:662)
                  Caused by: javax.xml.soap.SOAPException: Unable to parse SOAP Message
                            at org.switchyard.component.soap.composer.SOAPMessageComposer.decompose(SOAPMessageComposer.java:173)
                            at org.switchyard.component.soap.composer.SOAPMessageComposer.decompose(SOAPMessageComposer.java:55)
                            at org.switchyard.component.soap.OutboundHandler.handleMessage(OutboundHandler.java:140)
                            ... 185 more
                  Caused by: org.switchyard.exception.SwitchYardException: Error parsing DOM source.
                            at org.switchyard.transform.ootb.xml.AbstractDOMTransformer.parse(AbstractDOMTransformer.java:106)
                            at org.switchyard.transform.ootb.xml.BasicDOMTransformer.transformFromInputSource(BasicDOMTransformer.java:116)
                            at org.switchyard.transform.ootb.xml.BasicDOMTransformer.transform(BasicDOMTransformer.java:71)
                            at org.switchyard.internal.DefaultMessage.getContent(DefaultMessage.java:111)
                            at org.switchyard.component.soap.composer.SOAPMessageComposer.decompose(SOAPMessageComposer.java:148)
                            ... 187 more
                  Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
                            at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:246)
                            at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
                            at org.switchyard.transform.ootb.xml.AbstractDOMTransformer.parse(AbstractDOMTransformer.java:104)
                            ... 191 more
                  
                  

                   

                  Thank you!

                  • 6. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
                    kcbabo

                    My guess is the output of String.format is something wonky in your transformer based on this:

                    Content is not allowed in prolog.

                     

                    Can you System.out.println() the output of that inside your transformer and let us know what you see?  You can also attach you entire project if that doesn't help.

                    • 7. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
                      mageshbk

                      I think the transformer is not being picked up, notice this org.switchyard.transform.ootb.xml.AbstractDOMTransformer in the trace. Maybe you can try adding the transformer explicitly in the switchyard config

                      • 8. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
                        mageshbk

                        Wait a minute! I think I know why the transformer is not being picked up. According to your config

                                        <sca:reference name="HelloWorldWS">
                                        <sca:interface.wsdl interface="http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS?wsdl#wsdl.porttype(HelloWorld)" />
                                    </sca:reference>
                                </sca:component>
                                <sca:reference name="HelloWorldWS" promote="MyServiceCategory/HelloWorldWS" multiplicity="1..1">
                                    <soap:binding.soap>
                                        <soap:wsdl>http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS?wsdl</soap:wsdl>
                                        <soap:endpointAddress>http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS</soap:endpointAddress>
                                    </soap:binding.soap>
                                </sca:reference>
                        

                         

                        So this effectively becomes like this at runtime

                                        <sca:reference name="HelloWorldWS">
                                        <sca:interface.wsdl interface="http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS?wsdl#wsdl.porttype(HelloWorld)" />
                                    </sca:reference>
                                </sca:component>
                                <sca:reference name="HelloWorldWS" promote="MyServiceCategory/HelloWorldWS" multiplicity="1..1">
                                    <sca:interface.wsdl interface="http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS?wsdl#wsdl.porttype(HelloWorld)" />
                                    <soap:binding.soap>
                                        <soap:wsdl>http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS?wsdl</soap:wsdl>
                                        <soap:endpointAddress>http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS</soap:endpointAddress>
                                    </soap:binding.soap>
                                </sca:reference>
                        

                         

                        Notice the extra sca:interface added above. This is implicitly understood at runtime. So basically the consumer(service that uses a reference) and provider(the reference binding) both use the same interface here, that being the same WSDL types. So the transformer should be labeled like this below

                            @Transformer(from="{http://webservice_consumer1/helloworld}sayHello", to = "{http://webservice_consumer1/helloworld}sayHello")
                            public Element transform(String message) throws Exception {
                                return toElement(String.format(SOAP_TEMPLATE, message));
                            }
                        
                            @Transformer(to="{http://webservice_consumer1/helloworld}sayHelloResponse", from = "{http://webservice_consumer1/helloworld}sayHelloResponse")
                            public String transform(Element soap) throws Exception {
                                return getElementValue(soap, "return");
                            }
                        
                        
                        • 9. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
                          tadayosi

                          Awesome!  Now It works like a charm. Thanks a lot

                           

                          Lastly, please let me ask one more question. This insight naturally leads me to another configuration option like the below. However, this option in turn doesn't work. Can you explain why it doesn't work?

                           

                           

                                       <sca:reference name="HelloWorldWS">
                                          <interface.esb inputType="java:java.lang.String" />
                                      </sca:reference>
                                  </sca:component>
                                  <sca:reference name="HelloWorldWS" promote="MyServiceCategory/HelloWorldWS" multiplicity="1..1">
                                      <soap:binding.soap>
                                          <soap:wsdl>http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS?wsdl</soap:wsdl>
                                          <soap:endpointAddress>http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS</soap:endpointAddress>
                                      </soap:binding.soap>
                                  </sca:reference>
                          

                           

                           

                              @Transformer(to = "{http://webservice_consumer1/helloworld}sayHello")
                              public Element transform(String message) throws Exception {
                                  return toElement(String.format(SOAP_TEMPLATE, message));
                              }
                              
                              @Transformer(from = "{http://webservice_consumer1/helloworld}sayHelloResponse")
                              public String transform(Element soap) throws Exception {
                                  return getElementValue(soap, "return");
                              }
                          
                          • 10. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
                            kcbabo

                            Can you attach your entire project please?  Something isn't right here.  You should never have to define a transformer from and to the same type.  We should never look for a transformer from/to the same type since no transformation is necessary.  The fact that changing the transformer definition worked indicates to me that something else is wrong. 

                            • 11. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
                              tadayosi

                              Attached please find my project. Thank you for taking time to investigate this issue.

                              • 12. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
                                kcbabo

                                Sorry to take so long to reply.  Had some other stuff to do before I could get around to testing this out.  Good news is that as soon as I had the complete project it was pretty clear what was wrong.  Not sure how I missed this earlier but the contract definitions in your switchyard.xml are incorrect.  Here's a snip with the corrected bits:

                                 

                                <sca:component name="MyServiceCategory">
                                            <sca:service name="WebserviceConsumer1">
                                                <interface.esb inputType="java:java.lang.String" />
                                            </sca:service>
                                            <camel:implementation.camel>
                                                <spring:route id="org.switchyard.quickstarts.webservice.consumer1.WebserviceConsumer1">
                                                    <spring:log message="Request is: ${body}" />
                                                    <spring:to uri="switchyard://HelloWorldWS?operationName=sayHello" />
                                                    <spring:log message="Response is: ${body}" />
                                                </spring:route>
                                            </camel:implementation.camel>
                                            <sca:reference name="HelloWorldWS">
                                                <interface.esb inputType="java:java.lang.String" />
                                            </sca:reference>
                                        </sca:component>
                                        <sca:reference name="HelloWorldWS" promote="MyServiceCategory/HelloWorldWS" multiplicity="1..1">
                                            <sca:interface.wsdl interface="http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS?wsdl#wsdl.porttype(HelloWorld)" />
                                            <soap:binding.soap>
                                                <soap:wsdl>http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS?wsdl</soap:wsdl>
                                                <soap:endpointAddress>http://localhost:8080/Quickstart_webservice_consumer1/HelloWorldWS</soap:endpointAddress>
                                            </soap:binding.soap>
                                        </sca:reference>
                                

                                 

                                 

                                The first thing to note is that the contract you had declared for your component reference was incorrect.  You were specifying WSDL, which implies that the consumer (Camel in this case) was passing the XML input message defined in the sayHello operation in that contract.  You were, in fact, passing a String.  Since the consumer contract was declared to be XML, there was no transformation required for the promoted composite reference which explains why the SOAP gateway choked on it.  Note the change above to use a component reference with a contract type of java.lang.String.  The composite reference uses the WSDL interface type.  With this in place the runtime will detect that it needs to transform between String and the XML type and your transformer will be invoked.

                                 

                                After the above edits, change you Transformer definition back to what it originally was and run again:

                                 

                                @Transformer(to = "{http://webservice_consumer1/helloworld}sayHello")
                                    public Element transform(String message) throws Exception {
                                        return toElement(String.format(SOAP_TEMPLATE, message));
                                    }
                                

                                 

                                I tested this locally (after creating a test client so I could test your application ;-) ) and it worked.

                                • 13. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
                                  kcbabo

                                  BTW, I'm very happy to see that you are looking at mapping JBossESB features to SwitchYard.  This will be great input, so please keep posting questions and feedback. :-)

                                   

                                  Some other random things which I forgot to mention above:

                                   

                                  • I noticed in your application that you are using a route definition embedded in switchyard.xml.  This has been disabled through the tooling for a while and runtime support will be removed before 1.0 is complete.  If you want to use XML routes, definitely create a distinct file and reference from the implementation definition in switchyard.xml.
                                  • Speaking of tooling, you might want to give our editor a spin as you try implementing other ESB quickstarts on SY.  Aside from catching the above issue, I think it would help make the contract issues clearer and overall provides a nicer experience than hand editing the XML.
                                  • I noticed you are using an HTTP URL for the contract definition instead of pointing to a deployment-local resource.  I would recommend against this approach since it makes your deployment dependent on a remote resource which is not expected to change.  It will work in the runtime, but it's safer to just park the WSDL in your application when possible.
                                  • I added the operationName parameter to the switchyard endpoint URI in the switchyard.xml above, but it's actually not necessary since there's only one operation.  Just FYI.
                                  • 14. Re: JBoss ESB's SOAPClient equivalents in SwitchYard?
                                    tadayosi

                                    Keith, thank you for the answer. It works nicely   I may add to it that I have to configure the reference to "HelloWorldWS" inside the component as follows in order to complete my example:

                                     

                                                <sca:reference name="HelloWorldWS">
                                                    <interface.esb inputType="java:java.lang.String" outputType="java:java.lang.String" />
                                                </sca:reference>
                                    

                                     

                                    Thanks also for the detailed advices. It helps me a lot. Yeah, I'm working on a project which tries to convert JBoss ESB's quickstarts to SY so that we can better understand the capabilities of SY. Here is the GitHub repository for the project (it's just getting started).

                                    https://github.com/tadayosi/soa6-migration

                                     

                                    I'm sure I'll keep posting questions and feedback here. Thanks again.