Charles Bretana
Charles Bretana

Reputation: 146499

Customize WCF Add Service Reference Behavior?

Is there any way to customize or control which type of collection class types are created in the WCF client Side interface Types when using the default "Add Service Reference" menu option in Visual Studio?

Our WCF service is such that when the automated "Add Service Reference" runs, it creates DataSets for all the server side types that contain collections of objects.... And this is causing a

"no corresponding start element is open"

error message.

I want to tell our busienss partners how to create a WCF client that works, and in order to do that I think I need to tell them how to create a client with types where the relevant collection types are Lists, or arrays of objects, rather than datasets.

EDIT:

I have in my types a custom type called DoubleSchedule, which implements IXmlSerializable, and gets serialized like one of the following:
<DataELementName firstIntervalId="87656" schedule="77.3|77.3|76.9|77" />
or
<OtherDataELementName firstIntervalId="87656" lastIntervalId="87670" value="76.1" />

Even when I specify the Collection type in the Advanced tab of the Add Service Reference dialog, all of my Xml Elements that use this type are getting a generated type based on DataSet.

Ideas?

Upvotes: 0

Views: 2227

Answers (2)

insipid
insipid

Reputation: 3308

Your problem does not seem to be about collection types, but about the DataContractSerializer. If you forget to apply the XmlSchemaProvider attribute to your class, the DataContractSerialzer assumes you are trying to serialize a legacy DataSet object.

I am assuming your are not trying to do that, and therefore the DataSet returned is null. That is very likely where your start element error comes from.

See http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlschemaproviderattribute.aspx

EDIT:

also http://msdn.microsoft.com/en-us/library/aa347876.aspx

Upvotes: 1

empi
empi

Reputation: 15881

Yes, the dialog box looks like this:

alt text http://blog.mstern.at/uploads/pictures/ServiceReferenceSettings.gif

Upvotes: 0

Related Questions