1 2 Previous Next 24 Replies Latest reply on May 24, 2013 3:48 AM by boanergesza11 Go to original post
      • 15. Re: Step-to-step guide on how to invoke external web service from a bean component in Switchyard 0.5
        jonbondash

        Hi Magesh,

         

        We have followed the steps given in the rest-binding quickstarts. But we are not looking for that one.

         

        Our scenario is:

         

        1) We have created a SY hornetq, from where we tried to inject external SY rest service. But, we are not able to reach the external SY rest service.

             we have tried with both resteasy & Http binding approach, but no success.

         

         

        Plz, let us know, what are the steps need to make it workable.

         

        Thanks & Regards,

        Jonbon Dash

        • 16. Re: Step-to-step guide on how to invoke external web service from a bean component in Switchyard 0.5
          mageshbk

          Hi Jonbon,

           

          Would it be possible for you to include any of the quickstart to showcase your scenario or better still, add your scenario app with a simple usecase for us to help you better?

           

          thanks,

          Magesh

          • 17. Re: Step-to-step guide on how to invoke external web service from a bean component in Switchyard 0.5
            dmanibtech

            Magesh,

             

            This is just to give you brief intro about our plans,

             

            In our project we want to use SY to integrate our external REST services to perform distributed workflow components execution.

             

            Just to elaborate,

            1. A workflow is created with the components, A->B->C->D [where all the components are REST services]

            2. The components A & B will be executed on Server1

            3. Calling component C (the service routing), we are planning to use Switchyard with hornetQ (to persist the messages)

            4. As said, components C & D will be executed on Server2.

             

            This is our problem statement.

             

            We need your inputs on these areas,

              1. What would be idealistic approach to attempt this problem?

                   a. How to route the external REST calls inside the SY?

                   b. How can we post messages from WF to th SY?

                   c. Persisting messages (to provide failover feature) - we are planning to go with HornetQ? Is there any other alternative solution available?

             

            Regards,

            Mani

            • 18. Re: Step-to-step guide on how to invoke external web service from a bean component in Switchyard 0.5
              jonbondash

              Hi Magesh,

               

              Please find the attachment.

               

              Thanks & Regards,

              Jonbon Dash

              • 19. Re: Step-to-step guide on how to invoke external web service from a bean component in Switchyard 0.5
                mageshbk

                Hi Jonbon,

                 

                Thanks for the sample. It really helped to see what is wrong in the end.

                 

                Your hornetq-binding/org.switchyard.quickstarts.hornetq.GreetingServiceBean was using a different package of HelloService and Product classes. Could you change it to use com.example.switchyard.switchyard_rest_example as it is mentioned in the switchyard.xml? I think there is something weird in the Bean/RESTEasy component or the transformer module that is causing this issue. I need to investigate this further.

                 

                Further, you should use our latest version 0.8.Final. We have done some changes to RESTEasy component in 0.8. Besides, Hornetq is no longer supported as a direct component in this new version rather you can use JCA or Camel-JMS. For persistance you might want to look at our JPA component.

                • 20. Re: Step-to-step guide on how to invoke external web service from a bean component in Switchyard 0.5
                  mageshbk

                  For your external REST service invocation the reference binding should be like this

                      <sca:reference name="HelloService" multiplicity="0..1" promote="GreetingServiceBean/HelloService">
                        <resteasy:binding.rest>
                          <resteasy:contextMapper/>
                          <resteasy:interfaces>com.example.switchyard.switchyard_rest_example.JSONService</resteasy:interfaces>
                          <resteasy:address>http://localhost:8080/resttest</resteasy:address>
                        </resteasy:binding.rest>
                      </sca:reference>
                  
                  
                  • 21. Re: Step-to-step guide on how to invoke external web service from a bean component in Switchyard 0.5
                    mageshbk

                    Okay, if you use com.example.switchyard.switchyard_rest_example.Product in your hornetq-binding/switchyard.xml derived from com.example.switchyard.switchyard_rest_example.HelloService interface, then SwitchYard expects a transformer from com.example.switchyard.switchyard_rest_example.Product to org.switchyard.quickstarts.hornetq.Product, which is not thrown as any WARN/ERROR. This need to be addressed.

                     

                    Apart from that if you use the same types in both the servers it should work. If it doesn't let me know.

                     

                    thanks,

                    Magesh

                    • 22. Re: Step-to-step guide on how to invoke external web service from a bean component in Switchyard 0.5
                      jonbondash

                      Hi Magesh,

                       

                      I have tried with the approach (by renaming the hornetq project's package name with "com.example.switchyard.switchyard_rest_example" )  as suggested and added with the rest-easy binding in the reference binding section of HornetQ project. It's throwing the below exception:

                       

                      19:12:46,377 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."switchyard-quickstart-hornetq-binding.jar".SwitchYardService: org.jboss.msc.service.StartException in service jboss.deployment.unit."switchyard-quickstart-hornetq-binding.jar".SwitchYardService: java.lang.RuntimeException: Encountered unknown REST method type.

                                at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:85)

                                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]

                                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0]

                                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0]

                                at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0]

                      Caused by: java.lang.RuntimeException: Encountered unknown REST method type.

                                at org.switchyard.component.common.rest.RsMethodUtil.parseResources(RsMethodUtil.java:188)

                                at org.switchyard.component.resteasy.OutboundHandler.start(OutboundHandler.java:74)

                                at org.switchyard.deploy.internal.Deployment.deployReferenceBindings(Deployment.java:283)

                                at org.switchyard.deploy.internal.Deployment.start(Deployment.java:139)

                                at org.switchyard.as7.extension.deployment.SwitchYardDeployment.start(SwitchYardDeployment.java:106)

                                at org.switchyard.as7.extension.services.SwitchYardService.start(SwitchYardService.java:78)

                                ... 5 more

                       

                       

                      I have one query, as we expose the rest-service name as HelloService, so why we need to define the JSONService in the reference section?

                       

                      I have attached the modified project for further clarification.

                       

                      Thanks & Regards,

                      Jonbon Dash

                      • 23. Re: Step-to-step guide on how to invoke external web service from a bean component in Switchyard 0.5
                        mageshbk

                        From your project I see you have not included the com.example.switchyard.switchyard_rest_example.JSONService class or you may not have shared that with me. The error above indicates that one of the method annotation in that interface is not supported or there is no @GET, @POST annoations in that interface. This error is thrown in older version of SwitchYard. The latest one 0.8 should behave differently. As I mentioned above, please use the latest version, it has some major enhancement.

                         

                        You need to define JSONService because it is the contract, based on which the client invoker is created. Something similar to SOAP WSDL. You can define a new class with a different name, something like a subset of the REST provider's interface, but the JAX-RS annotations need to be present.

                        • 24. Re: Step-to-step guide on how to invoke external web service from a bean component in Switchyard 0.5
                          jonbondash

                          Hi Magesh,

                           

                          Thanks for your quick response and great help.

                           

                          One more change with respect to your suggestion, as per EJB specification we need to specify the injection code like below,

                           

                          @Inject @Named('helloServiceBean') // where 'helloServiceBean' is [SY_CDI_BEAN_NAME]

                          private HelloService service;

                           

                          So with this we can call external REST services.

                           

                           

                          Thanks & Regards,

                          Jonbon Dash

                          • 25. Re: Step-to-step guide on how to invoke external web service from a bean component in Switchyard 0.5
                            boanergesza11

                            May I ask how far that video is coming along? I am now stuck in the same place as well...

                            1 2 Previous Next