Ios MobileFirst平台适配器调用在模拟器中失败
我在MobileFirst平台中有一个示例项目“调用适配器过程”。它在MFP控制台中预览时接收提要并显示值,但在添加iPad环境并在Xcode中运行后,它不会获取任何提要,而是在Xcode控制台中显示错误: 无法获取提要 在iOS模拟器中: 服务不可用 适配器代码Ios MobileFirst平台适配器调用在模拟器中失败,ios,ibm-mobilefirst,mobilefirst-adapters,Ios,Ibm Mobilefirst,Mobilefirst Adapters,我在MobileFirst平台中有一个示例项目“调用适配器过程”。它在MFP控制台中预览时接收提要并显示值,但在添加iPad环境并在Xcode中运行后,它不会获取任何提要,而是在Xcode控制台中显示错误: 无法获取提要 在iOS模拟器中: 服务不可用 适配器代码 RSSReader RSS阅读器 http rss.cnn.com 80 30000 30000 50 JS代码 var busyIndicator = null; function wlCommonInit(){ busyI
RSSReader
RSS阅读器
http
rss.cnn.com
80
30000
30000
50
JS代码
var busyIndicator = null;
function wlCommonInit(){
busyIndicator = new WL.BusyIndicator();
loadFeeds();
}
function loadFeeds(){
busyIndicator.show();
/*
* The REST API works with all adapters and external resources, and is supported on the following hybrid environments:
* iOS, Android, Windows Phone 8, Windows 8.
* If your application supports other hybrid environments, see the tutorial for MobileFirst 6.3.
*/
var resourceRequest = new WLResourceRequest("/adapters/RSSReader/getFeedsFiltered", WLResourceRequest.GET);
resourceRequest.setQueryParameter("params", "['technology']");
resourceRequest.send().then(
loadFeedsSuccess,
loadFeedsFailure
);
}
function loadFeedsSuccess(result){
WL.Logger.debug("Feed retrieve success");
busyIndicator.hide();
if (result.responseJSON.Items.length>0)
displayFeeds(result.responseJSON.Items);
else
loadFeedsFailure();
}
function loadFeedsFailure(result){
WL.Logger.error("Feed retrieve failure");
busyIndicator.hide();
WL.SimpleDialog.show("Engadget Reader", "Service not available. Try again later.",
[{
text : 'Reload',
handler : WL.Client.reloadApp
},
{
text: 'Close',
handler : function() {}
}]
);
}
function displayFeeds(items){
var ul = $('#itemsList');
for (var i = 0; i < items.length; i++) {
var li = $('<li/>').text(items[i].title);
var pubDate = $('<div/>', {
'class': 'pubDate'
}).text(items[i].pubDate);
li.append(pubDate);
ul.append(li);
}
var busyIndicator=null;
函数wlCommonInit(){
busyIndicator=new WL.busyIndicator();
loadFeeds();
}
函数loadFeeds(){
busyIndicator.show();
/*
*REST API可与所有适配器和外部资源一起使用,并且在以下混合环境中受支持:
*iOS,安卓,WindowsPhone8,Windows8。
*如果您的应用程序支持其他混合环境,请参阅MobileFirst 6.3教程。
*/
var resourceRequest=new WLResourceRequest(“/adapters/RSSReader/getFeedsFiltered”,WLResourceRequest.GET);
setQueryParameter(“参数”,“技术]”);
resourceRequest.send()。然后(
LoadFeedsAccess,
负载反馈故障
);
}
函数LoadFeedsAccess(结果){
调试(“提要检索成功”);
busyIndicator.hide();
if(result.responseJSON.Items.length>0)
displayFeeds(result.responseJSON.Items);
其他的
loadFeedsFailure();
}
函数loadFeedsFailure(结果){
WL.Logger.error(“提要检索失败”);
busyIndicator.hide();
WL.SimpleDialog.show(“Engadget Reader”,“服务不可用。请稍后再试。”,
[{
文本:“重新加载”,
处理程序:WL.Client.reloadApp
},
{
文本:“关闭”,
处理程序:函数(){}
}]
);
}
功能显示源(项目){
var ul=$(“#项目列表”);
对于(变量i=0;i')。文本(项[i]。标题);
变量pubDate=$(''{
“类”:“pubDate”
}).text(项目[i].pubDate);
li.追加(发布日期);
ul.附加(li);
}
Xcode控制台日志
我使用了示例应用程序中给出的代码。我无法重新创建此错误。
确保您已采取以下步骤:
对我来说,通过执行上述步骤,我能够在iOS模拟器中成功运行示例应用程序=显示了应用程序并检索了提要。使用适配器调用代码和Xcode日志编辑问题。另外,请确保iPad设备与服务器连接到同一网络,否则它将失败。@Idan我用适配器代码、js代码和xcode日志编辑了问题。它在模拟器中工作,但在设备中失败。那么,设备是否与Worklight Server连接到同一网络?@Idan是的,它使用同一网络。当然,您必须部署…我是否需要任何外部服务器来完成此部署过程。如果您使用Eclipse中的开发服务器,它有一个嵌入式服务器。你不是问这个问题的人。请不要混淆问题。
var busyIndicator = null;
function wlCommonInit(){
busyIndicator = new WL.BusyIndicator();
loadFeeds();
}
function loadFeeds(){
busyIndicator.show();
/*
* The REST API works with all adapters and external resources, and is supported on the following hybrid environments:
* iOS, Android, Windows Phone 8, Windows 8.
* If your application supports other hybrid environments, see the tutorial for MobileFirst 6.3.
*/
var resourceRequest = new WLResourceRequest("/adapters/RSSReader/getFeedsFiltered", WLResourceRequest.GET);
resourceRequest.setQueryParameter("params", "['technology']");
resourceRequest.send().then(
loadFeedsSuccess,
loadFeedsFailure
);
}
function loadFeedsSuccess(result){
WL.Logger.debug("Feed retrieve success");
busyIndicator.hide();
if (result.responseJSON.Items.length>0)
displayFeeds(result.responseJSON.Items);
else
loadFeedsFailure();
}
function loadFeedsFailure(result){
WL.Logger.error("Feed retrieve failure");
busyIndicator.hide();
WL.SimpleDialog.show("Engadget Reader", "Service not available. Try again later.",
[{
text : 'Reload',
handler : WL.Client.reloadApp
},
{
text: 'Close',
handler : function() {}
}]
);
}
function displayFeeds(items){
var ul = $('#itemsList');
for (var i = 0; i < items.length; i++) {
var li = $('<li/>').text(items[i].title);
var pubDate = $('<div/>', {
'class': 'pubDate'
}).text(items[i].pubDate);
li.append(pubDate);
ul.append(li);
}