Ibm mobilefirst 使用RESTfulWebService的worklight适配器
我正在使用worklight适配器实现restful web服务。但我没有得到任何成功的回应 这是我的适配器:Ibm mobilefirst 使用RESTfulWebService的worklight适配器,ibm-mobilefirst,worklight-adapters,Ibm Mobilefirst,Worklight Adapters,我正在使用worklight适配器实现restful web服务。但我没有得到任何成功的回应 这是我的适配器: function getTest(username,password) { var path = "http://test.mybluemix.net"; var request = 'username='+username+'&'+'password='+password; var input = {
function getTest(username,password) {
var path = "http://test.mybluemix.net";
var request = 'username='+username+'&'+'password='+password;
var input = {
method : 'get',
returnedContentType : 'plain',
path : path,
headers: {
"Host":"http://test.mybluemix.net"
},
body : {
contentType: 'text/xml; charset=UTF-8',
content: request.toString()
}
};
return WL.Server.invokeHttp(input);
}
这是我调用适配器时得到的响应
响应标头连接关闭,X-Backside-Transport失败
正常情况下,我必须点击上面的网址它的工作罚款
我觉得有几件事不对
path
变量不应指向主机名。这应该是后来的部分:
在适配器XML文件中定义协议、主机和端口值。然后提供路径,例如:
http://myhost:8080/THE-路径
。在这种情况下,我认为您不需要它,因为根据您的工作URL示例,没有实际路径-只有参数和请求主机
标题。先试试看function getTest(username,password) {
var request = 'username='+username+'&'+'password='+password;
var input = {
method : 'get',
returnedContentType : 'plain',
path : path,
//headers: {
// "Host":"http://test.mybluemix.net"
// },
body : {
contentType: 'text/xml; charset=UTF-8',
content: request.toString()
}
};
return WL.Server.invokeHttp(input);
}
是的,兄弟,我在上面试过,一个不起作用,我得到了X-Backside-Transport失败的错误,并且连接关闭并配置xml文件的url
function getTest(username,password) {
var request = 'username='+username+'&'+'password='+password;
var input = {
method : 'get',
returnedContentType : 'plain',
path : path,
//headers: {
// "Host":"http://test.mybluemix.net"
// },
body : {
contentType: 'text/xml; charset=UTF-8',
content: request.toString()
}
};
return WL.Server.invokeHttp(input);
}