使用SP.WebProxy限制同时发出的请求数

时间:2014-07-14 15:36:49

标签: sharepoint webproxy

我已经创建了一个SharePoint托管应用,并且刚刚向应用添加了许可检查。通过使用SP.WebProxy调用REST端点来完成许可证检查。该应用程序是作为应用程序部件实现的,因此页面上可以有许多应用程序实例。

如果页面上只有一个或两个应用程序实例,那么一切正常。然而,只要我向页面添加第三个实例,第三个实例就会启动许可证检查失败并显示错误"此应用程序已达到其出站请求限制。"

显然这种情况正在发生,因为所有三个实例同时都在访问SharePoint代理服务。看起来似乎允许特定应用程序同时进行的呼叫数量有限制。

问题是我无法找到有关此限制的任何文档。我所获得的错误并未在Google中受到重创。这是一个可以通过web.config中的设置增加的限制吗?

有人知道我可以咨询哪些文件吗?

1 个答案:

答案 0 :(得分:0)

我已经使用以下解决方法来传递此错误。 (检查错误消息,然后使用“setTimeout”重新执行查询)

var response = SP.WebProxy.invoke(context, request);

    // Set the event handlers and invoke the request.
    context.executeQueryAsync(
        function () {
            if (response.get_statusCode() == 200) {
                var arrayResult = xmlToJson($.parseXML(response.get_body()));

                d.resolve(arrayResult);
            }
            else {
                var errorMessage = response.get_body();
                if (response.get_statusCode() == 403 && errorMessage == "This app has reached its outbound request limit.") {
                    //Try again in 100ms
                    setTimeout(function () {
                        console.log("reload");

                        response = SP.WebProxy.invoke(context, request);
                        context.executeQueryAsync(function () {
                            if (response.get_statusCode() == 200) {
                                var arrayResult = xmlToJson($.parseXML(response.get_body()));

                                d.resolve(arrayResult);
                            }
                        });
                    }, 100);
                }
                else {
                    d.reject(response.get_body());
                }
            }
        },
        function () { d.reject(response.get_body()); });

    return d.promise();
相关问题