简体   繁体   中英

Mobilefirst 7.1 Adapter - CLI

I am using MobileFirst CLI 7.1. I am following the tutorial ( https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-1/foundation/hello-world/integrating-mfpf-sdk-in-cordova-applications/ ) and almost everything works fine. I am using the RSSAdapter and I keep getting the following error when I deploy the app to the phone:

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

This is how my code looks like:

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

Update: in recent iFixes, the default adapter was changed to no longer point to CNN. If you haven't, please upgrade.

There is nothing wrong with your project. For whatever reason it appears that the default adapter created has stopped working with the CNN website; it is being investigated.

In the meanwhile you can either use an adapter from a different project (that is working with the engadget website), or create your own.

See for example the adapter that is provided as part of the Starter Application sample (you can copy the adapter folder to your MobileFirst project and use "mfp push" to deploy it to the server; make sure to update the adapter and procedure names in your applicative code).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM