如何在 IBM worklight 应用程序中进行调试?
How to debug in IBM worklight application?
我已经创建了一个示例程序,但我无法获得预期的结果,所以我调试了我的应用程序。我想 check/print URL 和 Post 数据到服务器。
这是我的 url : mydomain.com/RESTapi/Rest_LoginValidate.php
Post 日期:用户名:'pop',用户密码:'pop'
以下是我在 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);
}
我得到的结果:
{
"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
}
我得到了结果,但我无法成功登录(验证失败),所以我想检查我是否传递了正确的路径和 post 数据,并想知道为什么我会失败结果?
根据聊天中的讨论,您需要更改
parameters : {
UserName : 'UserName',
UserPwd : 'UserPwd'
}
收件人:
parameters : {
UserName : UserName,
UserPwd : UserPwd
}
我已经创建了一个示例程序,但我无法获得预期的结果,所以我调试了我的应用程序。我想 check/print URL 和 Post 数据到服务器。
这是我的 url : mydomain.com/RESTapi/Rest_LoginValidate.php
Post 日期:用户名:'pop',用户密码:'pop'
以下是我在 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);
}
我得到的结果:
{
"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
}
我得到了结果,但我无法成功登录(验证失败),所以我想检查我是否传递了正确的路径和 post 数据,并想知道为什么我会失败结果?
根据聊天中的讨论,您需要更改
parameters : {
UserName : 'UserName',
UserPwd : 'UserPwd'
}
收件人:
parameters : {
UserName : UserName,
UserPwd : UserPwd
}