2012-11-19 26 views
0

我正在使用worklight適配器作爲http適配器,我打開url並從結果中獲取純文本,現在如何在客戶端使用它。我現在想要在客戶端使用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>" 

我想使用文本輸出在我的客戶端功能如何做到這一點

回答

1

設置returnedContentType爲「XML」。這種方式適配器會自動將您的XML轉換爲JSON。

您可以將其引用爲response.HOME.REQUEST.USERID並/或將其返回給應用程序。