I have a business specific, internal XSD which we are using to represent a business-level exception (that is: not necessarilly one in code, but an error in a process) so that different business units can inform eachother when inter-unit processes have failed.
I have been tasked with writing a component to log these exceptions, along with their original requests and (if possible) the response generated. This is all going through biztalk, so I can't just take the data and write it to the DB: I have to return an XmlDocument to the original BizTalk orchestration so that our ExceptionHandling orchestration can handle it.
Okay, this all makes sense (at least, within the business framework- I can see other ways to do it, too, but this one works for us). The problem is this: I have an Xsd with several nested elements, including the original XML of the Request and, possibly, the original XML of the Response. I can create a class that holds all of this just fine. I can take the data passed to the class and create an instance just fine.
However, when I call the XmlSerializer to create the ExceptionMessage I need, it generates its own XML instead of using the xsd I want. I'm hoping soneone here can point me to a way that is not implementing IXmlSerializable and customizing my serialization that I can force an XmlSerializer to take an instance of a class and map it to a specific xsd.
Something along the lines of:
XmlSerializer ser = new XmlSerializer(typeOf(myClass), "mySchema.xsd");
ser.Serialize(myStream, myInstance);
would be ideal, but any direction would help. As a note, I'm using VS2005.