简体   繁体   English

通过网络服务传递参数为null

[英]Passing argument through webservice as null

I'm new with the .net webservices and had some problem with them. 我是.net Web服务的新手,但遇到了一些问题。 I've got some wsdl file with specification of this webservice and generete proxy class using wsdl.exe . 我有这个Web服务的规范和使用Wsdl.exe用 generete代理类的一些wsdl文件。 Then by using this class sending some data and here is a problem. 然后通过使用此类发送一些数据,这是一个问题。 Proxy class has some not nullable type such DateTime . 代理类具有一些不可为空的类型,例如DateTime So I cannot do something like this: 所以我不能做这样的事情:

someDateField = null;

So I'm only setting 所以我只是设定

someDateFieldSpecified = false;

And this don't working like I think. 这不像我想的那样工作。 I dont want to send this fields through web by some magic mechanizm adding it to xml with my program produce. 我不希望通过一些神奇的机械手段通过网络发送此字段,并将其与我的程序产生的结果添加到xml中。

...
<someDateField>1/1/0001 12:00:00 AM</someDateField>
...

Is any way to don't send this fields? 有什么办法不发送此字段? I read some about create custom serializer but on my level of knowledge is quite difficult task for me. 我读了一些有关创建自定义序列化程序的信息,但就我的知识水平而言,这对我来说是一项艰巨的任务。

DateTime is not a nullable type so it can't accept null as a value. DateTime不是可为null的类型,因此它不能接受null作为值。 However, DateTime? 但是, DateTime? or Nullable<DateTime> can accept nulls and should solve your problem. Nullable<DateTime>可以接受null并应解决您的问题。

Setting the someDateFieldSpecified proprerty to false will simply omit the someDateField field from your request, but it would be up to the server to determine how to handle that. someDateFieldSpecified属性设置为false只会简单地从您的请求中省略someDateField字段,但这取决于服务器来决定如何处理。

将someDateFieldSpecified属性设置为false只会简单地从您的请求中省略someDateField字段,但这取决于服务器来决定如何处理。

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

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