更新到 iOS 10 后,Cordova 应用无法连接 Dynamics NAV Web 服务 (ODATA)
Cordova app can't connect with Dynamics NAV Web-Service (ODATA) after update to iOS 10
我们正在使用 Cordova 开发一个应用程序,该应用程序将信息与 Microsoft Dynamics NAV 2013 中间层提供的 ODATA Web 服务同步。
在 Android 下,连接没有问题,在 iOS 8 和 9 下,它也可以正常工作。在使用 iOS 10 的设备上,连接不起作用并且 returns HTTP 400 Bad Request 错误。
连接具有以下结构(这是测试代码,适用于 Android 和 iOS 8 和 9,但不适用于 iOS 10)
var xreq = new XMLHttpRequest();
xreq.open('GET', "http://domain:port/MIDDLETIER/OData/MobileSetupMWP?$format=json",true,username,password);
xreq.onreadystatechange = function () {
if (xreq.readyState == 4) {
if (xreq.status == 200) {
alert("success");
} else {
alert("failure");
}
}
}
try {
xreq.send();
} catch (e) {
}
Web 服务使用 Digest 作为身份验证,可用作 http 和 https Web 服务。 http 和 https 都与 Android 和 iOS 8 和 9 一起工作。在没有身份验证的情况下连接到 http ODATA Web 服务 (http://services.odata.org/V3/OData/OData.svc/) 在 iOS 10 上工作所以问题似乎与身份验证有关。
我们已经在插件中包含了以下部分:
<platform name="ios">
<config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
<string>Für Bildvorschau wird die geräteeigene Fotogalerie verwendet</string>
</config-file>
<config-file target="*-Info.plist" parent="ITSAppUsesNonExemptEncryption">
<false/>
</config-file>
<config-file target="*-Info.plist" parent="NSAppTransportSecurity">
<dict><key>NSAllowsArbitraryLoads</key><true /></dict>
</config-file>
</platform>
这是我们正在使用的内容安全策略
<meta http-equiv="Content-Security-Policy" content="default-src * blob: data: ws: wss: gap://ready ; style-src 'self' 'unsafe-inline' 'unsafe-eval' * ;
script-src 'self' 'unsafe-inline' 'unsafe-eval' * ; connect-src * 'self' 'unsafe-inline' 'unsafe-eval' data: blob: ws: wss: ; img-src * data: blob:">
知道问题出在哪里或者我们可以测试什么吗?
问题似乎是 iOS 10 秒处理摘要式身份验证的一般问题,基本上与此处描述的问题相同:
我们用苹果打开了一个Bug。
Apple 在 10.2 Beta 版本中解决了这个问题。可以再次连接到 DIGEST Web 服务。
我们正在使用 Cordova 开发一个应用程序,该应用程序将信息与 Microsoft Dynamics NAV 2013 中间层提供的 ODATA Web 服务同步。 在 Android 下,连接没有问题,在 iOS 8 和 9 下,它也可以正常工作。在使用 iOS 10 的设备上,连接不起作用并且 returns HTTP 400 Bad Request 错误。 连接具有以下结构(这是测试代码,适用于 Android 和 iOS 8 和 9,但不适用于 iOS 10)
var xreq = new XMLHttpRequest();
xreq.open('GET', "http://domain:port/MIDDLETIER/OData/MobileSetupMWP?$format=json",true,username,password);
xreq.onreadystatechange = function () {
if (xreq.readyState == 4) {
if (xreq.status == 200) {
alert("success");
} else {
alert("failure");
}
}
}
try {
xreq.send();
} catch (e) {
}
Web 服务使用 Digest 作为身份验证,可用作 http 和 https Web 服务。 http 和 https 都与 Android 和 iOS 8 和 9 一起工作。在没有身份验证的情况下连接到 http ODATA Web 服务 (http://services.odata.org/V3/OData/OData.svc/) 在 iOS 10 上工作所以问题似乎与身份验证有关。
我们已经在插件中包含了以下部分:
<platform name="ios">
<config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
<string>Für Bildvorschau wird die geräteeigene Fotogalerie verwendet</string>
</config-file>
<config-file target="*-Info.plist" parent="ITSAppUsesNonExemptEncryption">
<false/>
</config-file>
<config-file target="*-Info.plist" parent="NSAppTransportSecurity">
<dict><key>NSAllowsArbitraryLoads</key><true /></dict>
</config-file>
</platform>
这是我们正在使用的内容安全策略
<meta http-equiv="Content-Security-Policy" content="default-src * blob: data: ws: wss: gap://ready ; style-src 'self' 'unsafe-inline' 'unsafe-eval' * ;
script-src 'self' 'unsafe-inline' 'unsafe-eval' * ; connect-src * 'self' 'unsafe-inline' 'unsafe-eval' data: blob: ws: wss: ; img-src * data: blob:">
知道问题出在哪里或者我们可以测试什么吗?
问题似乎是 iOS 10 秒处理摘要式身份验证的一般问题,基本上与此处描述的问题相同:
我们用苹果打开了一个Bug。
Apple 在 10.2 Beta 版本中解决了这个问题。可以再次连接到 DIGEST Web 服务。