C# request object(class) convert to xml format

Try this code below;

“myRequestObject” is the request object like wcf service request object.

XmlSerializer serializer = new XmlSerializer(myRequestObject.GetType());
FileStream fs = File.Open("xmlFilePath",FileMode.OpenOrCreate,FileAccess.Write,FileShare.ReadWrite);
serializer.Serialize(fs, myRequestObject);

#c-object-to-xml, #class-to-xml, #xml-format