4 Replies Latest reply on Oct 20, 2005 4:18 PM by Igor Brito Alves

    How can I invoke web services using jBoss jBpm?

    Igor Brito Alves Newbie

      My research group decided to use jBoss jBpm in our system. We'll need to invoke web services, but I only know how to execute Java classes in the action tags (jPdl). Can I invoke web services instead of java classes?

      thanks!

        • 1. Re: How can I invoke web services using jBoss jBpm?
          Ronald van Kuijk Master

          Currently you can't do this directly from a jBPM actionhandler (work is going on in one) so you have to write an actionhandler yourself which invokes the webservice. You can make this configurable any way you want.

          • 2. Re: How can I invoke web services using jBoss jBpm?
            Igor Brito Alves Newbie

            Cool, I'm happy to know that jBpm will permit web services invoking in future!

            But now, there's any example of an ActionHandler that invokes a web services? I don't know how to do this.

            thanks my friends!

            • 3. Re: How can I invoke web services using jBoss jBpm?
              Brian Bulthuis Newbie

               

              "bonfarj" wrote:

              But now, there's any example of an ActionHandler that invokes a web services? I don't know how to do this.


              As Ronald pointed out, you'll have to write your own code to call a ws at this point. The eclipse WTP project provides tools for creating java webservice clients, and Apache's Axis project provides (among other things) a client framework for making ws calls. There are many other options available, too. Here's an Axis example:

              import org.apache.axis.client.Call;
              import org.apache.axis.client.Service;
              
              import javax.xml.namespace.QName;
              
              import org.jbpm.graph.def.ActionHandler;
              
              public class MyActionHandler extends ActionHandler
              {
               public void execute(ExecutionContext executionContext) throws Exception {
               try {
               String endpoint = "http://nagoya.apache.org:5049/axis/services/echo";
              
               Service service = new Service();
               Call call = (Call) service.createCall();
              
               call.setTargetEndpointAddress( new java.net.URL(endpoint) );
               call.setOperationName(new QName("http://soapinterop.org/", "echoString") );
              
               // Call to addParameter/setReturnType as described in user-guide.html
               //call.addParameter("testParam",
               // org.apache.axis.Constants.XSD_STRING,
               // javax.xml.rpc.ParameterMode.IN);
               //call.setReturnType(org.apache.axis.Constants.XSD_STRING);
              
               String ret = (String) call.invoke( new Object[] { "Hello!" } );
              
               System.out.println("Sent 'Hello!', got '" + ret + "'");
               } catch (Exception e) {
               System.err.println(e.toString());
               }
               }
              }


              The axis code here is right from the axis user guide page at http://ws.apache.org/axis/java/user-guide.html.

              Hope that helps.

              Brian