MobileFirst Platform适配器调用在模拟器中失败

时间:2015-04-01 04:52:48

标签: ios ibm-mobilefirst mobilefirst-adapters

我在MobileFirst Platform中有一个示例项目“调用适配器过程”。它在MFP控制台中预览时接收Feed并显示值,但在添加iPad环境并在Xcode中运行后,它不会获取任何Feed,而是在Xcode控制台中显示错误:

  

无法提取Feed

并在iOS模拟器中:

  

服务不可用

适配器代码     

<displayName>RSSReader</displayName>
<description>RSSReader</description>
<connectivity>
    <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
        <protocol>http</protocol>
        <domain>rss.cnn.com</domain>
        <port>80</port> 
        <connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
        <socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
        <maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>           
        <!-- Following properties used by adapter's key manager for choosing specific certificate from key store  
        <sslCertificateAlias></sslCertificateAlias> 
        <sslCertificatePassword></sslCertificatePassword>
        -->     
    </connectionPolicy>
</connectivity>

<procedure name="getFeeds"/>
<procedure name="getFeedsFiltered"/>

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);
}

Xcode控制台日志

enter image description here

我曾在示例应用中使用过代码。

1 个答案:

答案 0 :(得分:0)

我无法重现此错误 确保这些是您采取的步骤:

  1. 将“调用混合应用程序中的适配器程序”sample project
  2. 导入MobileFirst Platform Studio 7.0
  3. 右键单击适配器文件夹,然后选择运行方式&gt;部署MobileFirst适配器
  4. 右键单击项目文件夹,然后选择新建&gt; MobileFirst Environment ,添加iPad环境
  5. 右键单击iPad文件夹,然后选择运行方式&gt; Xcode项目
  6. 单击“在Xcode中运行”
  7. 对我来说,通过以上步骤,我能够在iOS模拟器中成功运行示例应用程序=显示应用程序并检索提要。