无法连接到 MobileFirst 7.1 服务器
Can't connect to MobileFirst 7.1 server
我们正在将 Worklight 6.2 项目迁移到 MobileFirst 7.1 项目。
我们刚刚将 connectOnStartup 设置为 true。
我们的 MF7.1 iPhone 直接更新就可以了。
但是 MF7.1 android 应用程序无法连接到 worklight 服务器。
我们从 logcat 获得了这个信息:
Client registration failed with error:
{"responseHeaders":{},"status":403,"responseText":"/-secure-\n{\"reason\":\"App
authenticity security check failed\"}/","responseJSON":{"reason":"App
authenticity security check failed"},"invocationContext":null}
[/apps/services/api/**/android/init] failure. state: 403, response:
undefined
我们的authenticationConfig.xml如下图。
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<tns:loginConfiguration xmlns:tns="http://www.worklight.com/auth/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<staticResources>
<resource id="receiveSMS" securityTest="SubscribeServlet">
<urlPatterns>/receiveSMS*</urlPatterns>
</resource>
</staticResources>
<securityTests>
<customSecurityTest name="SubscribeServlet">
<test realm="wl_directUpdateRealm" step="1"/>
<test isInternalUserID="true" realm="SubscribeServlet"/>
</customSecurityTest>
</securityTests>
<realms>
<realm loginModule="rejectAll" name="SubscribeServlet">
<className>com.worklight.core.auth.ext.HeaderAuthenticator</className>
</realm>
<realm loginModule="StrongDummy" name="SampleAppRealm">
<className>com.worklight.core.auth.ext.FormBasedAuthenticator</className>
</realm>
</realms>
<loginModules>
<loginModule expirationInSeconds="-1" name="rejectAll">
<className>com.worklight.core.auth.ext.RejectingLoginModule</className>
</loginModule>
<loginModule expirationInSeconds="-1" name="StrongDummy">
<className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
</loginModule>
<loginModule expirationInSeconds="-1" name="requireLogin">
<className>com.worklight.core.auth.ext.SingleIdentityLoginModule</className>
</loginModule>
</loginModules>
</tns:loginConfiguration>
我们的 Worklight 版本是:7.1.0.00-20151107-1647
正如我在您的其他问题中提到的:不要使用 connecOnStartup!在您的代码中更改为 WL.Client.connect。
错误清楚地表明是应用真实性检查失败了。无论您在 authenticationConfig.xml 文件中显示什么,您是否 100% 确定您正在使用或未使用应用程序的真实性 - 请确认
如果您正在使用应用真实性,follow the tutorial并确保您正确遵循它。您需要确保 wlapp 文件、war 和 .apk 都同步,否则会失败。
确保在正确连接到服务器之前没有执行任何适配器请求。连接后,您可以调用对服务器的任何调用(通过连接 API 的 onSuccess 回调)。
我们正在将 Worklight 6.2 项目迁移到 MobileFirst 7.1 项目。
我们刚刚将 connectOnStartup 设置为 true。
我们的 MF7.1 iPhone 直接更新就可以了。
但是 MF7.1 android 应用程序无法连接到 worklight 服务器。
我们从 logcat 获得了这个信息:
Client registration failed with error: {"responseHeaders":{},"status":403,"responseText":"/-secure-\n{\"reason\":\"App authenticity security check failed\"}/","responseJSON":{"reason":"App authenticity security check failed"},"invocationContext":null}
[/apps/services/api/**/android/init] failure. state: 403, response: undefined
我们的authenticationConfig.xml如下图。
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<tns:loginConfiguration xmlns:tns="http://www.worklight.com/auth/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<staticResources>
<resource id="receiveSMS" securityTest="SubscribeServlet">
<urlPatterns>/receiveSMS*</urlPatterns>
</resource>
</staticResources>
<securityTests>
<customSecurityTest name="SubscribeServlet">
<test realm="wl_directUpdateRealm" step="1"/>
<test isInternalUserID="true" realm="SubscribeServlet"/>
</customSecurityTest>
</securityTests>
<realms>
<realm loginModule="rejectAll" name="SubscribeServlet">
<className>com.worklight.core.auth.ext.HeaderAuthenticator</className>
</realm>
<realm loginModule="StrongDummy" name="SampleAppRealm">
<className>com.worklight.core.auth.ext.FormBasedAuthenticator</className>
</realm>
</realms>
<loginModules>
<loginModule expirationInSeconds="-1" name="rejectAll">
<className>com.worklight.core.auth.ext.RejectingLoginModule</className>
</loginModule>
<loginModule expirationInSeconds="-1" name="StrongDummy">
<className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
</loginModule>
<loginModule expirationInSeconds="-1" name="requireLogin">
<className>com.worklight.core.auth.ext.SingleIdentityLoginModule</className>
</loginModule>
</loginModules>
</tns:loginConfiguration>
我们的 Worklight 版本是:7.1.0.00-20151107-1647
正如我在您的其他问题中提到的:不要使用 connecOnStartup!在您的代码中更改为 WL.Client.connect。
错误清楚地表明是应用真实性检查失败了。无论您在 authenticationConfig.xml 文件中显示什么,您是否 100% 确定您正在使用或未使用应用程序的真实性 - 请确认
如果您正在使用应用真实性,follow the tutorial并确保您正确遵循它。您需要确保 wlapp 文件、war 和 .apk 都同步,否则会失败。
确保在正确连接到服务器之前没有执行任何适配器请求。连接后,您可以调用对服务器的任何调用(通过连接 API 的 onSuccess 回调)。