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

Instantiate one  WebService , then I got the following Exception:

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

 

Cause:

It is nillable dates that are a problem

Solution:

1. If you have control over the web service causing the problem, change it's specification so that all nillable date fields are nillable dateTime fields. This seemed to work in my solution.

2. If you do not have control over the web service you are calling, you will have to edit the generated reference.cs class to replace all instances of System.Nullable<System.DateTime> with just DateTime. This means the field on the object is no longer nullable, so you will have problems representing null values. It also means you have to edit it again every time you update your web service.

Hopefully this has been resolved in .NET 3.0 and WCF?

你可能感兴趣的:(attribute)