Ok, i'm really lost on this one. I created a wcf service which i post xml to and the services does something with the data. Everything works just great except when i put the opening xml tag at the very top of my xml. the data comes through as null when i view everything in debug mode.
My C# code in the wcf is something like this:
public interface ITest
{
[OperationContract]
void DoWork();
[OperationContract]
[WebDispatchFormatter]
[WebInvoke(UriTemplate = "MyTest", Method = "*")]
void MyTest(PassedIn request);
}
[Serializable]
[DataContract(Namespace = "", Name = "")]
public class PassedIn
{
public PassedIn() { }
[DataMember]
public string firstname {get; set;}
[DataMember]
public string lastname {get; set;}
[DataMember]
public string email {get; set;}
}
Here's the different xml posts:
<mypost>
<firstname>test</firstname>
<lastname>foo</lastname>
<email>test@bar.com</email>
</mypost>
<?xml version="1.0"?>
<mypost>
<firstname>test</firstname>
<lastname>foo</lastname>
<email>test@bar.com</email>
</mypost>
I was able to fix this where data isn't lost when the tag is in the xml by adding the order to the datamember like so:
public class PassedIn
{
public PassedIn() { }
[DataMember (order=1)]
public string firstname {get; set;}
[DataMember (order=2)]
public string lastname {get; set;}
[DataMember (order=3)]
public string email {get; set;}
}
BUT now it has a reverse effect. If i don't have the "?xml version" tag the data comes through as null.
Has anyone run into this? Could really use some advice. Thanks