[英]Call REST WebServices via HTTP Adapter MFP 7.1
我们正在使用MFP7.1开发IONIC App。 我们正在尝试使用HTTP适配器调用REST webservice来获取一些数据。
我有以下适配器实现文件,
function getFeed(username,password) {
var data = {
"username" : username,
"password" : password
};
var input = {
method : 'post',
returnedContentType : 'plain',
path : 'PATH HERE',
body: {
content: data.toString(),
contentType: 'application/json; charset=utf-8;',
},
};
return WL.Server.invokeHttp(input);
}
这是adapter.xml,
<mfp:adapter name="http"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mfp="http://www.ibm.com/mfp/integration"
xmlns:http="http://www.ibm.com/mfp/integration/http">
<displayName>http</displayName>
<description>http</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>DOMAIN NAME HERE</domain>
<port>PORT NO HERE</port>
<connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
<socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
<maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
</connectionPolicy>
</connectivity>
<procedure name="getFeed"/>
</mfp:adapter>
我们做了以下操作来调用我的离子提供器中的适配器,
var resourceRequest = new WLResourceRequest("adapters/http/getFeed", WLResourceRequest.GET);
resourceRequest.setQueryParameter("params", "['username', 'password']");
resourceRequest.send().then(
function(response) {
alert('response '+JSON.stringify(response.responseText));
},
function(response) {
alert("HTTP Failure "+JSON.stringify(response));
}
);
我在错误日志中收到以下错误,
“errors \\”:[],\\“info \\”“statuscode \\”:400}“,”responseJSON“:{”statusReason“:”Bad Request“,”responseHeaders“:{”Transfer-Encoding“:”chunked“ ,“Server”:“Apache-Coyote / 1.1”,“Connection”:“close”,“Content-Type”:“text / plain”},“isSuccessful”:true,“不能在这里反序列化WEBSERVICE实体的实例。用户在[Siyrce.org.apache.catal.inc.connector .......]的START_ARRAY令牌\\ n之外
根据评论中的建议,尝试将.toString()
更改为JSON.stringify
:
content:
JSON.stringify(data)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.