2015-08-24 103 views
1

我正在使用MobileFirst CLI 7.1。我正在按照教程(https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-1/foundation/hello-world/integrating-mfpf-sdk-in-cordova-applications/)幾乎一切正常。我現在用的是RSSAdapter和我不斷收到以下錯誤,當我部署應用程序到手機上:Mobilefirst 7.1適配器 - CLI

status : 500 

    responseHeaders  {5} 

X-Powered-By : Servlet/3.0 

Content-Type : application/json 

Content-Length : 430 

Connection : Close 

Date : Mon, 24 Aug 2015 09:55:41 GMT 

responseText : {\"statusCode\":404,\"errors\":[\"White spaces are required between publicId and systemId.\",\"Failed to parse the payload from backend (procedure: HttpRequest)\"],\"isSuccessful\":false,\"statusReason\":\"Not Found\",\"responseHeaders\":{\"Date\":\"Mon, 24 Aug 2015 09:55:41 GMT\",\"Content-Length\":\"149\",\"Content-Type\":\"text/html;charset=UTF-8\",\"Connection\":\"close\",\"Server\":\"FeedsPortal\"},\"warnings\":[],\"totalTime\":276,\"responseTime\":244,\"info\":[]} 

    responseJSON  {9} 

statusCode : 404 

    errors  [2] 

0 : White spaces are required between publicId and systemId. 

1 : Failed to parse the payload from backend (procedure: HttpRequest) 

isSuccessful : false 

statusReason : Not Found 

    responseHeaders  {5} 

    warnings  [0] 

totalTime : 276 

responseTime : 244 

    info  [0] 

invocationContext : null 

這是我的代碼看起來像:

--- RSSAdapter .XML ----

<?xml version="1.0" encoding="UTF-8"?> 
<wl:adapter name="RSSAdapter" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:wl="http://www.ibm.com/mfp/integration" 
    xmlns:http="http://www.ibm.com/mfp/integration/http"> 

    <displayName>RSSAdapter</displayName> 
    <description>RSSAdapter</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="getStories"/> 

    <procedure name="getStoriesFiltered"/> 

</wl:adapter> 

----- RSSAdapter-impl.js ---

function getStories(interest) { 
    path = getPath(interest); 
    var input = { 
     method : 'get', 
     returnedContentType : 'xml', 
     path : path 
    }; 

    return WL.Server.invokeHttp(input); 
} 

function getStoriesFiltered(interest) { 
    path = getPath(interest); 
    var input = { 
     method : 'get', 
     returnedContentType : 'xml', 
     path : path, 
     transformation : { 
      type : 'xslFile', 
      xslFile : 'filtered.xsl' 
     } 
    }; 
    return WL.Server.invokeHttp(input); 
} 


function getPath(interest) { 
    if (interest == undefined || interest == '') { 
     interest = ''; 
    }else { 
     interest = '_' + interest; 
    } 
    return 'rss/edition' + interest + '.rss'; 
} 

--- JS ---

function invokeAdapter() { 
     var resourceRequest = new WLResourceRequest(
     "/adapters/RSSAdapter/getStories", 
     WLResourceRequest.GET); 
     resourceRequest.send().then(success,error); 
    } 

    function success(res) { 
     console.log('Success'); 
     console.log('res ', res); 
     /*console.log('Text ', res.responseJSON.rss.channel.item.length);*/ 
     console.log('Text ', res.responseJSON); 
     alert("Total RSS Feed items received:"+res.responseJSON); 
    } 

    function error(error) { 
     console.log('Nei'); 
     console.log('error ', JSON.stringify(error)); 
     alert("Response error"+ JSON.stringify(error)); 
    } 

回答

2

更新:在最近iFixes,默認的適配器改爲不再指向CNN。如果你還沒有,請升級。

您的項目沒有任何問題。無論出於何種原因,似乎創建的默認適配器已停止與CNN網站合作;正在調查中。

與此同時,您可以使用來自不同項目(與engadget網站一起工作)的適配器,也可以創建自己的適配器。

例如,請參閱作爲Starter Application sample的一部分提供的適配器(您可以將適配器文件夾複製到MobileFirst項目並使用「mfp push」將其部署到服務器;確保更新適配器和過程名稱在你的應用代碼中)。

相關問題