Search code examples
ibm-mobilefirstmobilefirst-adapters

Invoking http adapter procedure failure


I'm trying to send some values to a web server and it is going to respond with true or false using http adapter in ibm mobilefirst. When i invoke the procedure from the environment, i got this error:

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

Here is the link i'm using: http://mfpreader.comze.com/login.php?username=kevin&password=pass The server is working.

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

}

Can i have some help please. Thanks.


Solution

  • connect website using http port 80 .on the other hand return 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);
    
        }
    

    invocation result:

    {
       "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": [
       ]
    }