3 Replies Latest reply on Jul 26, 2010 9:32 PM by aguizar

    Invoking a WebService from ActionHandler ?

    agentsmith0009

      Hi All,

       

      I am using jpdl 3.2.2 suite & using eclipse to deploy workflows on it.

       

      Inside my workflow , I am trying to invoke a Liferay web service from my jBoss/jBPM process.

       

      I have implemented an ActionHandler & trying to invoke web servie from here.

       

       



      public class KMNotifyAndReminderWorkflowActionHandler implements ActionHandler {
         
          private static Logger logger = Logger.getLogger(KMNotifyAndReminderWorkflowActionHandler.class);
          private static final long serialVersionUID = 1L;
          private String[] noOfUser;

          /**
           * Method to call web services from jBPM Handler.
           */
          @Override
          public void execute(ExecutionContext context) throws Exception {
              System.out.println("Inside execute() of KMNotifyAndReminderWorkflowActionHandler!!");
              logger.debug("Inside execute() of KMNotifyAndReminderWorkflowActionHandler!!");
              String noOfDays = (String) context.getVariable("noOfDays");
              int daysToPass = new Integer(noOfDays).intValue();
              Integer tempDays = new Integer(noOfDays);
              System.out.println("noOfDays inside execute() : " + noOfDays);
              String kmFlag = (String) context.getVariable("kmFlag");
              System.out.println("kmFlag inside execute() : " + kmFlag);
              if(kmFlag.equalsIgnoreCase("getUsers")){
                  System.out.println("For kmFlag !!!: "+kmFlag);
                  try{
                      // Make Web Service call to get not logged in users.
                      JbpmPropertyReader propertyReader = new JbpmPropertyReader();
                      String endpoint = propertyReader.getProperty("liferay.endpoint");
                      String method = propertyReader.getProperty("liferay.method");
                      Service service = new Service();
                      Call call = (Call) service.createCall();
                      call.setTargetEndpointAddress(new java.net.URL(endpoint));
                      call.setOperationName(method);
                      call.addParameter(noOfDays,XMLType.XSD_STRING,ParameterMode.IN);
                      call.setReturnClass(String.class);
                      call.setReturnType(XMLType.XSD_ANYTYPE);
                     
                      noOfUser  = (String[]) call.invoke(new Object[] { noOfDays });
                       if(noOfUser != null || noOfUser.length != 0){
                           for(int i = 0 ; i < noOfUser.length ; i++){
                               System.out.println("User Name : "+noOfUser[i]);
                           }
                       }
                       context.setVariable("noOfUser", noOfUser);
                  }catch (Exception e) {
                      System.out.println("Error while invoking web service in KMNotifyAndReminderWorkflowActionHandler : "+e.getMessage());
                      e.printStackTrace();
                  }
              }else if(kmFlag.equalsIgnoreCase("callEmailService")){
                  System.out.println("For kmFlag : "+kmFlag);
                  //Call email seb service.
              }else if(kmFlag.equalsIgnoreCase("remindUsers")){
                  //Schedule Reminder.
                  System.out.println("For kmFlag : "+kmFlag);
                  context.getTimer().setRetries(5);
                  int rptCnt = context.getTimer().getRetries();
                  System.out.println("rptCnt : "+rptCnt);
                  if(rptCnt > 5){
                      context.getNode().leave(context, "endTransition");
                  }
              }
          }
      }

       

       

       

       

      But when it runs, i can see following error on my tomcat console

       

       

       

      Error while invoking web service in KMNotifyAndReminderWorkflowActionHandler : org.xml.sax.SAXParseException: The content of elements must consist of
      well-formed character data or markup.
      AxisFault
      faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
      faultSubcode:
      faultString: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
      faultActor:
      faultNode:
      faultDetail:
              {http://xml.apache.org/axis/}hostname:liferay

      org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
              at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
              at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
              at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
              at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
              at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
              at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2938)

              at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
              at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
              at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
              at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
              at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
              at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
              at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
              at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
              at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
              at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
              at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
              at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
              at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
              at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
              at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
              at org.apache.axis.client.Call.invoke(Call.java:2767)
              at org.apache.axis.client.Call.invoke(Call.java:2443)
              at org.apache.axis.client.Call.invoke(Call.java:2366)
              at org.apache.axis.client.Call.invoke(Call.java:1812)
              at com.jindal.km.jbpm.KMNotifyAndReminderWorkflowActionHandler.execute(KMNotifyAndReminderWorkflowActionHandler.java:68)
              at org.jbpm.graph.def.Action.execute(Action.java:122)
              at org.jbpm.graph.def.GraphElement.executeAction(GraphElement.java:264)
              at org.jbpm.graph.def.GraphElement.executeActions(GraphElement.java:220)
              at org.jbpm.graph.def.GraphElement.fireAndPropagateEvent(GraphElement.java:190)
              at org.jbpm.graph.def.GraphElement.fireEvent(GraphElement.java:174)
              at org.jbpm.graph.def.Node.enter(Node.java:303)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:157)
              at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$c0568ab2.enter(<generated>)
              at org.jbpm.graph.def.Transition.take(Transition.java:151)
              at org.jbpm.graph.def.Node.leave(Node.java:394)
              at org.jbpm.graph.node.StartState.leave(StartState.java:70)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:157)
              at org.jbpm.graph.def.Node$$EnhancerByCGLIB$$c0568ab2.leave(<generated>)
              at org.jbpm.graph.exe.Token.signal(Token.java:195)
              at org.jbpm.graph.exe.Token.signal(Token.java:140)
              at org.jbpm.jsf.core.action.SignalActionListener.handleAction(SignalActionListener.java:52)
              at org.jbpm.jsf.core.impl.JbpmActionListenerWrapper.processAction(JbpmActionListenerWrapper.java:82)
              at javax.faces.event.ActionEvent.processListener(ActionEvent.java:77)
              at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:758)
              at javax.faces.component.UICommand.broadcast(UICommand.java:368)
              at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:448)
              at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
              at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
              at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
              at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
              at java.lang.Thread.run(Thread.java:619)

       

       

       

      I googled it & found following posts:

       

      http://community.jboss.org/message/390406#390406

       

      http://community.jboss.org/thread/112363?tstart=0

       

       

      But no help.I am stuck up here.

       

      Any help will be appreciated.
      Thank you!