Http 适配器调用失败?

Http Adapter Invocation failure?

当我尝试调用 Http 时,控件功能将失效 Adapter.Here 我的适配器 运行 正常,我也在获取数据。

这是我的 html 代码

<html>
<head>
<meta charset="UTF-8">
<title>IIB_WL_App</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/IIB_WL_App.css">
<script>window.$ = window.jQuery = WLJQ;</script>
</head>
<body id="content" style="display: none;">
<form name="f1">
Enter Employee ID :<input type="text" id="EmpId">
<br>
<input type="submit" value="GetDetails" onclick="GetDetails()">
</form>
<!--application UI goes here-->
<script src="js/initOptions.js"></script>
<script src="js/IIB_WL_App.js"></script>
<script src="js/messages.js"></script>
</body>
</html>

这是我的 .js 代码,用于获取详细信息

function GetDetails(){
//alert("Function Called");
var id=f1.EmpId.value;
//var id=document.getElementById("EmpId").value();
alert(id);
var invocationData = {
    adapter : 'IIB_WL_Adapter',
    procedure : 'getData',
    parameters : [id]
};
var options={
        onSuccess : getDataSuccess,
        onFailure : getDataFailure, 
};
WL.Client.invokeProcedure(invocationData,options);

};
function getDataSuccess(result) {
//WL.Logger.debug("Retrieve success" +  JSON.stringify(result));

alert("Success");
var httpStatusCode = result.status;
alert(httpStatusCode);

}
function getDataFailure(result) {
//WL.Logger.debug("Retrieve success" +  JSON.stringify(result));
alert("Failure");
   var httpStatusCode = result.status;
   alert(httpStatusCode);    
}

我想在列表视图中显示该数据

这是我的 adapter.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed Materials - Property of IBM 5725-G92 (C) Copyright IBM Corp. 
2011, 2013. All Rights Reserved. US Government Users Restricted Rights - 
Use, duplication or disclosure restricted by GSA ADP Schedule Contract with 
IBM Corp. -->
<wl:adapter name="IIB_WL_Adapter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.worklight.com/integration" xmlns:http="http://www.worklight.com/integration/http">

<displayName>IIB_WL_Adapter</displayName>
<description>IIB_WL_Adapter</description>
<connectivity>
    <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
        <protocol>http</protocol>
        <domain>172.17.14.228</domain>
        <port>7080</port>
        <!-- Following properties used by adapter's key manager for choosing specific 
            certificate from key store <sslCertificateAlias>       </sslCertificateAlias> <sslCertificatePassword></sslCertificatePassword> -->
    </connectionPolicy>
    <loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>

<procedure name="getData" />

这是我的适配器-impl.js

function getData(interest) {
//path = getPath(interest);

var input = {
    method : 'get',  
    path : '/DBRetrive',
    returnedContentType : 'xml',
    parameters : {'id' : interest}  
};


return WL.Server.invokeHttp(input);

}

我运行你的代码。
代码本身似乎是合理的。

虽然失败了,所以我不明白你说的 "The Control is going to failure function when I'm trying to invoke Http Adapter.Here My adapter is running fine and I'm getting data also."

是什么意思

您说您在浏览器中对其进行了测试,但失败 "The Service Currently not available"。它在浏览器中对我来说也同样失败,从 Studio 调用适配器时也是如此 - 同样的错误消息。

再说一遍,它到底对你有用吗?

据我所知,问题出在您的适配器配置中,您指向的位置不存在或指向错误的位置:http://172.17.14.228:7080/DBretrieve

我得到了这个问题的解决方案。问题出在我的 Html 页面,即不使用它。

<input type="submit" value="GetDetails" onclick="GetDetails()">

将以下标签与按钮类型一起使用然后它的工作。

<input type="button" value="GetDetails" onclick="return GetDetails()">

为了显示数据,我在 .js 文件中添加了一些代码

function GetDetails(){
var id=f1.EmpId.value;
alert(id);
var invocationData = {
    adapter : 'IIB_WL_Adapter',
    procedure : 'getData',
    parameters : [id]
};
var options={
        onSuccess : getDataSuccess,
        onFailure : getDataFailure, 
};
WL.Client.invokeProcedure(invocationData,options);

};
function getDataSuccess(result) {
   display(result.invocationResult.Employee.Data);
}
function getDataFailure(result) {
   alert(JSON.stringify(result));
   alert(result.errorMsg);
   var httpStatusCode = result.status;
}
function display(items){

var ul=$("#itemList");
ul=$("#itemList").html("&nbsp");
var li=$('<li/>').html("Id:"+items.ID);
li.append($('<li/>').html("Name:"+items.NAME));
li.append($('<li/>').html("Age:"+items.AGE));
ul.append(li);
}