2012-07-14 96 views
1

我有一個WCF服務,它看起來像這樣響應對象

[OperationContract] 
[WebGet(ResponseFormat = WebMessageFormat.Xml)] 
CompositeType GetCompositeTypeForUser(int userid); 

...有一個CompositeType對象看起來是這樣的:

[DataContract] 
    public class CompositeType 
    { 
     bool boolValue = true; 
     string stringValue = "Hello "; 

     [DataMember] 
     public List<string> stuffAroundMe = new List<string>(); 

     [DataMember] 
     public bool BoolValue 
     { 
      get { return boolValue; } 
      set { boolValue = value; } 
     } 

     [DataMember] 
     public string StringValue 
     { 
      get { return stringValue; } 
      set { stringValue = value; } 
     } 
    } 

每當我打電話給我的服務我找回描述特定CompositeType的XML數據塊。有沒有辦法在客戶端重新獲得CompositeType對象而無需解析一堆XML並手動創建新的CompositeType對象?

此外,我有一個生活在Visual Studio上的C#和Android應用程序(實際調用Web服務的代碼)上的Java的代碼。有沒有辦法避免解析大量的xml,當我可以控制從雙方傳遞的對象?

+0

閱讀關於JSON的東西http://stackoverflow.com/questions/11485956/how-to-pass-an-array-of-objects-into-a-format- jQuery的Ajax的理解 – 2012-07-14 20:39:10

回答