如何在适配器工作灯中使用纯文本 [英] how to use plain text in adapter worklight
问题描述
我正在使用worklight适配器作为http适配器,我正在使用url并从结果中获取纯文本,现在如何在客户端使用它。我正在获取xml作为plian文本现在我想在客户端使用xml告诉我如何做到这一点。
I am using worklight adapter as http adapter and i am htting on url and getting plain text from result now how to use it on client side. I am getting xml as a plian text now i want to use that xml on client side tell me how to do that.
function searchData(){
var input = {
method : 'post',
//requestType : 'http',
path : 'Mobile/Default.aspx',
returnedContentType : 'plain',
body : {
contentType: 'application/x-www-form-urlencoded',
acceptEncoding: 'gzip',
content: 'xml=<HOME><REQUEST><USERID>5345435</USERID></HOME>'
}
};
return WL.Server.invokeHttp(input);
}
{
"errors": [
],
"info": [
],
"isSuccessful": true,
"responseHeaders": {
"Cache-Control": "private",
"Content-Length": "42263",
"Content-Type": "text\/xml; charset=utf-8",
"Date": "Mon, 19 Nov 2012 07:03:46 GMT",
"Server": "Microsoft-IIS\/6.0",
"X-AspNet-Version": "2.0.50727",
"X-Powered-By": "ASP.NET"
},
"statusCode": 200,
"statusReason": "OK",
"text": "<HOME><REQUEST><USERID>5345<\/USERID><SECURE_KEY>fsdfs<\/SECURE_KEY><DEVICE_ID>e52164cc6cce6a39<\/DEVICE_ID></HOME>"
我想在我的客户端函数中使用该文本输出如何做到这一点
I want to use that text output in my client side function how to do that
推荐答案
将returnedContentType设置为xml。这样,适配器会自动将您的XML转换为JSON。
Set returnedContentType to "xml". This way adapter will automatically convert your XML to JSON.
您可以将其引用为response.HOME.REQUEST.USERID和/或将其返回给应用程序。
You can the reference it as response.HOME.REQUEST.USERID and/or return it to application.
这篇关于如何在适配器工作灯中使用纯文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!