Search code examples
wcfremoting

Can WCF Service return proxy objects to client?


I am new to world of distributed applications in .net. I understood that in WCF a client creates a proxy object which can communicate to the Service. Once client is connected , is it possible for service to return proxies of other objects in service instead of client creating proxy. Let me ask same thing with example. I have computer connected with four lamps that I can switch on and off programmatically. I would like to expose these lamps to remote machines. I want to create a WCF service which has instances of four lamp objects. Is it possible to expose them via WCF service where client connect to service and gets a proxy object to one of lamp object in remote machine and then it controls the lamp directly via proxy of lamp object.

So the client side code will be something like this.

ILamp lamp = serviceProxy.GetLampProxy();

lamp.On(); // dispatch the call to remote object in service.

I would like to know if remoting in .net can do the same? Others means of doing so are also welcomed.


Solution

  • No. The proxy objects are simply deserialized data objects. Functions and methods are not supported.

    You can however use them as state objects and perhaps create some level of automation which transmits any property changes by way of your own coding but WCF itself doesn't handle anything other than transfer the data the object contains.