Search code examples
wcfserviceobject

How to pass Client Objects to WCF Service


I want to pass list of entitiy objects from Client to WCF Service, but my WCF Service has no knowledge of the structure of these entity objects.

One way could be to pass them in an XML file.

What could be the other possible ways to pass such objects to WCF service? Please guide.

Thank you!


Solution

  • Basically, you need to make your WCF service aware of the structure.

    Remember: calling a WCF service is passing a message (WCF is serialising an object, stuffing it into an envelope, and sending it away; this is not a remote procedure call or some object remoting!) and you need to make this message so that the caller and the callee can serialize and deserialize it!

    Create DataContracts for your object classes being sent back and forth - that's the easiest way.

    You can also work with untyped messages in WCF - but it's a lot more manual work, and I'd strongly recommend investigating the DataContract route first!

    See a blog post and the MSDN docs on how to deal with untyped messages in WCF.

    Marc