0

我正在使用 worklight 适配器作为 http 适配器,我正在使用 url 并从结果中获取纯文本现在如何在客户端使用它。我正在将 xml 作为 plian 文本获取,现在我想在客户端使用该 xml,告诉我该怎么做。

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>"  

我想在我的客户端函数中使用该文本输出怎么做

4

1 回答 1

1

将返回的内容类型设置为“xml”。这样适配器会自动将您的 XML 转换为 JSON。

您可以将其引用为 response.HOME.REQUEST.USERID 和/或将其返回给应用程序。

于 2012-11-19T08:01:35.380 回答