tags:

views:

210

answers:

0

I need to consume a Java Webservice which has elements of type Date and Time.

Example from the wsdl:

...
<xsd:element name="fromTime" nillable="true" type="xsd:time" />
<xsd:element name="dateOfInspection" type="xsd:date" />
...

When consuming the Webservice via Add Service Reference Visual Studio 2008 generates the following code:

[System.Xml.Serialization.SoapElementAttribute(DataType="time", IsNullable=true)]
public System.Nullable<System.DateTime> fromTime { ... }

[System.Xml.Serialization.SoapElementAttribute(DataType="date")]
public System.DateTime dateOfInspection { ... }

Sending a Message results in an reflection error with the innerException:

'time' is an invalid value for the SoapElementAttribute.DataType property. The property may only be specified for primitive types.

When removing the DataType="time" and DataType="date" attributes everything seems to work. But modifying generated code is an anti pattern. So is there any other way to get this working?

Update:

The Problem only exist if the date or time elements are nullable!

I Reported a bug on Microsofts connect site. If you have the same problem you can vote it up here: https://connect.microsoft.com/VisualStudio/feedback/details/534453/consuming-java-webservice-with-nullable-date-and-time-elements-in-wcf-generates-invalid-datatype-attributes

Update 2:

Microsoft confirmed it's a bug and unlikly to be fixed.