Visual Studio Service Reference is not generating DateTime Specified fields

I have added a Service Reference to my local SOAP wsdl file in Visual Studio. The datetime properties in service wsdl were marked with minOccurs=”0″ like this:

<xs:element minOccurs="0" name="validFrom" type="xs:dateTime" />
<xs:element minOccurs="0" name="validTo" type="xs:dateTime" />

But in generated Reference.cs class was no field like validToSpecified or validFromSpecified.

In Reference.svcmap you need to specify this two attributes (Note: in most cases the Serializer will be already set to “Auto”):

<Serializer>XmlSerializer</Serializer>
<Wrapped>true</Wrapped>

After this, right click on your Service in Service References and click “Update Service Reference”. Now, your newly generated Reference.cs should contain XXXSpecified properties.

It is also possible to get XXXSpecified properties generated with svcutil (source):

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

Leave a Reply

Your email address will not be published. Required fields are marked *

About me

I am web developer, tech enthusiast and fitness junkie 🙂

Calendar

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930