svcutil 和指定字段
我正在使用 svcutil 从 Web 服务生成数据合同。
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;
如何使字段既可为空又具有指定字段?
I am generating a datacontract with svcutil from a webservice.
svcutil /language:cs /noConfig /targetclientversion:Version35
/out:Generated\ProductService.cs http://example.com/ProductService.svc?wsdl
The fields generated looks like this:
private System.Nullable<System.DateTime> createdField;
private bool createdFieldSpecified;
How can the fields be both nullable and have a specified field?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这取决于源 Wsdl。我打赌有这样的东西(不确定语法):
svcutil.exe
使用nillable
来生成Nullable<>
字段,并且minOccurs
生成字段 + 指定的组合。我还打赌 WSDL 不是 .Net 生成的 WSDL!
it depends on the source Wsdl. I bet there is something this (not sure of the syntax):
svcutil.exe
usenillable
to produce aNullable<>
field, andminOccurs
to produce a field + specified combination.I also bet the WSDL is not a .Net generated WSDL !
类生成由 Web 服务的 XSD 模式驱动。
为了生成可为空的字段。该字段应标记为
nillable
。XML 将如下所示。
我相信您的架构中的该字段如下所示:
如果
createdFieldSpecified = false
,它将完全省略该元素:底线:应更新 Web 服务架构,以便使用
生成可为空的字段>svcutil
。The class generation is driven by XSD schema of the web service.
In order to generate nullable fields. The field should be marked as
nillable
.The XML will look like this.
I believe that this field in your schema looks like this:
and it would omit the element completely if
createdFieldSpecified = false
:The bottom line: web service schema should be updated in order to generate nullable fields with
svcutil
.