Webchannelfactory can be used in the net to easily construct the client for using WCF rest, but there is a problem at this time, that is, when our server has some errors,
For example, if the verification succeeds, but we want to throw a custom exception message (which is the same message class), we will find that the client cannot process it.
He will appear
Unable to deserialize XML body with root name 'errormess' and root namespace ''(for Operation 'get' and contract ('iservice1 ', 'HTTP: // tempuri.org /')) using datacontractserializer. ensure that the type corresponding to the XML is added to the known types collection of the service.
Such an error,
At this time, we can improve the client so that all our entity classes inherit from this message class, so that everything is okay.
But there is no way for list <> and void.
We will use
[Serviceknowntype (typeof (list <sampleitem>)] and dynamic return classes get the expected results.
But the best way is to implement such a process by writing a webchannelfactory (which is actually a proxy to work) similar class to how to customize the proxy http://www.cnblogs.com/lovebanyi/archive/2011/02/22/1961258.html.