Reputation: 33
Trying to create a cxml request from a c# class auto generated from the official cxml specification(http://cxml.org/) through xsd. I can serialize the header, and I can serialize the setupRequest, but I keep getting errors when trying to serialize the whole cxml. I wonder if anyone knows how to implement the classes from the cxml specification correctly. Since the auto generated class is 38401 lines I didn't include it here, and I'm not really sure how to share it.
var cxml = new cXML();
var header = new Header();
var requestWrapper = new Request();
var setupRequest = new PunchOutSetupRequest();
requestWrapper.Item = setupRequest;
cxml.Items = new object[] { header, setupRequest };
-- skipped the data implementation since i have successfully serialized setupRequest and header ---
var sw = new StringWriter();
using (var writer = XmlWriter.Create(sw, xmlSettings))
{
XmlSerializer serializer = new XmlSerializer(cxml.GetType());
serializer.Serialize(writer, cxml);
return await Task.FromResult(sw.ToString());
}
I cannot seem to serialize the requestWrapper with the setupRequest inside it either.
Upvotes: 1
Views: 238