首页 > 解决方案 > 在 Worklight 8 中使用 WL.Client.connect 连接 Worklight 时出现 500 内部服务器错误

问题描述

我是 worklight 的新手,正在将 worklight 6.2 迁移到 8。我正在尝试使用以下代码连接 worklight,

if (document.addEventListener) {
    document.addEventListener('mfpready', function() {

     WL.Client.init(wlInitOptions);
     WL.Client.connect({ onSuccess: onConnectSuccess, onFailure: onConnectFailure });

        angular.bootstrap(document, [ 'App' ]);
        WLAuthorizationManager.obtainAccessToken()
        .then(
            function () {
                console.log("*** Obtained token successfully.");
            },
            function () {
                console.log("*** Failed obtaining token.");
            }
        );
     }, false);
    document.addEventListener('mfpjsloaded', function() {

    WL.Client.init(wlInitOptions);
    WL.Client.connect({ onSuccess: onConnectSuccess, onFailure: onConnectFailure });

        angular.bootstrap(document, [ 'App' ]);
        WLAuthorizationManager.obtainAccessToken()
        .then(
            function () {
                console.log("*** Obtained token successfully.");
            },
            function () {
                console.log("*** Failed obtaining token.");
            }
        );

    }, false);
} else if (document.attachEvent) {
    document.attachEvent('mfpready',  function() {
    WL.Client.init(wlInitOptions); });
}


function onConnectSuccess(result){
        console.log("Success to connect worklight :"+JSON.stringify(result));
    }

    function onConnectFailure(result){
        console.log("Fail to connect worklight :"+JSON.stringify(result));
    }

但我得到以下错误,

{"status":500,"statusText":"Internal Server Error","responseText":"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>500 Internal Server Error</title>\n</head><body>\n<h1>Internal Server Error</h1>\n<p>The server encountered an internal error or\nmisconfiguration and was unable to complete\nyour request.</p>\n<p>Please contact the server administrator,\n you@your.address and inform them of the time the error occurred,\nand anything you might have done that may have\ncaused the error.

又面临一个错误,

static_app_props.js:3 Running static_app_props.js...
angular.js:107 ReferenceError: WLResourceRequest is not defined

请引导我解决这个问题。提前致谢。

标签: androidangularjsibm-mobilefirstworklight-runtime

解决方案


推荐阅读