4 Replies Latest reply on Apr 23, 2015 6:41 AM by nello360

    How to invoke external web service???

    nello360

      Hi all,

      I have a problem: I want to consume an external web service and edit its output in my switchard application.

      For example I want to consume this service http://www.w3schools.com/webservices/tempconvert.asmx?wsdl and edit the output (such as I want to add the C or  F symbol in temperature result).

      I know that to consume Switchyard service I have to use the @Reference and @Inject annotation, but it's only for "switchyard service"...but it does not work for external web service...

      So, what is the procedure to consume external web service and edit its output?

       

      thank's all.

        • 1. Re: How to invoke external web service???
          jorgemoralespou_2

          Hi Nello,

          What do you mean with edit the output in your switchyard service?

          This scenario that you describe is the normal:

           

          Create a switchayrd app with:

          - A composite service that you'll use to invoke the service (can be the same as the end service or a different one)

          - A component. Camel or Java component, but depending on your selection, you'll have to work in a different maner, using Java, and @Reference annotations to the reference, or just a to("switchyard://YourCompositeReference")

          - A composite reference that will consume the end service, and where you'll configure the backend endpoint.

           

          I recommend you to read the docs (to settle the concepts), and play with the quickstarts, specially with this one: https://github.com/jboss-switchyard/quickstarts/tree/master/camel-soap-proxy

           

          Hope it helps,

          • 2. Re: How to invoke external web service???
            nello360

            with edit the output, I mean, for example,  that if the external service return a string (such as "100"), my service concats another string (such as "C" , then my service will return "100 C")

             

            switchyard.png

            this is what i did...

            I have an external soap web service that converts the temperature and return the result

            my bean cosnume the service and concat the result; the bean is promoted as a web service.

             

            I did my bean like this:

             

            import javax.inject.Inject;
            import org.switchyard.component.bean.Reference;
            import org.switchyard.component.bean.Service;
            
            
            @Service(MyConvert.class)
            public class MyConvertBean implements MyConvert {
              @Reference
              @Inject
              TempConvertSoap t;
              @Override
              public String converti(String temp) {
              // TODO Auto-generated method stub
              String result = t.CelsiusToFahrenheit(temp)+ " F";
              System.out.println("ok");
              return result;
              }
            }
            

             

            but it does not work...It is correct or I have done somethig wrong?

             

            I hope I have been clearer now.

            thanks for all

            • 3. Re: How to invoke external web service???
              jorgemoralespou_2

              Hi Nello,

              This is fine, as long as you have converters properly defined.

              Your external service is wsdl (with XML elements as parameters), your component interface is Java with a String as parameters, so as long as you convert everything properly, this should work.

               

              Check this:

              http://unpoucode.blogspot.se/2014/10/switchyard-contracts.html

              https://docs.jboss.org/author/display/SWITCHYARD11/Transformers

               

              Hope it helps,

              • 4. Re: How to invoke external web service???
                nello360

                thank's!!!

                 

                I had a problem with the transformer!

                 

                Bye