Reputation: 690
I have my class structure for response as below:
/// <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;
}
}
}
It's creating response as below
<DisallowedPaymentMethods>
<PaymentMethods>
<PaymentMethod>CreditCard</PaymentMethod>
</PaymentMethods>
<PaymentMethods>
<PaymentMethod>OnlineCheck</PaymentMethod>
</PaymentMethods>
</DisallowedPaymentMethods>
but I want response to be shown as below
<DisallowedPaymentMethods>
<PaymentMethod>CreditCard</PaymentMethod>
<PaymentMethod>OnlineCheck</PaymentMethod>
</DisallowedPaymentMethods>
How to create my response class to generate appropriate response structure.
Upvotes: 0
Views: 610
Reputation: 3581
If you're using Visual Studio, the easiest way to get a start is to copy the response as you want it into the clipboard, then use the "Paste XML as Classes" feature under the Edit => Paste Special menu.
If you're not using Visual Studio, you can also try Xml2Csharp.com
Upvotes: 1
Reputation: 1190
Your class structure, without decorations indicating otherwise, dictates what your serialized response is. I think you class structure is a bit off.
Upvotes: 0
Reputation: 3958
Try setting your return type to this and populating as appropriate:
public System.Collections.Generic.List<PaymentMethod> DisallowedPaymentMethods
Upvotes: 0