Tutorial for Simple process with service task with call to an external webservice

3,059 views
Skip to first unread message

Victor

unread,
Oct 25, 2017, 11:30:52 AM10/25/17
to jBPM Usage
Hi Everyone,

I'm new to jbpm7 and I want based on the docs found here: https://docs.jboss.org/jbpm/release/7.3.0.Final/jbpm-docs/html_single/ to be able to create a simple process that calls a webservice.
For that I have installed Eclipse Oxygen with jBPM support. All is fine, the editor is there and working. Then I have created a simple jbpmn process with Start - Web service call -> error? Y/N gate which decide where to go and print a message.
Like in this picture:


Following the various examples, I discovered that the web service task needs an implementation. I assume that has to be defined somehow. I don't know how to do it.
So, to summarize, i think my understanding is not correct: I have defined a service task that will call an external web service service. What I would like to do is how to define for this service task
a java class that can call my external web service.
Here is the definition of the Service Task:

and the I/O


I saw that is also needed a file: kie-deployment-descriptor.xml, I have it with the following def:
 <work-item-handlers> 
        <work-item-handler> 
            <resolver>mvel</resolver> 
            <identifier>new com.sample.handlers.NwsItemHandler()</identifier> 
            <parameters/> 
            <name>Rest</name> 
        </work-item-handler> 
    </work-item-handlers> 
I believe that the service task needs an interface. Is that true?

Anyway, the error I have is this:
Exception in thread "main" org.jbpm.workflow.instance.WorkflowRuntimeException: [com.sample.nwsearch:236 - web service call:7] -- Could not find work item handler for Service Task
It seems that the link between the service task and my java class is not done. How do I do that? Is not the interface defined in Service Task -> Operation?
The project is maven, run from eclipse.
I will attach a zip file with the details. Please help or lead me in the correct direction.
Thank you!

jBPMDemo.zip
Auto Generated Inline Image 1
Auto Generated Inline Image 2
Auto Generated Inline Image 3

Maciej Swiderski

unread,
Oct 26, 2017, 2:26:55 AM10/26/17
to Victor, jBPM Usage
see if this helps: Service Task with web service implementation

might be bit outdated when it comes to editors layout but the content should give you enough to understand the concept.

when it comes registering you need to register handler under proper name - the exception tells you exactly the name of handler that is missing - in this case Service Task. jBPM comes with basic impl for service task that supports local java class or webservice via cxf dynamic client https://github.com/kiegroup/jbpm/blob/7.3.x/jbpm-workitems/jbpm-workitems-bpmn2/src/main/java/org/jbpm/process/workitem/bpmn2/ServiceTaskHandler.java

Maciej
On 25 Oct 2017, at 17:30, Victor <chirita.v...@groupehn.com> wrote:

Hi Everyone,

I'm new to jbpm7 and I want based on the docs found here: https://docs.jboss.org/jbpm/release/7.3.0.Final/jbpm-docs/html_single/ to be able to create a simple process that calls a webservice.
For that I have installed Eclipse Oxygen with jBPM support. All is fine, the editor is there and working. Then I have created a simple jbpmn process with Start - Web service call -> error? Y/N gate which decide where to go and print a message.
Like in this picture:
<Auto Generated Inline Image 1.png>


Following the various examples, I discovered that the web service task needs an implementation. I assume that has to be defined somehow. I don't know how to do it.
So, to summarize, i think my understanding is not correct: I have defined a service task that will call an external web service service. What I would like to do is how to define for this service task
a java class that can call my external web service.
Here is the definition of the Service Task:
<Auto Generated Inline Image 2.png>
and the I/O
<Auto Generated Inline Image 3.png>


I saw that is also needed a file: kie-deployment-descriptor.xml, I have it with the following def:
 <work-item-handlers> 
        <work-item-handler> 
            <resolver>mvel</resolver> 
            <identifier>new com.sample.handlers.NwsItemHandler()</identifier> 
            <parameters/> 
            <name>Rest</name> 
        </work-item-handler> 
    </work-item-handlers> 
I believe that the service task needs an interface. Is that true?

Anyway, the error I have is this:
Exception in thread "main" org.jbpm.workflow.instance.WorkflowRuntimeException: [com.sample.nwsearch:236 - web service call:7] -- Could not find work item handler for Service Task
It seems that the link between the service task and my java class is not done. How do I do that? Is not the interface defined in Service Task -> Operation?
The project is maven, run from eclipse.
I will attach a zip file with the details. Please help or lead me in the correct direction.
Thank you!


--
You received this message because you are subscribed to the Google Groups "jBPM Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+...@googlegroups.com.
To post to this group, send email to jbpm-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jbpm-usage/033a1a7e-35cb-46fd-9c61-dc26bd5b2f3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<jBPMDemo.zip><Auto Generated Inline Image 1.png><Auto Generated Inline Image 2.png><Auto Generated Inline Image 3.png>

Victor

unread,
Oct 30, 2017, 9:14:50 AM10/30/17
to jBPM Usage
Hi,  I'm not being able to make it work so I tried a simpler approach:

I have a Process with start -> task1 -> task2 -> end; the bpmn file is created with Eclipse BPMN modeler, both tasks assigned to the same user. I noticed that when creating a new file with eclipse modeler, the result is not a file with bpmn extension, but a file with bpmn2 extension and if I view the source of the file, the content is completely different from the sample one that is generated when creating a new project.Like this:

<bpmn2:process id="com.cycleon.jCDemo" tns:packageName="defaultPackage" name="jCDemo" isExecutable="true" processType="Private">
 
versus

<process processType="Private" isExecutable="true" id="com.sample.bpmn.hello" tns:packageName="defaultPackage" name="Hello World" >

Next step was to create a kiebase, session, load the process and run it from code. I was able to create the base, to create the session, load the process, but I cannot get the task assigned to the user. What I do is like this:

        KieSession ksession = engine.getKieSession();
        TaskService taskService = engine.getTaskService();
        KieServices.Factory.get().getLoggers().newThreadedFileLogger(ksession, "jbpmDemo", 1000);
       
        ksession.startProcess("jCDemo");
       
        List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("userAllowed", "en-UK");

So, in my opinion, if I do taskService.getTasksAssignedAsPotentialOwner("userAllowed", "en-UK");  it means that the actor defined at task1 (actor: userAllowed) should be potential owner to this task,even if he is not explicitly set. However, list is returned with size zero.

Please help me solve the issue.

Thank you!
Reply all
Reply to author
Forward
0 new messages