cancel
Showing results for 
Search instead for 
Did you mean: 

Access endpoint from script

esakilpi
Champ in-the-making
Champ in-the-making

From script task, how to get an endpoint from a tenant?

9 REPLIES 9

abbask01
Star Collaborator
Star Collaborator

could you please describe your question a bit more?

Regards,
Abbas

esakilpi
Champ in-the-making
Champ in-the-making

Yes, if you would like to call a REST endpoint form a groovy script, can you get the endpoint that is defined in the tenant somehow? Like the way you access process instance variables with execution.getVariable()?
The same endpoint definition that is used with REST call activity.

sanjaybandhaniya
Elite Collaborator
Elite Collaborator

You can access Endpoint from script task like below.

I have tried with javascript.

java.lang.System.out.println(endpointService.getConfigurationByName("Demo").getHost());

Where can you find endpointService documentation?

esakilpi
Champ in-the-making
Champ in-the-making

org.activiti.engine.ActivitiException: problem evaluating script: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: endpointService for class: Script7

You need to unable script at below place.

process-services\tomcat\webapps\activiti-app\WEB-INF\classes\activiti\whitelisted-scripts.conf

You need to unable scripttask at like below.(activiti-app.properties)

validator.editor.bpmn.disable.scripttask=false
validator.editor.bpmn.disable.scripttask.groovy=false

beans.whitelisting.enabled=true

Yes, scripts and groovy have been enabled. The problem is that the runtime is unaware of endpointService. It needs to be defined somehow before calling. Referring to your other posts, it seems that you are injecting it with a bean. But is it your own mock implementation of EndpointService you are injecting or can you really access the endpoints defined in the tenant on Alfresco server runtime?

It is not mock implementation.

I am actually able to get endpoint which is defined i  Tenant->Endpoints.

I have previously tried with groovy only. Now I tested your code and got this error:

jdk.nashorn.internal.runtime.ECMAException: ReferenceError: "endpointService" is not defined