Svein Fidjestøl
Svein Fidjestøl

Reputation: 3216

svcutil.exe not generating DateTimeOffset for xs:datetime

I'm generating a C# SOAP Web service proxy from a WSDL using svcutil.exe.

Some fields in the WSDL are of type xs:datetime and return datetimes with timezone information.

I would therefore like the proxy to use DateTimeOffset for these fields.

According to the svcutil.exe documentation it should be enough to specify the /tcv:Version35 parameter in order for it to generate DateTimeOffset fields instead of DateTime fields in the C# proxy.

However this is not the case. There is no change when adding the /tcv:Version35 parameter. It still generates fields of type DateTime in the C# proxy for the xs:datetime fields in the WSDL.

Any ideas how to have it generate fields of type DateTimeOffset instead?

Upvotes: 1

Views: 518

Answers (1)

sverrehundeide
sverrehundeide

Reputation: 162

Adding "/targetClientVersion:Version35" worked for me. Can you verify that you are not using an old version of svcutil.exe? My version is located in "Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\SvcUtil.exe".

Also, remember to add "[KnownType(typeof(DateTimeOffset))]" to the data contract class, since DateTimeOffset isn't a type known by the DataContractSerializer as default (ref https://msdn.microsoft.com/en-us/library/ms730167(v=vs.110).aspx),

Upvotes: -2

Related Questions