0

我正在尝试从我的 ICN 插件中触发插件请求。请求如下。但是,我从服务器收到 403 Forbidden 错误。

Forbidden 您无权访问此服务器上的 /navigator/jaxrs/plugin。

https://<icnserver.com>/navigator/jaxrs/plugin?repositoryId=Demo&query=%5B%7B%22name%22%3A%22ID%22%2C%22operator%22%3A%22LIKE%22%2C%22values%22%3A%5B%22123434234%22%2C%22%22%5D%7D%5D&className=Checks&plugin=DemoPlugin&action=DemoService&desktop=Demo

插件JS:

aspect.around(ecm.model.SearchTemplate.prototype, "_searchCompleted", function advisingFunction(original_searchCompleted){
    return function(response, callback, teamspace){
        var args = [];
        var templateName = response.templates[0].template_name;
        var res = response;
        var requestParams = {};
        requestParams.repositoryId = this.repository.id;
        requestParams.query = query;
        requestParams.className = templateName;
        
        Request.invokePluginService("DemoPlugin", "DemoService",
            {
                requestParams: requestParams,
                requestCompleteCallback: lang.hitch(this, function(resp) {  // success
                    res.rows = resp.rows;
                    res.num_results = resp.rows.length;
                    res.totalCount = resp.rows.length;
                    args.push(res);
                    args.push(callback);
                    args.push(teamspace);
                    original_searchCompleted.apply(this,args);
                })
            }
        ); 
    }
});

sc

4

1 回答 1

0

您需要提供一个 security_token 才能调用您的服务,因此您需要先登录。然后,打开浏览器的调试并检查网络选项卡中的请求。在那里,您可以看到以 /navigator/jaxrs/* URI 为目标的每个请求都将包含它,因此标题中将包含以下内容:

安全令牌:163594541620199174

请求标头

所以我敢打赌,你没有在你的客户端中设置它(我推荐一个邮递员来测试你的服务,或者我会在 ICN 插件项目中添加一个测试(ICN)功能页面以便能够正确调用它)。在您的功能页面中,您可以使用 ecm/model/Request OOTB 导航器 dojo/javascript 类直接调用您的服务,如CheckinAction.js 所示

        _checkInDocument: function (item, requestData) 
    {
        var self = this;
        var payLoadObject = {requestType: "Get", id: item.id};
        
        Request.postPluginService("DocuSignPlugin", "UpdateSignedDocumentService",  "application/json", {
            requestParams: {
                repositoryId : item.repository.id,
                serverType : item.repository.type,
                docId : item.docid,
                envelopeId: item.attributes.DSEnvelopeID,
                payLoad: json.stringify(payLoadObject)
            },
            requestCompleteCallback: function(response) {
                if (response.returncode == 0)
                {
                    item.attributeDisplayValues.DSSignatureStatus = "Checkedin";
                    item.attributes.DSSignatureStatus = 4;
                    item.update(item);
                }
                else if (response.returncode == -1)
                {
                    items = [];
                    items.push(item);
                    self._showLoginDialog(items);
                }                   
            },
            backgroundRequest : false,
            requestFailedCallback: function(errorResponse) {
                // ignore handline failures
            }
        });
    },
    

如您所见,您不必将 security_token 添加到 requestParams,框架会为您完成。

于 2020-09-02T07:54:46.597 回答