简体   繁体   English

如何在BPMN模型的脚本任务中使用Javascript发送HTTP请求?

[英]How to send an HTTP request using Javascript within a BPMN model's script task?

I wold like to send an HTTP request from within a script task in a BPMN model executed by Camunda using Javascript. 我希望从Camunda使用Javascript执行的BPMN模型中的脚本任务中发送HTTP请求。 Does anyone know how to do that? 有谁知道这是怎么做到的吗?

I've already tested this: 我已经测试过了:

var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "http://test.local/append.php", true);
xmlhttp.send();

But once I get to the script task containing the above code, Tasklist prompts that XMLHttpRequest is not found. 但是一旦我找到了包含以上代码的脚本任务,任务Tasklist提示未找到XMLHttpRequest

Depending on your Java version you either use the Rhino (until Java 7) or Nashorn (since Java 8) Javascript engine. 根据您的Java版本,您可以使用Rhino(直到Java 7)或Nashorn(从Java 8开始)Javascript引擎。 Both have no concept of XmlHttpRequest as you know it from Javascript engines in web browsers. 正如您从Web浏览器中的Javascript引擎了解的那样,两者都没有XmlHttpRequest的概念。 So you have to use a library which allows you to send HTTP Requests. 因此,您必须使用允许您发送HTTP请求的库。 This Post links a XmlHttpRequest implementation for Rhino. 这篇文章链接了Rhino的XmlHttpRequest实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM