Ibm mobilefirst 调用http适配器过程失败

Ibm mobilefirst 调用http适配器过程失败,ibm-mobilefirst,mobilefirst-adapters,Ibm Mobilefirst,Mobilefirst Adapters,指的是我以前的经历 我试图从混合移动应用程序调用该过程,但在logcat中出现以下错误: [错误]FWLSE009E:调用过程[project OfflineReaderAppProject]LoginAdapter/getVerifyFWLSE0100E:参数:[project OfflineReaderAppProject]时出错 过程返回值必须是Javascript对象,当前为字符串。 FWLSE0101E:原因:[project OfflineReaderAppProject]nullj

指的是我以前的经历

我试图从混合移动应用程序调用该过程,但在logcat中出现以下错误:

[错误]FWLSE009E:调用过程[project OfflineReaderAppProject]LoginAdapter/getVerifyFWLSE0100E:参数:[project OfflineReaderAppProject]时出错 过程返回值必须是Javascript对象,当前为字符串。 FWLSE0101E:原因:[project OfflineReaderAppProject]nulljava.lang.RuntimeException:过程返回值必须是Javascript对象,它当前是字符串

[错误]FWLSE0332E:服务器上不存在适用于android环境的应用程序OfflineReaderApp。无法注册此客户端。[项目离线阅读应用项目]

以下是index.html

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="UTF-8">
        <title>OpenPdf</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
        <!--
            <link rel="shortcut icon" href="images/favicon.png">
            <link rel="apple-touch-icon" href="images/apple-touch-icon.png"> 
        -->
        <link rel="stylesheet" href="css/main.css">
        <script>window.$ = window.jQuery = WLJQ;</script>
        <script>
        function mobgetVerify(pName) {
          var invocationData = {
                 adapter : 'LoginAdapter',
                 procedure : 'getVerify',
                 parameters : [ pName ]
          };

          WL.Client.invokeProcedure(invocationData, {
                 onSuccess : getVerifySuccess,
                 onFailure : getVerifyFailure,
          });
   };

        function getVerifySuccess(res) {
          var httpStatusCode = res.status;
          if (200 == httpStatusCode) {
                 var invocationResult = res.invocationResult;
                 var isSuccessful = invocationResult.isSuccessful;
                 if (true == isSuccessful) {
                       var val = invocationResult.res;
                      // var lng = invocationResult.lng;
                       alert("Success: Value=" + res);
                 } else {
                       alert("Error. isSuccessful=" + isSuccessful);
                 }
          } else {
                 alert("Error. httpStatusCode=" + httpStatusCode);
          }


   };




    function getVerifyFailure(result){
      alert("Verification Failure");


    };
        </script>
    </head>
    <body style="display: none;">
        <!--application UI goes here-->
        Hello MobileFirst
        <br />
        <br />
        <br />
        <p> 
<button onclick="mobgetVerify( 'kevin' )">send value="kevin"</button>
<p> 
        <p id="demo"></p> <br />        
        <br />
        <br />
        <br />
        <br />
        <script src="js/initOptions.js"></script>
        <script src="js/main.js"></script>
        <script src="js/messages.js"></script>
    </body>
能帮我点忙吗。多谢各位

  • 您有一个错误,说明wlapp文件未部署到服务器;部署它

  • 您有一个错误,说明返回的是
    字符串而不是
    对象
    ,但是您没有提供适配器的JavaScript实现。因此,只能假设您返回的确实是字符串,而不是对象。验证代码和/或提供适配器JavaScript实现


  • 首先,您必须从index.html页面中删除invoke HttpAdpater客户端代码,并实现任何js文件(即main.js),部署适配器wlapp

    这样试试

    main.js:
    从混合客户端应用程序调用适配器过程

    为什么JS代码在HTML文件中?项目中有一个main.js文件;使用它。你的适配器代码缺少很多分号…而且我认为不允许你返回null。适配器工作正常。我将应用程序测试为“普通”,当适配器直接工作时,它工作正常。
    <description>LoginAdapter</description>
    <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>http</protocol>
            <domain>mfpreader.comze.com</domain>
            <port>80</port>
            <connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
            <socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
    
    function getVerify(pName) {
    
    var input = {
        method : 'get',
        returnedContentType : 'plain',
        path : '/login.php',
        parameters : {
            'username' : pName,
            'password' : 'pass'   // hard-coded
                }
    
    
    };
    
    
    var response= WL.Server.invokeHttp(input);
    
    if (response.statusCode==200 && response.isSuccessful==true){
    
        var val =response.text
    
            return {
    
                data:val
    
            }
    
    
    }
    else{
    
        return null
    }
    
    function wlCommonInit(){
    
    
        }
        function mobgetVerify(pName) {
    
            alert("Hi"+pName);
            var invocationData = {
                   adapter : 'LoginAdapter',
                   procedure : 'getVerify',
                   parameters : [ pName ]
            };
    
            WL.Client.invokeProcedure(invocationData, {
                   onSuccess : getVerifySuccess,
                   onFailure : getVerifyFailure,
            });
        };
    
         function getVerifySuccess(res) {
                var httpStatusCode = res.status;
    
                var httpStatusCode = res.status;
                if (200 == httpStatusCode) {
                       var invocationResult = res.invocationResult;
                       var isSuccessful = invocationResult.isSuccessful;
                       if (true == isSuccessful) {
    
                           $("#demo").html(JSON.stringify(res.responseJSON));     
    
                             alert("Success: Value=" + res.responseJSON.data);
    
                       } else {
                             alert("Error. isSuccessful=" + isSuccessful);
                       }
                } else {
                       alert("Error. httpStatusCode=" + httpStatusCode);
                }
    
        };
    
        function getVerifyFailure(result){
            alert("Verification Failure");
        };