WCF - Missing integer parameter treated like 0
c#, missing-data, soap, wcf, web-services
Solution
The hack-it-about way:
[OperationContract]
public void InsertSomeData(MyData data){...}
[DataContract]
public class MyData{
[DataMember]
public string version{get;set;}
[DataMember(IsRequired=true)]
public int someId{get;set;}
}
A longer winded, but better way: http://thorarin.net/blog/post/2010/08/08/Controlling-WSDL-minOccurs-with-WCF.aspx
Problem
I'm using WCF to generate a SOAP Webservice and right now I'm facing the following problem: - I have an OperationContract defined that looks like this ` [OperationContract] void InsertSomeData(string version, int someId);` - While testing the service with soapUI I realized that if I delete the someId tags in the request I do receive the value 0 in my service - Is this the standard behavior? Acutally I would suppose the service to throw some kind of Exception, as the parameter is not nullable. - Can I differ in my service between 0 as real value that was passed and just missing tags, or do I have to make all of my parameters nullable in advance Thank you for your help in advance.