Access endpoint from script

cancel
Showing results for 
Search instead for 
Did you mean: 
esakilpi
Member II

Access endpoint from script

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

9 Replies
abbask01
Senior Member

Re: Access endpoint from script

could you please describe your question a bit more?

Regards,
Abbas
esakilpi
Member II

Re: Access endpoint from script

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.

sanjaybandhniya
Intermediate

Re: Access endpoint from script

You can access Endpoint from script task like below.

I have tried with javascript.

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

esakilpi
Member II

Re: Access endpoint from script

Where can you find endpointService documentation?

esakilpi
Member II

Re: Access endpoint from script


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

 

sanjaybandhniya
Intermediate

Re: Access endpoint from script

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

 

esakilpi
Member II

Re: Access endpoint from script

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?

sanjaybandhniya
Intermediate

Re: Access endpoint from script

It is not mock implementation.

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

esakilpi
Member II

Re: Access endpoint from script

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