Попробуйте xml linq:
public void callservice()
{
string id = "TESTING";
string productID = "534";
int age = 29;
int gender = 0;
XElement reqData = new XElement("MSRequest", new object[] {
new XElement("RequestData", new object[] {
new XAttribute("id", id),
new XElement("Attributes", new object[] {
new XElement("attribute", new object[] {
new XAttribute("key", "ProductID"),
productID,
}),
new XElement("attribute", new object[] {
new XAttribute("AGE", "ProductID"),
age,
}),
new XElement("attribute", new object[] {
new XAttribute("key", "Gender"),
gender,
})
}),
new XElement("RequestOutput", new object[] {
new XElement("attribute", new object[] {
new XAttribute("key", "ProductName")
}),
new XElement("attribute", new object[] {
new XAttribute("AGE", "Premiumamount")
})
})
})
});
Product.Productservice service = new Product.Productservice();
var response = service.processrequest(reqData.ToString());
Для сериализации используйте следующие классы:
public class MSRequest
{
[XmlElement("RequestData")]
public List<RequestData> requestData { get; set; }
}
public class RequestData
{
[XmlAttribute("id")]
public string id { get; set; }
[XmlArray("Attributes")]
[XmlArrayItem("attribute")]
List<Attribute> attributes { get; set; }
}
public class Attribute
{
[XmlAttribute("key")]
public string key { get; set; }
[XmlText]
public string value { get; set; }
}