简体   繁体   中英

Passing argument through webservice as null

I'm new with the .net webservices and had some problem with them. I've got some wsdl file with specification of this webservice and generete proxy class using wsdl.exe . Then by using this class sending some data and here is a problem. Proxy class has some not nullable type such 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.

...
<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. However, DateTime? or Nullable<DateTime> can accept nulls and should solve your problem.

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字段,但这取决于服务器来决定如何处理。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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