Last post Dec 13, 2010 09:15 PM by ajdennis78
Dec 27, 2008 04:08 PM|dosborn278|LINK
I created a WCF Rest Collection service using the starter kit, made the modification to using my object and adjusted the UriTemplates. When I do a post I get the following error:
An exception of type 'System.Runtime.Serialization.SerializationException' occurred in System.ServiceModel.Web.dll but was not handled in user code
Additional information: Unable to deserialize XML body with root name 'MyObject' and root namespace '' (for operation 'AddItemInXml' and contract ('ICollectionServiceOf_MyObject', 'http://tempuri.org/')) using DataContractSerializer. Ensure that the type corresponding
to the XML is added to the known types collection of the service.
Dec 27, 2008 04:30 PM|dosborn278|LINK
It appears that the issue is related to the fact that myObject lives in a different assembly and namespace as the REST service. (I figured this out by creating a new rest collection project and moving the sampleitem class to a different assembly and got
the error.) What do I need to change so that I can have the class for myObject in a different assembly?
Dec 27, 2008 04:48 PM|dosborn278|LINK
Ok, solved my own problem. If anyone runs into this issue there is an attribute at the top of Service.svc.cs class that needs to move with the SampleItem class and the ClrNamspace needs to be changed to the Namespace where the class is moved to.
// The following line sets the default namespace for DataContract serialized typed to be ""
[assembly: ContractNamespace("", ClrNamespace = "SampleRest")]
Dec 13, 2010 09:15 PM|ajdennis78|LINK
Thanks for the response...this was useful...even 2 years later!