Service Reference does not create “set” properties for DateTime

I added a service link for the SOAP web service. WSDL contains several dateTime elements, such as:

<xsd:element minOccurs="0" name="plannedStartDate" type="xsd:dateTime"/>
<xsd:element minOccurs="0" name="plannedEndDate" type="xsd:dateTime"/>

etc .. VS2013 generated a class with (non-nullable) DateTime properties, but did not add properties such as the scheduled StartDateSpecified. As a result, I have no way to skip any of them. Should I crack the generated code with a null DateTime? properties, it sends null in these fields, and the remote system overrides the values ​​as I expected. I need to completely skip the original elements.

Creating a web link really gives "specific" properties, which allows me to skip sending optional items and all is good.

Any ideas? I would like to use links to services so that everything is consistent in our libraries that consume services.

+4
source share
1 answer

I will wait and see if anyone has a smarter answer, but I ignored and used svcutil.exe with XmlSerializer and wrapped as follows.

svcutil /serializer:XmlSerializer /namespace:*,<desired_namespace_for_generated_class> /wrapped <path_to_WSDL>

For convenience, in app.config I added a regular service link in Visual Studio, as usual, for the same WSDL, and then replaced the contents of the created VS Reference.cs with the contents of the file created from svcutil.exe. Now I have the * specified fields, and everything works the way I want.

, , , -. (, , ).

+3

All Articles