Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wcf : string element nillable="false"

Tags:

wsdl

wcf

I have a client that is mandating that my required string elements have nillable="false", currently all strings in the wsdl come out will nillable="true", IE:

<xs:element name="username" nillable="true" type="xs:string" />

How can i change the nillable="false" ?!? I will take any suggestions on how to do this? Am I the first person that has run into this?

like image 841
stevenrosscampbell Avatar asked Oct 19 '09 16:10

stevenrosscampbell


1 Answers

How is this element defined in your data contract?

If it's not already done, try adding a IsRequired=true clause to the data member attribute:

[DataContract]
class YourDataStructure
{
   ......

   [DataMember(IsRequired=True)]
   string username;

   .....
}

Other than that, I'm not aware of any way to influence the XSD being rendered from your WCF data contract, short of writing your own WsdlExporter extension (which is totally possible - just seems a bit overkill here).

like image 86
marc_s Avatar answered Oct 11 '22 17:10

marc_s