c# - Return Inherited Class into Base Class WCF Service -


i trying return derived class base class using wcf service, keep getting following exception

"an error occurred while receiving http response http://localhost:50137/service.svc. due service endpoint binding not using http protocol. due http request context being aborted server..."

i have tried adding of following on wcf service method.

1) [xmlinclude(typeof(derivedclass1)), xmlinclude(typeof(derivedclass2))]

2) [soaprpcmethod]

3) [soapinclude(typeof(derivedclass1)), soapinclude(typeof(derivedclass2))]

code:

public class baseclass { } public class derivedclass1:baseclass { } public class derivedclass2:baseclass { } 

wcf service method:

public baseclass validate() {     if(somecondition)        return new derivedclass1();     else        return new derivedclass2(); } 

[serializable] [datacontract] [    knowntype(typeof(derivedclass1)),     knowntype(typeof(derivedclass2)) ] public class baseclass { } public class derivedclass1:baseclass { } public class derivedclass2:baseclass { } 

see https://msdn.microsoft.com/en-us/magazine/gg598929.aspx more information known types , generic resolver.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -