wcf : string element nillable="false"
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?
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).
精彩评论