Showing posts with label Silverlight. Show all posts
Showing posts with label Silverlight. Show all posts

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.

Friday, July 18, 2008

Silverlight: Beware of the Contract

WCF webservice in a silverlight project debugging.


Project build will succeed with 1 warning:

Warning 1 Custom tool warning: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.


This warning refers to the file Reference.svcmap Line 1 Column 1.


When you do run the project you will get:

The remote server returned an unexpected response: (404) Not Found.


This is a pretty good indicator that the web service is not being found. Why? It's looking in the wrong place of course. This is the second time that ServiceReferences.ClientConfig has caused me problems. The solution to resolve the above errors is to simply open up the ServiceReferences.ClientConfig in you Silverlight application, and point the to the correct location of your webservice. Last time I had my project open, the service was running on port 1786, now the port changed to 1408, thus an entirely different location.



Another place to look is under the Web.config file in the website project. Look for all the endpoint addresses, and check to make sure they are correct.
Hope this post helps your debug! Cheers