Referring to my previous post.
I'm trying to invoke the procedure from a hybrid mobile app but I get the following error in logcat:
[ERROR ] FWLSE0099E: An error occurred while invoking procedure [project OfflineReaderAppProject]LoginAdapter/getVerifyFWLSE0100E: parameters: [project OfflineReaderAppProject] Procedure return value must be a Javascript Object, it is currently a String. FWLSE0101E: Caused by: [project OfflineReaderAppProject]nulljava.lang.RuntimeException: Procedure return value must be a Javascript Object, it is currently a String.
...
[ERROR ] FWLSE0332E: The application OfflineReaderApp for the environment android does not exist on the server. Cannot register this client. [project OfflineReaderAppProject]
Here is the 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>
LoginAdapter.xml
<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>
LoginAdapter-impl.js
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
}
Can I have some help please. Thank you.
first of all.you have to remove your invoke HttpAdpater client side code from index.html page and implement any js file (i.e main.js) ,deploy your adapter,wlapp.
Try this way
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");
};
Invoking adapter procedures from hybrid client applications https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-6-3/server-side-development/invoking-adapter-procedures-hybrid-client-applications/