Search code examples
c#wsdlsvcutil.exe

svcutil and specified fields


I am generating a datacontract with svcutil from a webservice.

svcutil /language:cs /noConfig /targetclientversion:Version35 
        /out:Generated\ProductService.cs http://example.com/ProductService.svc?wsdl

The fields generated looks like this:

private System.Nullable<System.DateTime> createdField;
private bool createdFieldSpecified;

How can the fields be both nullable and have a specified field?


Solution

  • it depends on the source Wsdl. I bet there is something this (not sure of the syntax):

    <xsd:element name="created" type="xsd:datetime" minOccurs="0" xsd:nil="true" />
    

    svcutil.exe use nillable to produce a Nullable<> field, and minOccurs to produce a field + specified combination.

    I also bet the WSDL is not a .Net generated WSDL !