Monday, July 21, 2008

Setting up WCF web service

While setting up a new project I ran into the following issue with a WCF web service that needed to pass data to a silverlight application.



The type of errors I was recieving:

Content Type application/soap+xml; charset=utf-8 was not supported by service


System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior contract: CubeService ----> System.Runtime.Serialization.InvalidDataContractException: Type 'GraphDataClass' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.


The problem is with the class contracts not matching and being unable to be serialized (or something along that effect)

Start by including
Imports System.Runtime.Serialization
-for examples [http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datamemberattribute.aspx]

Give the class and properties the according contract information (See image below or example above)



That should allow you to add the WCF as a web service reference/fix the errors. Comment if you have questions on it, because I'm just briefly going over the problem/solution.

No comments: