I am using wsdl.exe to convert a WSDL file and Types.xsd file into a C# file. The wsdl file specifies optional variables (minOccurs="0" maxOccurs="1"
), and the generated .NET type handles this by created two fields - one for the variable (e.g. status
) and one to let you know if it's specified (statusSpecified
).
Is there a way to use the wsdl
tool to only create one field that is Nullable
(i.e. if not null, it is specified)? (If it helps, I think I can change the wsdl file to have nillable="true"
elements.)
Is there a different, better tool that will generate .NET types from WSDL? I am using .NET 4, so it would be useful if the generated types took advantage of features like Nullable types.
NOTE: I just realized that I am using the wsdl tool from .NET 2 and that newer projects should use WCF for this stuff. Any pointers on the WCF way to get what I want?
Regarding WCF, this article pointed me in the direction of using the svcutil
tool (which was already in my PATH, so I could just run it from the command line in the folder with the wsdl and xsd files like so: svcutil *.wsdl *.xsd /language:C#
). Unfortunately, svcutil doesn't seem to do any better with using Nullable types instead of xSpecified
variables.