JQuery / Activiti - 如何使用 JQuery .ajax() 访问 .bpmn 文件的 XML?
JQuery / Activiti - How can I access the XML of the .bpmn file with JQuery .ajax()?
我是 AJAX 和 Activiti 的新手,所以我可能遗漏了一些明显的东西。我正在尝试使用 .ajax() 访问我的流程图的 XML。我不断收到 404 Not Found 错误。到目前为止,这是我的代码:
function getData() {
$.ajax({
type: "GET",
url: "src/diagrams/ChangeControl.bpmn",
dataType: "xml",
success: function(data){
xmlString = (new XMLSerializer()).serializeToString(data);
$("#wrapper").html(xmlString);
}
});
}
getData();
(我将 XML 设置为 String 纯粹是为了测试目的)。我知道在 Activiti 中有一个 .bpmn20.xml 文件类型,但我不知道如何访问这样的文件。正如我所说,我是新手,我什至不知道使用 .bpmn 文件是否正确。
是的,
这个有记录但不是很好。
使用以下 URL 检索流程定义:
/service/repository/process-definitions/
这将 return 一个名为 "resource" 的元素..
下面的示例响应:
{
"id": "BP3CreateTimersProcess:1:180035",
"url": "http://localhost:8080/activiti-rest/service/repository/process-definitions/BP3_Rocks_Process:1:180035",
"key": "BP3CreateTimersProcess",
"version": 1,
"name": "BP3 Create timers process",
"description": "Test process to create a number of timers.",
"tenantId": "",
"deploymentId": "180032",
"deploymentUrl": "http://localhost:8080/activiti-rest/service/repository/deployments/180032",
"resource": "http://localhost:8080/activiti-rest/service/repository/deployments/180032/resources/BP3_Rocks.bpmn20.xml",
"diagramResource": "http://localhost:8080/activiti-rest/service/repository/deployments/180032/resources/BP3_Rocks.BP3_Rocks_Process.png",
"category": "Examples",
"graphicalNotationDefined": true,
"suspended": false,
"startFormDefined": false
}
Resource实际上指向一个JSON资源描述,所以把resource改成resourcedata:
$scope.getBPMNResource = function(process) {
if(process.resource){
return process.resource.replace("resources", "resourcedata");
} else return null;
}
这给你类似的东西:
http://localhost:8080/activiti-rest/service/repository/deployments/180032/resourcedata/BP3_Rocks_Process.bpmn20.xml
这将为您 return BPMN XML。
P.S。以上代码摘录为angular.
我是 AJAX 和 Activiti 的新手,所以我可能遗漏了一些明显的东西。我正在尝试使用 .ajax() 访问我的流程图的 XML。我不断收到 404 Not Found 错误。到目前为止,这是我的代码:
function getData() {
$.ajax({
type: "GET",
url: "src/diagrams/ChangeControl.bpmn",
dataType: "xml",
success: function(data){
xmlString = (new XMLSerializer()).serializeToString(data);
$("#wrapper").html(xmlString);
}
});
}
getData();
(我将 XML 设置为 String 纯粹是为了测试目的)。我知道在 Activiti 中有一个 .bpmn20.xml 文件类型,但我不知道如何访问这样的文件。正如我所说,我是新手,我什至不知道使用 .bpmn 文件是否正确。
是的, 这个有记录但不是很好。
使用以下 URL 检索流程定义:
/service/repository/process-definitions/
这将 return 一个名为 "resource" 的元素..
下面的示例响应:
{
"id": "BP3CreateTimersProcess:1:180035",
"url": "http://localhost:8080/activiti-rest/service/repository/process-definitions/BP3_Rocks_Process:1:180035",
"key": "BP3CreateTimersProcess",
"version": 1,
"name": "BP3 Create timers process",
"description": "Test process to create a number of timers.",
"tenantId": "",
"deploymentId": "180032",
"deploymentUrl": "http://localhost:8080/activiti-rest/service/repository/deployments/180032",
"resource": "http://localhost:8080/activiti-rest/service/repository/deployments/180032/resources/BP3_Rocks.bpmn20.xml",
"diagramResource": "http://localhost:8080/activiti-rest/service/repository/deployments/180032/resources/BP3_Rocks.BP3_Rocks_Process.png",
"category": "Examples",
"graphicalNotationDefined": true,
"suspended": false,
"startFormDefined": false
}
Resource实际上指向一个JSON资源描述,所以把resource改成resourcedata:
$scope.getBPMNResource = function(process) {
if(process.resource){
return process.resource.replace("resources", "resourcedata");
} else return null;
}
这给你类似的东西:
http://localhost:8080/activiti-rest/service/repository/deployments/180032/resourcedata/BP3_Rocks_Process.bpmn20.xml
这将为您 return BPMN XML。 P.S。以上代码摘录为angular.