1 Reply Latest reply on Sep 16, 2010 7:09 AM by lalit jangra

    How to expose a jbpm workflow as web service.

    lalit jangra Newbie

      Hi,

       

      I have created a sample workflow in jbpm 3.2.6 & using jbpm-console over tomcat 6 & mysql db.

       

      Now as per use case, i need to expose it as a web service so that any third party can invoke it.

       

      I googled a lot but of little help.

       

      Does jbpm support this feature in 3.2 version?

       

      If yes, How can i do it?

       

      Any help will be highly appreciated.

        • 1. Re: How to expose a jbpm workflow as web service.
          lalit jangra Newbie

          Hi All,

           

          You can use the following code to trigger a workflow in java.

           

          /**
               * Method to trigger workflow dynamically.
               */
              public void exposeWorkflowAsWebService(){
                  JbpmContext jbpmContext = null;
                  try{
                      System.out.println("Invoking a workflow");
                      jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
                      ProcessInstance processInstance = jbpmContext.newProcessInstance("NotificationWorkflow");
                      while (!processInstance.isTerminatedImplicitly()) {
                          processInstance.signal();           
                      }
                  }catch (Exception e) {
                      System.out.println("Error while invoking workflow : "+e.getMessage());
                      e.printStackTrace();
                  }finally {       
                      System.out.println("Finally closing jbpmContext.");
                      jbpmContext.close();   
                      }
              } 

           

          This java code can be exposed as web service & used as needed.