5 Replies Latest reply on Jan 14, 2008 9:12 AM by kukeltje

    Invoke a WebService from ActionHandler

    dadajboss

      Hi all.
      I'm trying to invoke a web service from my jBoss/jBPM process.
      As Ronald suggests in this post:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=70723
      I write an actionhandler which invokes the webservice and then I associate it on a node-enter event of a node.
      But when I run the process from jBoss-jBpm console I get an exception

      description The server encountered an internal error () that prevented it from fulfilling this request.
      
      exception
      
      javax.servlet.ServletException: Servlet execution threw an exception
       org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      
      root cause
      
      java.lang.NoClassDefFoundError: org/apache/axis/client/Service
       com.Process_3.WebServiceAction.execute(WebServiceAction.java:22)
       org.jbpm.graph.def.Action.execute(Action.java:122)
       org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:264)
       org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:220)
       org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:190)
       org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:174)
       org.jbpm.graph.def.Node.enter(Node.java:303)
       org.jbpm.graph.def.Node$$FastClassByCGLIB$$d187eeda.invoke(<generated>)
       net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:163)
       org.jbpm.graph.def.Node$$EnhancerByCGLIB$$ad2fc36c.enter(<generated>)
       org.jbpm.graph.def.Transition.take(Transition.java:151)
       org.jbpm.graph.def.Node.leave(Node.java:394)
       org.jbpm.graph.node.TaskNode.leave(TaskNode.java:209)
       org.jbpm.graph.node.TaskNode$$FastClassByCGLIB$$923668a4.invoke(<generated>)
       net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:163)
       org.jbpm.graph.node.TaskNode$$EnhancerByCGLIB$$e933732a.leave(<generated>)
       org.jbpm.graph.exe.Token.signal(Token.java:195)
       org.jbpm.graph.exe.Token.signal(Token.java:140)
       org.jbpm.graph.exe.Token$$FastClassByCGLIB$$74df1c6e.invoke(<generated>)
       net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
       org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:163)
       org.jbpm.graph.exe.Token$$EnhancerByCGLIB$$dc8930e8.signal(<generated>)
       org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:485)
       org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:399)
       org.jbpm.jsf.core.action.CompleteTaskActionListener.handleAction(CompleteTaskActionListener.java:47)
       org.jbpm.jsf.core.impl.JbpmActionListenerWrapper.processAction(JbpmActionListenerWrapper.java:82)
       javax.faces.event.ActionEvent.processListener(ActionEvent.java:77)
       javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:758)
       javax.faces.component.UICommand.broadcast(UICommand.java:368)
       org.jbpm.jsf.taskform.ui.UITaskFormButtonBase.broadcast(UITaskFormButtonBase.java:56)
       javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:448)
       javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
       com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
       com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
       com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
       org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      


      This is the ActionHandler code:
      package com.Process_3;
      
      import org.jbpm.graph.def.ActionHandler;
      import org.jbpm.graph.exe.ExecutionContext;
      import org.apache.axis.client.Call;
      import org.apache.axis.client.Service;
      import org.apache.axis.encoding.XMLType;
      
      
      import javax.xml.rpc.ParameterMode;
      
      
      public class WebServiceAction implements ActionHandler {
       private static final long serialVersionUID = 1L;
      
       public void execute(ExecutionContext executionContext) throws Exception {
       // Make the call
       String method = new String("Get_CodFisFromLocalita");
       String endpoint = "http://www.nexusonline.it:8088/4DWSDL";
       String city = (String) ("Milano");
      
       Service service = new Service();
       Call call = (Call) service.createCall();
      
       call.setTargetEndpointAddress(new java.net.URL(endpoint));
       call.setOperationName( method );
       call.addParameter(city, XMLType.XSD_STRING, ParameterMode.IN);
       call.setReturnType(XMLType.XSD_STRING);
      
       String ret = (String) call.invoke( new Object[] { city } );
      
       executionContext.getContextInstance().createVariable("sigla", ret);
      
       System.out.println("Result: " + ret);
       }
      
      }
      


      Note:
      I deploy the process by mean jBPD Eclipse plugin.

      Any help will be appreciated.
      Thank you!

        • 1. Re: Invoke a WebService from ActionHandler
          anuragpaliwal

          Its seems that axis jar file is not in classpath.

          Include it in your classpath.

          • 2. Re: Invoke a WebService from ActionHandler
            dadajboss

            anuragpaliwal, thanks for the answer.
            Execuse me for my "ignorance" when you say "Include it in your classpath" what do you mean in practical? There is some settings to do ?
            thank you.

            • 3. Re: Invoke a WebService from ActionHandler
              anuragpaliwal

              Add axis.jar file in jbpm-console.war's lib dir

              • 4. Re: Invoke a WebService from ActionHandler
                dadajboss

                Done! But I have still the following error:

                Error completing task: An exception of type "org.jbpm.graph.def.DelegationException" was thrown. The message is: ; nested exception is:
                 org.xml.sax.SAXParseException: Content is not allowed in prolog.


                I've also tried to call another webservice:
                String method = new String("GetQuote");
                 String endpoint = "http://www.webservicex.com/stockquote.asmx?WSDL";
                 String city = (String) ("IBM");
                

                and the error is:

                Error completing task: An exception of type "org.jbpm.graph.def.DelegationException" was thrown. The message is: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: .
                 at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
                 at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
                 at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)




                Do you have some idea?


                • 5. Re: Invoke a WebService from ActionHandler
                  kukeltje

                  'content not allowed in prolog' means there is data before <?xml.......?>

                  Not jbpm related at all....