1 2 3 Previous Next 30 Replies Latest reply on Jun 4, 2013 10:29 PM by Magesh Bojan

    Need Help on How to call WebService proxy in Swicthyard

    maran selva Newbie

      Hi ,

       

            I am new to switchyard.

            I want a quickstart project in switchyard to invoke a client webservice API available in my client location which has  a method addNumbers($arg1,$arg2). the given the endpoint url.

       

      can any one help me , i tried switchyard-quickstart-camel-soap-proxy available in switchyard-as7-0.8.Final distribution package donloaded from Jbos SwitchYard.

        • 1. Re: Need Help on How to call WebService proxy in Swicthyard
          Magesh Bojan Master

          Hi,

           

          Are you looking anything in particular with that quickstart? Here is set of videos that can help you walthrough in creating SwitchYard applications.

           

          https://community.jboss.org/wiki/SwitchYardVideoSeries

          • 2. Re: Need Help on How to call WebService proxy in Swicthyard
            maran selva Newbie

            Thanks Magesh,

             

                                   I already tried that video's but it tell how to create new web Service, but i want to use the existing webservice using switchyard,

            some thing like this,but this code was done in Javax

            how to call the service endpoint URL using switchyard ,

             

              @Override

                public Object getService(String serviceClassName, String serviceName, String serviceURL) {

                    try {

                        clientFactory = new JaxWsProxyFactoryBean();

                        clientFactory.setServiceClass(Class.forName(serviceClassName));

                    } catch (ClassNotFoundException e) {

                        throw new RiceRuntimeException("Failed to connect to soap service because failed to load interface class: ", e);

                    }

                    QName namespaceURI = new QName("http://service.select.ole.org/", "oleExposedWebService");

                    clientFactory.setServiceName(namespaceURI);

                    clientFactory.setAddress(serviceURL);

                    Object service = clientFactory.create();

                    return service;

                }

            • 3. Re: Need Help on How to call WebService proxy in Swicthyard
              Magesh Bojan Master

              In SwitchYard you create a reference binding to that endpoint's WSDL and use an Interface to communicate to that endpoint. All the underlying stuff will be handled automatically. Here is a thread where I think you will find the answers.

               

              https://community.jboss.org/message/799852#799852

               

              I thought that Keith created a demo video somewhere, but couldn't find it.

               

              Here is another thread that has more information on how the soap-proxy QS was created.

               

              https://community.jboss.org/thread/175816?start=0&tstart=0

               

              If these still doesn't help then please let me know.

              • 4. Re: Need Help on How to call WebService proxy in Swicthyard
                Magesh Bojan Master

                Sorry, my post was half-baked, so I edited it. We also recommend to download the remote endpoints WSDL and use it in your project.

                • 5. Re: Need Help on How to call WebService proxy in Swicthyard
                  maran selva Newbie

                  Magesh,

                   

                              actually the client doesn't have any WSDL they written the Web Service API in PERL script( attached the file how they are calling their Service using PER script client programme).

                   

                  In that they mentioneda host ("http://81.133.138.121:8383";)  as end point and

                                                     URI :urn:cdl_wsfunctions 

                   

                  like this when i discussed with the them they said you need to call

                  like http://81.133.138.121:8383/addRequest

                  addRequest is oneof the methods in the Webservice client programme.

                   

                  if you dont mine can you help me how to call this webService API without WSDL and no ServiceName

                   

                  they given only endpoint URL and URI.

                  • 6. Re: Need Help on How to call WebService proxy in Swicthyard
                    Magesh Bojan Master

                    Usually without knowing what that service accepts as Input and what it provides as Output it is difficult to program a Java SOAP client. Not that it is not possible, you can use a plain Http binding to send and receive the messages. But you will need to construct the SOAP message manually and parse the response manually. I think the SOAP::Lite Perl library hides these things underneath. It maybe just a String displayed in the command line, but underneath these need to map to some objects when you port to Java. You provided code for getting a service in Java, but how are the methods invoked on that service, have you thought about that? Besides that, that method getService accepts a ServiceName too, right?

                     

                    Okay, enough with my blah blahs! There are three ways to do this:

                     

                    1. Create a Java Interface with the known method names, input and output and then generate a WSDL using the Java tool wsprovide. Then this WSDL can be used in SwitchYard.

                    2. Create a JAXRS Interface with the method type, input and output and then use it in SwitchYard's RESTEasy reference binding. Checkout our rest-binding quickstart.

                    3. Use our Http binding and send and receive information as needed. Do manual processing of request and response.

                     

                    regards,

                    Magesh

                    • 7. Re: Need Help on How to call WebService proxy in Swicthyard
                      maran selva Newbie

                      Thanks Magesh,

                       

                                           i am able to call the service using the following code,available in BeanClient.java in switchyard-quickstart-bean-service

                       

                      --------------------------------------------------------------------------------------------

                      private static final String URL = "http://81.133.138.121:8383";

                          private static final String XML = "src/test/resources/xml/soap-request.xml";

                       

                       

                          /**

                           * Private no-args constructor.

                           */

                          private BeanClient() {

                          }

                       

                       

                          /**

                           * Only execution point for this application.

                           * @param ignored not used.

                           * @throws Exception if something goes wrong.

                           */

                          public static void main(final String[] ignored) throws Exception {

                       

                       

                              HTTPMixIn soapMixIn = new HTTPMixIn();

                              soapMixIn.initialize();

                       

                       

                              try {

                                  String result = soapMixIn.postFile(URL, XML);

                                  System.out.println("SOAP Reply:\n" + result);

                              } finally {

                                  soapMixIn.uninitialize();

                              }

                          }

                       

                      __________________________________________________________________________________________________________

                       

                      this is my soap_request.xml

                       

                      <?xml version="1.0" encoding="UTF-8"?>

                      <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">

                                <soap:Body>

                                                    <orders:hi xmlns:orders="urn:cdl_wsfunctions">

                       

                                          </orders:hi>

                                </soap:Body>

                      </soap:Envelope>

                      ____________________________________________________________________________________________________________

                       

                      now when i click Search in my screen , i want to invoke the hi method so i changed the code as follows, refer the attachment(SearchMoleculeAction.java)

                       

                      so when i click search in my screen it will call the subStructure1()--> callService()

                       

                      and guide me whether i am goin in right direction or not , because now when i build the application using mvn clean install

                      it tells the following error,

                       

                       

                      SearchMoleculeAction.java:[91,13] error: cannot access AbstractTestMixIn

                      • 8. Re: Need Help on How to call WebService proxy in Swicthyard
                        Magesh Bojan Master

                        The HTTPMixin is for testing standalone SwitchYard tests. I think my links were not visible to you in my post. Here they are:

                         

                        https://docs.jboss.org/author/display/SWITCHYARD/RESTEasy

                        https://docs.jboss.org/author/display/SWITCHYARD/HTTP

                         

                        That aside, you will need to use a reference binding to call the external service. I started brewing a sample for you. Will let you know when that is ready.

                         

                        regards,

                        Magesh

                        • 9. Re: Need Help on How to call WebService proxy in Swicthyard
                          Magesh Bojan Master

                          Here is a simple example showing how to call the Perl service using Http binding in SwitchYard. It is a Maven project. If you deploy the target\JsfSample-1.0.war, you can access the url http://<yourserver>:<yourport>/jsf-sample and click the search button to invoke the service. You should see the SOAP response printed below on the same page. Here is how the application is designed in SwitchYard.

                           

                          jsf-sample.jpg

                          regards,

                          Magesh

                          • 10. Re: Need Help on How to call WebService proxy in Swicthyard
                            Magesh Bojan Master

                            BTW, most of the Seam/Weld functionality has been replace by CDI in Java EE 6. I have used a CDI bean here in my example. Note that it acts both as bean as well as a SwitchYard service.

                            • 11. Re: Need Help on How to call WebService proxy in Swicthyard
                              maran selva Newbie

                              Magesh,

                               

                                               I dont have word to express my heartful thanks to you.You are really great person.

                              helped me .

                              • 12. Re: Need Help on How to call WebService proxy in Swicthyard
                                sheriman xavier Newbie

                                Hi Magesh,

                                 

                                I try to build jsfSample project, but showing error like this.

                                 

                                 

                                [ERROR] Plugin org.switchyard:switchyard-plugin:1.0.0-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.switchyard:switchyard-plugin:jar:1.0.0-SNAPS

                                HOT: Could not find artifact org.switchyard:switchyard-plugin:pom:1.0.0-SNAPSHOT -> [Help 1]

                                [ERROR]

                                [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

                                [ERROR] Re-run Maven using the -X switch to enable full debug logging.

                                [ERROR]

                                [ERROR] For more information about the errors and possible solutions, please read the following articles:

                                [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

                                 

                                • 13. Re: Need Help on How to call WebService proxy in Swicthyard
                                  Magesh Bojan Master

                                  Looks like the 1.0.0-SNAPSHOTs have not been published yet. Can you try 0.8.0.Final as the version in the pom?

                                   

                                  regards,

                                  Magesh

                                  • 14. Re: Need Help on How to call WebService proxy in Swicthyard
                                    maran selva Newbie

                                    Magesh,

                                     

                                    after changing the 1.0.0-SNAPSHOTs to 0.8.0.Final , when i start mvn clean install

                                    follwoing error is coming

                                     

                                    [WARNING] The POM for org.switchyard:switchyard-plugin:jar:0.8.0.Final is missing, no dependency information available

                                    [INFO] ------------------------------------------------------------------------

                                    [INFO] BUILD FAILURE

                                    [INFO] ------------------------------------------------------------------------

                                    [INFO] Total time: 0.170s

                                    [INFO] Finished at: Tue May 28 13:56:25 SGT 2013

                                    [INFO] Final Memory: 12M/480M

                                    [INFO] ------------------------------------------------------------------------

                                     

                                    Plugin org.switchyard:switchyard-plugin:0.8.0.Final or one of its dependencies could not be resolved: Failed to read artifact descriptor

                                    for org.switchyard:switchyard-plugin:jar:0.8.0.Final: Failure to find org.switchyard:switchyard-plugin:pom:0.8.0.Final

                                    in https://maven.java.net/content/groups/public/ was cached in the local repository,

                                    resolution will not be reattempted until the update interval of java-net-public has elapsed or updates are forced -> [Help 1]

                                    1 2 3 Previous Next