views:

764

answers:

2

Hello there,

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!

A: 

I would recommend against this since WCF is contract based. I would map the entities onto DataContracts in the service and work with them from there. Let me know if I'm missing something..

Adam Fyles
A: 

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

marc_s
Thank you foosnazzy and Marc for your reply.Okie.. So for passing list of my custom objects, I should specify [DataContract] for another class ListABC: List<ABC>, where ABC is already decorated with [DataContract] and then passing object ListABC as parameter. or Should I pass a List<ABC> as parameter in calling method?I am assuming there is no big difference in above two as long as I am specifying my class as [DataContract]. What do you say?
inutan