我正在使用来自网络服务的 svcutil 生成数据契约(Contract)。
svcutil /language:cs /noConfig /targetclientversion:Version35
/out:Generated\ProductService.cs http://example.com/ProductService.svc?wsdl
生成的字段如下所示:
private System.Nullable<System.DateTime> createdField;
private bool createdFieldSpecified;
字段如何既可以为空又具有指定字段?
最佳答案
这取决于源 Wsdl。我敢打赌有这样的东西(不确定语法):
<xsd:element name="created" type="xsd:datetime" minOccurs="0" xsd:nil="true" />
svcutil.exe
使用 nillable
产生一个Nullable<>
领域,和minOccurs
产生一个字段+指定的组合。
我还打赌 WSDL 不是 .Net 生成的 WSDL!
关于c# - svcutil 和指定字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6341345/