How do I handle differences with the "Specified" fields in WCF services using VS 2010 vs VS 2008?

We are trying to upgrade to VS 2010, and we noticed some strange behavior with our WCF services.

In VS 2008, when I add a link to this WCF service, for each field of an object that is not a reference type, the fieldNameSpecified bool property is displayed in the object browser. I understand that this exists, so there is a way to determine if the value returned from the service really matters, because DateTime, ints, etc. Cannot be zero.

When I try to add the same link in VS 2010 (installed in .Net 3.5), all of these fieldNameSpecified fields are missing. We have code that we wrote in VS 2008 that looks at these fieldNameSpecified fields, which lead to disruption of our applications when trying to use VS 2010 (since proxies generated in VS 2010 do not have fieldNameSpecified fields).

Is there a way to get VS 2010 to return these specified fields? Is there any other solution that will not require us to rewrite our code?

Also, what is the correct way for VS 2010 to determine if a value type field (int or DateTime) really has valid data in it, returning from the service?

Any help GREAT appreciated!

: fieldNameSpecified WSDL. VS 2008, -, ...

+3
4

. - xxxspecified, . VS2008. , , xxxspecified false.

reference.cs , . DataContractSerializer, XMLSerializer.

, URL- , . http://localhost/MyService.svc, DataContractSerializer. URL- WSDL, . http://localhost/MyService.svc?wsdl, XMLSerializer.

+5

, (, [DataMember(IsRequired=true)]), "" . , , , , .

An alternative way to allow callers not to specify parameters (I don’t know if it is more VS 2010-ish than the "Specified" fields) in order to use types Nullable<>.

0
source

I did not test it, but perhaps you could delete your service links and instead put the pre-build step in your projects to run the old version of WSDL.exe to create a proxy.

0
source

Source: https://habr.com/ru/post/1791540/


All Articles