2017-08-08 54 views
0

我有我的響應等級結構如下圖所示:在C#中的Web服務響應結構

/// <remarks/> 
    public System.Collections.Generic.List<PaymentMethods> DisallowedPaymentMethods 
    { 
     get 
     { 
      return this.disallowedPaymentMethodsField; 
     } 
     set 
     { 
      this.disallowedPaymentMethodsField = value; 
     } 
    } 

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18408")] 
[System.SerializableAttribute()] 
[System.Diagnostics.DebuggerStepThroughAttribute()] 
[System.ComponentModel.DesignerCategoryAttribute("code")] 
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://blcorp.net/PaymentInfoInquiryService")] 
public partial class PaymentMethods 
{ 

    private string paymentMethodField; 

    /// <remarks/> 
    public string PaymentMethod 
    { 
     get 
     { 
      return this.paymentMethodField; 
     } 
     set 
     { 
      this.paymentMethodField = value; 
     } 
    } 
} 

它建立響應如下

<DisallowedPaymentMethods> 
      <PaymentMethods> 
       <PaymentMethod>CreditCard</PaymentMethod> 
      </PaymentMethods> 
      <PaymentMethods> 
       <PaymentMethod>OnlineCheck</PaymentMethod> 
      </PaymentMethods> 
     </DisallowedPaymentMethods> 

,但我想回應顯示如下

 <DisallowedPaymentMethods> 
       <PaymentMethod>CreditCard</PaymentMethod> 
       <PaymentMethod>OnlineCheck</PaymentMethod> 
     </DisallowedPaymentMethods> 

如何創建我的響應類來生成適當的響應結構。

回答

0

試試你的返回類型設置爲這個和填充酌情:

public System.Collections.Generic.List<PaymentMethod> DisallowedPaymentMethods 
0

你的階級結構,不表明否則裝飾品,決定你的序列化的反應是什麼。我認爲你的課堂結構有點不合適。