tags:

views:

305

answers:

1

Hello.

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?

Thanks a million.

A: 

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).

Marc

marc_s
Hi Marc. Thanks for the suggestion. I have tried the IsRequired=True, that only removes the minOccurs="0".
stevenrosscampbell
@Steven: I was afraid of that :-(
marc_s
Hi Marc, Good news, I already had the WsdlExporter in my wcf service for flattening out the wsdl, so it was actually quite easy to implement this in the WsdlExporter extension. Thanks for the suggestion, without it I don't think I would have gone down that avenue. (Note: I used http://blogs.msdn.com/stan_kitsis/archive/2005/08/06/448572.aspx for Walking the XmlSchema, and when the appropriate element was found, I was able to go el.IsNillable=false; and it worked.Thanks again. Steven
stevenrosscampbell