Search code examples
ibm-mobilefirstworklight-adapters

How to debug in IBM worklight application?


I have created a sample program but i can't get expected result, so i have debug my application. I want to check/print the URL and Post data to server.

This is my url : mydomain.com/RESTapi/Rest_LoginValidate.php
Post date: UserName : 'pop', UserPwd : 'pop'

The following are the code snippet i used in Worklight.

myRESTAdapter.xml

<?xml version="1.0" encoding="UTF-8"?>
<wl:adapter name="myRESTAdapter"
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>myRESTAdapter</displayName>
<description>myRESTAdapter</description>
<connectivity>
    <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
        <protocol>http</protocol>
        <domain>mydomain.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="getGmapLatLng"/>
</wl:adapter>

myRESTAdapter-impl.js

    function getGmapLatLng(UserName,UserPwd) {

var  path = '/RESTapi/Rest_LoginValidate.php';
    var input = {
    method : 'post',
    returnedContentType : 'application/json',
    path : path,
    parameters : {
        UserName : 'UserName',
        UserPwd : 'UserPwd'
    }
  };

  return WL.Server.invokeHttp(input);
  }

Result what i am getting:

  {
  "UserLogin": {
  "ADMIN_FLAG": null,
  "ADMIN_FNAME": null,
  "ADMIN_ID": null,
  "ADMIN_LNAME": null,
  "ADMIN_LOCID": null,
  "ADMIN_LOCNAME": null,
  "ADMIN_MAIL": null,
  "ADMIN_SEC_TYPE": null,
  "BS_NATURE": null,
  "BS_NATURENAME": null,
  "RESPONSE": "authentication failed"
  },
  "isSuccessful": true,
  "responseHeaders": {
  "Connection": "close",
  "Content-Length": "236",
  "Content-Type": "text\/html",
  "Date": "Thu, 09 Apr 2015 09:25:00 GMT",
  "Server": "Apache",
  "X-Powered-By": "PleskLin"
  },
  "responseTime": 583,
  "statusCode": 200,
  "statusReason": "OK",
  "totalTime": 590
  }

I am getting result, but i cant able to login successfully (getting authentication failed), so i want to check whether I am passing correct path and post data and want to know why i am getting failure result?


Solution

  • Per the discussion in the chat, you need to change

    parameters : {
        UserName : 'UserName',
        UserPwd : 'UserPwd'
    }
    

    To:

    parameters : {
        UserName : UserName,
        UserPwd : UserPwd
    }