I have a VB.NET (2008) console application which consumes a web service. All is working fine -- I've used WSDL.exe to import the web service's definition and create the appropriate classes, I can interact with those classes to fill them up with data, and the call to the web service succeeds and data is passed.
However, after the successful transfer of data, I would like to log this event to a table in my Oracle database -- including the XML that was transferred (for review at a later time, in case there are questions about the specific data which was passed, etc.). How can I get the XML that was created through the automatic serialization of these objects (by the .NET internal plumbing)?
I can serialize the objects myself and get an approximate representation of the data, for example:
Dim oStringBuilder As New StringBuilder
Dim oStringWriter As New StringWriter(oStringBuilder)
Dim oXmlTextWriter As New XmlTextWriter(oStringWriter)
'-- (oData, for the purposes of this example, is an instance of the main data class explosed in the code generated by WSDL.exe)
Dim oXmlSerializer as New System.Xml.Serialization.XmlSerializer(oData.GetType)
'-- Serialize the data to a StringBuilder
oXmlTextWriter.Formatting = Formatting.Indented
oXmlSerializer.Serialize(oXmlTextWriter, oData)
'-- Display serialized XML (in practice this would be an insert to a table, etc.)
MessageBox.Show(oStringBuilder.ToString)
... however, this really isn't the same as what actually gets passed to the web service (most notably, some of the element names are different, and it doesn't include the same header information and root elements). There are classes with Serialization.XmlTypeAttribute definitions, etc., which I assume are being used by the .NET framework to do handle the real SOAP plumbing. How can I get the actual XML that is passed to the web service?