Adding Root xmlns Using XmlSerializer with WCF SOAP

delbertpiggy

New Member
I have a class file generated from an XML Schema document supplied from a third party by our customer. I should be able to use this generated class to the customer's SOAP web service, but I'm having some problems.I've created a \[code\]ServiceContract\[/code\] interface so I can use the WCF \[code\]ChannelFactory\[/code\] to connect to the web service, like follows:\[code\][ServiceContract(Namespace = "http://theircompany.co.uk/theirapp/v1")][XmlSerializerFormat]public interface IWebService{ [OperationContract] EPSStatus serviceNotifyDataEventSet( [XmlElement(Namespace = "http://www.thirdparty.org/thirdapp")] DataEventSet dataSet );}\[/code\]Both \[code\]EPSStatus\[/code\] and \[code\]DataEventSet\[/code\] are in my generated class file. The important bits of \[code\]DataEventSet\[/code\]:\[code\][System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")][System.SerializableAttribute()][System.Diagnostics.DebuggerStepThroughAttribute()][System.ComponentModel.DesignerCategoryAttribute("code")][System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.thirdparty.org/thirdapp")][System.Xml.Serialization.XmlRootAttribute(Namespace="http://www.thirdparty.org/thirdapp", IsNullable=false)]public partial class DataEventSet { //...}\[/code\]When I now try to call \[code\]IWebService.serviceNotifyDataEventSet\[/code\] I get the following SOAP body (found with WCF Trace enabled on their server):\[code\]<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <serviceNotifyDataEventSet xmlns="http://theircompany.co.uk/theirapp/v1"> <dataSet> <dataEvents xsi:type="q1:DAInt" xmlns="" xmlns:q1="http://www.thirdparty.org/thirdapp"> <id>47245361157</id> <time> <tick_time>141728877218</tick_time> <time>2012-06-28T10:07:57.218+01:00</time> <time_type>OSACBM_TIME_MIMOSA</time_type> </time> <value>42</value> </dataEvents> <id xmlns="">0</id> <site xmlns=""> <category>SITE_SPECIFIC</category> </site> <time xmlns=""> <tick_time>141728877218</tick_time> <time>2012-06-28T10:07:57.218+01:00</time> <time_type>OSACBM_TIME_MIMOSA</time_type> </time> </dataSet> </serviceNotifyDataEventSet></s:Body>\[/code\]So, I'm able to call the web service and it appears as though my data is serialising properly, however on the server side \[code\]dataSet\[/code\] is coming up null. I've also got a trace from a client that does work with the following body:\[code\]<soap:Body> <serviceNotifyDataEventSet xmlns="http://theircompany.co.uk/theirapp/v1"> <dataSet xmlns="http://www.thirdparty.org/thirdapp"> <dataEvents xmlns:q1="http://www.thirdparty.org/thirdapp" xsi:type="q1:DAReal" xmlns=""> <id>47245361408</id> <time> <tick_time>141730618844</tick_time> <time>2012-06-28T10:36:58.843+01:00</time> <time_type>OSACBM_TIME_MIMOSA</time_type> </time> <value>12.34</value> </dataEvents> <id xmlns="">0</id> <site xmlns=""> <category>SITE_SPECIFIC</category> </site> <time xmlns=""> <tick_time>141730618843</tick_time> <time>2012-06-28T10:36:58.843+01:00</time> <time_type>OSACBM_TIME_MIMOSA</time_type> </time> </dataSet> </serviceNotifyDataEventSet></soap:Body>\[/code\]The only difference I can see is that the root namespace is set on the \[code\]dataSet\[/code\] on the working packet: \[code\]<dataSet xmlns="http://www.thirdparty.org/thirdapp">\[/code\]. On my packet, the namespace is not specified at all.My question is, does my analysis sound reasonable and if so, is there any way I can get the root xmlns to output properly on my \[code\]dataSet\[/code\]?
 
Back
Top