wcf : 字符串元素 nillable="false"; [英] wcf : string element nillable="false"

查看:31
本文介绍了wcf : 字符串元素 nillable="false";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户端要求我的 required 字符串元素具有 nillable="false",目前 wsdl 中的所有字符串都将 nillable=真",IE:

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" />

如何更改 nillable="false" ?!?我会就如何做到这一点提出任何建议吗?我是第一个遇到这种情况的人吗?

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?

如果尚未完成,请尝试在数据成员属性中添加 IsRequired=true 子句:

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;

   .....
}

除此之外,除了编写您自己的 WsdlExporter 扩展(这完全有可能 - 在这里似乎有点矫枉过正),我不知道有什么方法可以影响从您的 WCF 数据合同呈现的 XSD.

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 : 字符串元素 nillable="false";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆