12-19-2017 10:51 AM
Is it possible to call Java Backend web script from Aikau service using Xhr. I tried it but got status code 500. When I call web script from the (Surf) document library it works. Below is my code:
define(["dojo/_base/declare",
"alfresco/services/BaseService",
"alfresco/core/CoreXhr",
"service/constants/Default",
"alfresco/core/PathUtils",
"alfresco/enums/urlTypes",
"dojo/_base/lang",
"dojo/_base/array"],
function(declare, BaseService, CoreXhr, AlfConstants, PathUtils, urlTypes, lang, array) {
return declare([BaseService, CoreXhr, PathUtils], {
constructor: function alfresco_services_BaseService__constructor(args) {
this.alfSubscribe("ADD_ITEMS_TO_LIST", lang.hitch(this, this.onAction));
},
onAction: function facetedsearch_DocumentService_onAction(payload) {
var config = {nodesToArchive: []};
if (payload.nodes)
{
array.forEach(payload.nodes, function(node) {
config.nodesToArchive.push({"nodeRef": node.nodeRef});
});
}
var url ="http://localhost:8080/alfresco/s/com/test/export/documents";
var headers = {
"Content-Type": "application/json"
};
this.serviceXhr({
url: url,
headers: headers,
method: "POST",
data: {
"nodes": config.nodesToArchive
},
callbackScope: this,
successCallback: this.onSuccess,
failureCallback: this.onFailure
});
},
onSuccess:
function facetedsearch_DocumentService_onSuccess(response, originalRequestConfig) {
var msg = "Items are added successfully.";
this.alfLog("log", msg, response, originalRequestConfig);
Alfresco.util.PopupManager.displayMessage({ title: "Info", text: msg});
},
onFailure:
function facetedsearch_DocumentService_onFailure(response, originalRequestConfig) {
var msg = "Something went wrong.";
this.alfLog("log", msg, response, originalRequestConfig);
Alfresco.util.PopupManager.displayMessage({ title: "Info", text: msg});
}
});
});
12-19-2017 01:01 PM
It's always good to look at existing code of the library you are using. It could provide examples of how to call a backend web script.
12-19-2017 01:01 PM
It's always good to look at existing code of the library you are using. It could provide examples of how to call a backend web script.
12-20-2017 08:34 AM
Thank you Axel once more. I've solved it.
Explore our Alfresco products with the links below. Use labels to filter content by product module.