WCF生成的代理不包含*指定属性的标志与的minOccurs WSDL字符串字段=" 0"字段、字符串、不包含、属性

2023-09-03 06:35:14 作者:半夏花开

我已经注意到,WCF代理生成器不产生指定的属性标志字符串字段

I've noticed that the WCF proxy generator is not generating the "specified" property flags for string fields

例如,当我对在WSDL中指定的复杂类型两个字段:

EG When I have two fields on a complexType specified in the WSDL:

<xs:element name="testStringField" type="xs:string" minOccurs="0" /> 
<xs:element name="testDecimalField" type="xs:decimal" minOccurs="0" /> 

代理生成器将在类的复杂类型创建这些属性:

the proxy generator will create these properties on the class for the complexType:

testStringField
testDecimalField
testDecimalFieldSpecified

为什么不*字符串指定属性?我怎样才能得到SvcUtil工具来生成这个?

Why no *Specified property for strings? How can I get svcutil to generate this?

推荐答案

好吧,我是哑巴。这显然​​是因为串是引用类型,所以没有必要指定是否被包括,因为testStringField可以设置为空,而testDecimalField不能,因此需要一个testDecimalFieldSpecified标志

Ok, I'm being dumb. This is obviously because string is a reference type so there is no need to specify whether is included because the testStringField can be set to null, whereas testDecimalField cannot, hence the need for a testDecimalFieldSpecified flag.