iOS [undefinedquery]失败。 state:404,响应:服务器无法处理来自应用程序的请求。请稍后再试

时间:2015-07-29 14:37:09

标签: ios ibm-mobilefirst

MobileFirst Environment 6.3 XCode版本6.4

我有一个混合应用程序,当我在XCode上测试我的iPad环境时调用适配器时遇到404错误(在测试公共资源时一切正常)。以下是XCode控制台日志:

2015-07-29 09:36:55.679 MyApplication[31753:78214] [DEBUG] [WL_SPLASH] -[WLSplashView updateImage] in WLSplashView.m:194 :: Splash screen image is Default
2015-07-29 09:36:55.746 MyApplication[31753:78214] [DEBUG] [WL_SPLASH] -[WLSplashView updateImage] in WLSplashView.m:194 :: Splash screen image is Default
2015-07-29 09:36:55.761 MyApplication[31753:78419] [DEBUG] [WL_CONFIG] -[WLConfig init] in WLConfig.m:68 :: {
"application id" = MyApp;
"application version" = "1.0";
authenticitySharedData = "${authenticitySharedData}";
buildtime = 1438176990;
environment = ipad;
host = "1.1.1.1";
ignoredFileExtensions = "";
platformVersion = "6.3.0.0";
port = PORT;
protocol = http;
testWebResourcesChecksum = false;
wlAppFamily = "";
wlMainFile = "index.html";
wlSecureDirectUpdatePublicKey = "";
wlServerContext = "/MobileFirstMyApp/";
wlShareCookies = "";
wlShareUserCert = false;
wlUid = "GpcFvRuPrj0ZAvmmAFHPyw==";
}
2015-07-29 09:36:55.773 MyApplication[31753:78214] Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x7a8b3610>.
2015-07-29 09:36:55.795 MyApplication[31753:78419] [DEBUG] [WL_INIT] -[WLImpl isFirstLaunchAfterInstallOrUpgrade] in WLImpl.m:236 :: isFirstLaunchAfterInstallOrUpgrade: isEncryptedWebResources - 0
2015-07-29 09:36:55.806 MyApplication[31753:78419] [DEBUG] [WL_INIT] -[WLImpl isFirstLaunchAfterInstallOrUpgrade] in WLImpl.m:237 :: isFirstLaunchAfterInstallOrUpgrade: isDirectUpdatePerformed - 0
2015-07-29 09:36:55.819 MyApplication[31753:78419] [DEBUG] [WL_INIT] -[WLImpl isFirstLaunchAfterInstallOrUpgrade] in WLImpl.m:246 :: isFirstLaunchAfterInstallOrUpgrade: there is no encrypted web resources or direct update.
2015-07-29 09:36:55.832 MyApplication[31753:78419] [DEBUG] [WL_INIT] -[WLImpl initWL] in WLImpl.m:123 :: handleAppWebResources: At first launch
2015-07-29 09:36:55.884 MyApplication[31753:78419] [DEBUG] [WL_INIT] -[WLImpl initWL] in WLImpl.m:147 :: handleAppWebResources: encrypted web resources should not be extracted
2015-07-29 09:36:56.899 MyApplication[31753:78214] Apache Cordova native platform version 3.6.1 is starting.
2015-07-29 09:36:56.899 MyApplication[31753:78214] Multi-tasking -> Device: YES, App: YES
2015-07-29 09:36:56.967 MyApplication[31753:78214] Unlimited access to network resources
2015-07-29 09:36:56.983 MyApplication[31753:78214] [DEBUG] [WL_INIT] +[WLImpl wwwFolderName] in WLImpl.m:582 :: WLCordovaAppDelegate:wwwFolderName: //Folder/Library/Developer/CoreSimulator/Devices/EB8E276D-1916-444C-BF41-D2B91B524BD8/data/Containers/Bundle/Application/84E0A7BB-C728-4928-8458-619487D7BB80/MyApplication.app/www
2015-07-29 09:36:57.086 MyApplication[31753:78214] [CDVTimer][wlapp] 3.044009ms
2015-07-29 09:36:57.087 MyApplication[31753:78214] [CDVTimer][push] 0.452995ms
2015-07-29 09:36:57.087 MyApplication[31753:78214] [CDVTimer][TotalPluginStartup] 3.947020ms
2015-07-29 09:36:57.106 MyApplication[31753:78214] Resetting plugins due to page load.
2015-07-29 09:36:58.443 MyApplication[31753:78214] Finished load of: file:folder/index.html
2015-07-29 09:36:58.446 MyApplication[31753:78214] [DEBUG] [WL_INIT] +[WLImpl wwwFolderName] in WLImpl.m:582 :: WLCordovaAppDelegate:wwwFolderName: folder
2015-07-29 09:36:58.679 MyApplication[31753:78214] THREAD WARNING: ['NetworkStatus'] took '28.627197' ms. Plugin should use a background thread.
2015-07-29 09:36:59.991 MyApplication[31753:78396] [DEBUG] [NONE] establishSSLClientAuth
2015-07-29 09:37:00.004 MyApplication[31753:78463] [DEBUG] [NONE] ondeviceready event dispatched
2015-07-29 09:37:00.010 MyApplication[31753:78214] THREAD WARNING: ['WLApp'] took '17.805176' ms. Plugin should use a background thread.
2015-07-29 09:37:00.017 MyApplication[31753:78214] [WARN] [USER_CERT_AUTH] +[WLUserAuthManager getCertificateIdentifier] in WLUserAuthManager.m:68 :: Certificate Identifier Key: com.worklight.userenrollment.certificate:com.MyApp
2015-07-29 09:37:00.030 MyApplication[31753:78214] THREAD WARNING: ['UserAuth'] took '16.427979' ms. Plugin should use a background thread.
2015-07-29 09:37:00.047 MyApplication[31753:78214] log1
2015-07-29 09:37:00.049 MyApplication[31753:78463] [DEBUG] [NONE] wlclient init started
2015-07-29 09:37:00.068 MyApplication[31753:78214] THREAD WARNING: ['Globalization'] took '20.590820' ms. Plugin should use a background thread.
2015-07-29 09:37:00.092 MyApplication[31753:78394] [DEBUG] [NONE] CookieMgr read cookies: {}
2015-07-29 09:37:00.104 MyApplication[31753:78396] [DEBUG] [NONE] Read cookies: null
2015-07-29 09:37:00.106 MyApplication[31753:78214] THREAD WARNING: ['DeviceAuth'] took '35.353760' ms. Plugin should use a background thread.
2015-07-29 09:37:00.107 MyApplication[31753:78395] [DEBUG] [NONE] establishSSLClientAuth isCertificateExists:  false
2015-07-29 09:37:00.118 MyApplication[31753:78397] [DEBUG] [NONE] Request [undefinedquery]
2015-07-29 09:37:00.132 MyApplication[31753:78493] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] +[WLAFHTTPClientWrapper requestWithURL:] in WLAFHTTPClientWrapper.m:37 :: Request url is http://1.1.1.1:PORT/MobileFirstMyAppundefinedquery
2015-07-29 09:37:00.134 MyApplication[31753:78485] [DEBUG] [NONE] before: initOptions.onSuccess
2015-07-29 09:37:00.139 MyApplication[31753:78489] [DEBUG] [NONE] after: initOptions.onSuccess
2015-07-29 09:37:00.147 MyApplication[31753:78487] [DEBUG] [NONE] added onPause and onResume event handlers
2015-07-29 09:37:00.151 MyApplication[31753:78490] [DEBUG] [NONE] wlclient init success
2015-07-29 09:37:00.164 MyApplication[31753:78493] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper start] in WLAFHTTPClientWrapper.m:182 :: Starting the request with URL http://1.1.1.1:PORT/MobileFirstMyAppundefinedquery
2015-07-29 09:37:00.222 MyApplication[31753:78214] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:209 :: Request Failed
2015-07-29 09:37:00.229 MyApplication[31753:78214] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:210 :: Response Status Code : 404
2015-07-29 09:37:00.236 MyApplication[31753:78214] [DEBUG] [WL_AFHTTPCLIENTWRAPPER_PACKAGE] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:211 :: Response Error : Expected status code in (200-299), got 404
2015-07-29 09:37:00.410 MyApplication[31753:78396] [ERROR] [NONE] [undefinedquery] failure. state: 404, response: The server was unable to process the request from the application. Please try again later.

我认为该问题源于未正确设置查询路径(读取undefinedquery)。我从应用程序描述符中删除并重新添加了“iPad”环境,我没有更改任何属性。我在Xcode中运行环境,但仍然出现错误。

我的代码如下。这很直截了当。另一件事可能是我第一次尝试MobileFirst身份验证(AdapterAuthentication)。我认为我已经正确设置了(从常见的方面再次正常工作)但我怀疑的一件事是我遵循Hybrid示例来设置ChallengeHandler。我希望在所有环境中使用Hybrid身份验证方法,但对于iPad环境,我是否必须在本机IOS代码中创建ChallengeHandler?如果是这样,我可能在文档中错过了这个。

init = function () {

    var invocationData = {
        adapter: 'MyAdapter',
        procedure: 'myProcedure'
    };

    WL.Client.invokeProcedure(invocationData, {
        onSuccess: doSuccess,
        onFailure: doFailure //Goes Here
    });    
}

MyChallengeHandler = WL.Client.createChallengeHandler("MyAuthRealm");

MyChallengeHandler.isCustomResponse = function (response) {
    if (!response || !response.responseJSON || response.responseText === null) {
        return false;
    }

    if (typeof (response.responseJSON.authRequired) !== 'undefined') {
        return true;
    } else {
        return false;
    }
};

MyChallengeHandler.handleChallenge = function (response) {
    var authRequired = response.responseJSON.authRequired;

    if (authRequired == true) {
        popLoginWindow();
    } else if (authRequired == false) {

       cleanupLoginWindow();
       MyChallengeHandler.submitSuccess();

    }
};

1 个答案:

答案 0 :(得分:0)

感谢Idan的帮助。我能够解决自己的问题。因此,在加载时立即调用适配器,结果看起来好像在Worklight完成所有初始化之前调用了适配器。我向init调用添加了500毫秒的延迟任务,并成功调用了适配器。 (不确定为什么这不是公共资源中的问题)

然而,虽然这确实解决了这个问题,但我想知道是否有更好的方法来确定WL初始化过程是否完成。如果有更好的解决方案,请告诉我,我会更新我的答案。

更新

根据Idan的解决方案,将初始化放在wlCommonInit()中解决了这个问题。