Rhabarbertoast
Rhabarbertoast

Reputation: 47

How to pass any object as parameter to WCF service?

I've got the the following interface method:

[OperationContract]
void AddObject(object o);

Of course this won't work because 'o' can't be deserialized on the service side. Is there any way around this? Maybe by putting the types in the web.config? Like the user of the service can define the types he'd like to pass to this method.

Thanks

Upvotes: 1

Views: 3651

Answers (1)

nvoigt
nvoigt

Reputation: 77304

I have never seen it used for input parameters and you should validate your concept of the service to check if you really need it:

You can use the ServiceKnownType attribute to specify all types that the service should accept although they do not appear in it's signature.

Upvotes: 2

Related Questions