【问题标题】:Invoking http adapter procedure failure调用 http 适配器过程失败
【发布时间】:2016-02-19 10:23:46
【问题描述】:

我正在尝试向 Web 服务器发送一些值,它会使用 ibm mobilefirst 中的 http 适配器以 true 或 false 响应。当我从环境中调用该过程时,出现此错误:

{
"errors": [
  "Runtime: Http request failed: java.net.UnknownHostException: mfpreader.comze.com\/"
],
"info": [
],
"isSuccessful": false,
"warnings": [
]
}

这是我正在使用的链接: http://mfpreader.comze.com/login.php?username=kevin&password=pass 服务器正在工作。

LoginAdapter.xml

<connectivity>
    <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
        <protocol>https</protocol>
        <domain>mfpreader.comze.com/</domain>
        <port>443</port>        


<procedure name="getVerify"/>

LoginAdapter-impl.js

                 function getVerify(pName) {

var input = {
    method : 'get',
    returnedContentType : 'json',
    path : '/login.php',
    parameters : {
        'username' : pName,
        'password' : 'pass'   // hard-coded
            }

 };

return WL.Server.invokeHttp(input);

}

我可以帮忙吗?谢谢。

【问题讨论】:

    标签: ibm-mobilefirst mobilefirst-adapters


    【解决方案1】:

    我认为您的问题是您的域名中有多余的/

    <domain>mfpreader.comze.com/</domain>
    

    这是一个域名,而不是 URL。您只需指定您尝试访问的服务器的主机名:

    <domain>mfpreader.comze.com</domain>
    

    【讨论】:

    • 谢谢你安德鲁。现在,我收到了这个错误:过程调用失败:读取超时
    • 这是一个不同的问题。建议你打开一个不同的问题。
    【解决方案2】:

    使用http端口80连接网站。另一方面返回returnedContentType : 'plain'

    LoginAdapter.xml

    <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>http</protocol>
                <domain>mfpreader.comze.com</domain>
    
                <port>80</port>      
    
    
    <procedure name="getVerify"/>
    

    LoginAdapter-impl.js

    function getVerify(pName) {
    
        var input = {
            method : 'get',
            returnedContentType : 'plain',
            path : '/login.php',
            parameters : {
                'username' : pName,
                'password' : 'pass'   // hard-coded
                    }
    
         };
    
        return WL.Server.invokeHttp(input);
    
        }
    

    调用结果:

    {
       "errors": [
       ],
       "info": [
       ],
       "isSuccessful": true,
       "responseHeaders": {
          "Connection": "close",
          "Content-Length": "748",
          "Content-Type": "text\/html",
          "Date": "Fri, 19 Feb 2016 11:56:31 GMT",
          "Server": "Apache",
          "X-Powered-By": "PHP\/5.2.17"
       },
       "responseTime": 563,
       "statusCode": 200,
       "statusReason": "OK",
       "text": "<br><table border='1' cellpadding='2' bgcolor='#FFFFDF' bordercolor='#E8B900' align='center'><tr><td><font face='Arial' size='1' color='#000000'><b>PHP Error Message<\/b><\/font><\/td><\/tr><\/table><br \/>\n<b>Warning<\/b>:  json_encode() expects exactly 1 parameter, 2 given in <b>\/home\/a1974455\/public_html\/login.php<\/b> on line <b>72<\/b><br \/>\n<br><table border='1' cellpadding='2' bgcolor='#FFFFDF' bordercolor='#E8B900' align='center'><tr><td><div align='center'><a href='http:\/\/www.000webhost.com\/'><font face='Arial' size='1' color='#000000'>Free Web Hosting<\/font><\/a><\/div><\/td><\/tr><\/table> \n<!-- Hosting24 Analytics Code -->\n<script type=\"text\/javascript\" src=\"http:\/\/stats.hosting24.com\/count.php\"><\/script>\n<!-- End Of Analytics Code -->",
       "totalTime": 578,
       "warnings": [
       ]
    }
    

    【讨论】:

    • { "errors": [ ], "info": [ ], "isSuccessful": true, "responseHeaders": { "Connection": "close", "Content-Length": "159 ","内容类型":"text\/html","日期":"星期六,2016 年 2 月 20 日 11:15:35 GMT","服务器":"Apache","X-Powered-By":" PHP\/5.2.17" }, "responseTime": 705, "statusCode": 200, "statusReason": "OK", "text": "True \n\n\n
    【解决方案3】:

    网站无法使用。

    当您指向它时,您使用的是 http,但在 XML 中您使用的是 https。当尝试使用 https 协议访问网站时,它没有加载。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多