简体   繁体   English

wcf:string element nillable =“false”

[英]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: 我有一个客户端要求我的required字符串元素有nillable="false" ,目前wsdl中的所有字符串都会出现nillable="true" ,IE:

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

How can i change the nillable="false" ?!? 我怎样才能改变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: 如果尚未完成,请尝试将IsRequired=true子句添加到数据成员属性:

[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). 除此之外,我不知道有什么方法可以影响你的WCF数据合同中呈现的XSD,而不是编写你自己的WsdlExporter扩展(这完全可能 - 这里看起来有点矫枉过正)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM