![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Marshalling returned objects by reference In Indigo, is it possible to return an instance of a type that is marshalled by reference so that the returned object is a proxy and calling methods on this object calls methods on the server? Something like: [ServiceContract] public interface IMyService { [OperationContract] IMyOtherService GetOtherService(); } public interface IMyOtherService { string SayHello(); } .... ChannelFactory<IMyService> factory = new ChannelFactory<IMyService>( ... ); IMyService myService = factory.CreateChannel(); // following line should create a proxy for an instance of IMyOtherService on the server IMyOtherService otherService = myService.GetOtherService(); // following should call the SayHello method on server object instance, i.e. marshalled by ref string s = otherService.SayHello(); Is this possible? Or does WCF only support passing of data objects by value? TIA MikeS. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Marshalling returned objects by reference To create proxy of second interface WCF demand that will expose metadata for serialization of parameters and OTOH service itself have to listen for incoming calls. Both conditions are not implemented in the scenario you wrote, so IMHO that can't be done. On the contrary , you can define few service contracts in your WCF service and call their methods from the the same client Arkady "Mike Scott" <someone@microsoft.com> wrote in message news:%232jWgcnAHHA.4256@TK2MSFTNGP04.phx.gbl... > In Indigo, is it possible to return an instance of a type that is > marshalled by reference so that the returned object is a proxy and calling > methods on this object calls methods on the server? > > Something like: > > [ServiceContract] > public interface IMyService > { > [OperationContract] > IMyOtherService GetOtherService(); > } > > public interface IMyOtherService > { > string SayHello(); > } > ... > > ChannelFactory<IMyService> factory = new ChannelFactory<IMyService>( > ... ); > IMyService myService = factory.CreateChannel(); > > // following line should create a proxy for an instance of IMyOtherService > on the server > IMyOtherService otherService = myService.GetOtherService(); > > // following should call the SayHello method on server object instance, > i.e. marshalled by ref > string s = otherService.SayHello(); > > Is this possible? Or does WCF only support passing of data objects by > value? > > TIA > > MikeS. > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Marshalling returned objects by reference Thanks Arkady. If definining several contracts, wouldn't it be necessary to create several channels, one for each interface? In that case, wouldn't each interface (and therefore channel) need to connect to a different endpoint on the server? Using Net.Tcp, wouldn't that mean that the server would have to have different ports for each interface? This would be inefficient also because a separate connection would have to be made for each interface. Or is there another way? Cheers, MikeS. "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message news:%23gDO2IxAHHA.4672@TK2MSFTNGP02.phx.gbl... > To create proxy of second interface WCF demand that will expose metadata > for serialization of parameters and OTOH service itself have to listen for > incoming calls. Both conditions are not implemented in the scenario you > wrote, so IMHO that can't be done. > > On the contrary , you can define few service contracts in your WCF service > and call their methods from the the same client > > Arkady > > "Mike Scott" <someone@microsoft.com> wrote in message > news:%232jWgcnAHHA.4256@TK2MSFTNGP04.phx.gbl... >> In Indigo, is it possible to return an instance of a type that is >> marshalled by reference so that the returned object is a proxy and >> calling methods on this object calls methods on the server? >> >> Something like: >> >> [ServiceContract] >> public interface IMyService >> { >> [OperationContract] >> IMyOtherService GetOtherService(); >> } >> >> public interface IMyOtherService >> { >> string SayHello(); >> } >> ... >> >> ChannelFactory<IMyService> factory = new ChannelFactory<IMyService>( >> ... ); >> IMyService myService = factory.CreateChannel(); >> >> // following line should create a proxy for an instance of >> IMyOtherService on the server >> IMyOtherService otherService = myService.GetOtherService(); >> >> // following should call the SayHello method on server object instance, >> i.e. marshalled by ref >> string s = otherService.SayHello(); >> >> Is this possible? Or does WCF only support passing of data objects by >> value? >> >> TIA >> >> MikeS. >> > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Marshalling returned objects by reference Hi, Mike! "Mike Scott" <someone@microsoft.com> wrote in message news:ew4bFi0AHHA.2328@TK2MSFTNGP02.phx.gbl... > Thanks Arkady. > > If definining several contracts, wouldn't it be necessary to create > several channels, one for each interface? In that case, wouldn't each > interface (and therefore channel) need to connect to a different endpoint > on the server? Using Net.Tcp, wouldn't that mean that the server would > have to have different ports for each interface? That will be with any type of binding not only Net.tcp ![]() Arkady >This would be inefficient also because a separate connection would have to >be made for each interface. > > Or is there another way? > > Cheers, > > MikeS. > > > "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message > news:%23gDO2IxAHHA.4672@TK2MSFTNGP02.phx.gbl... >> To create proxy of second interface WCF demand that will expose metadata >> for serialization of parameters and OTOH service itself have to listen >> for incoming calls. Both conditions are not implemented in the scenario >> you wrote, so IMHO that can't be done. >> >> On the contrary , you can define few service contracts in your WCF >> service and call their methods from the the same client >> >> Arkady >> >> "Mike Scott" <someone@microsoft.com> wrote in message >> news:%232jWgcnAHHA.4256@TK2MSFTNGP04.phx.gbl... >>> In Indigo, is it possible to return an instance of a type that is >>> marshalled by reference so that the returned object is a proxy and >>> calling methods on this object calls methods on the server? >>> >>> Something like: >>> >>> [ServiceContract] >>> public interface IMyService >>> { >>> [OperationContract] >>> IMyOtherService GetOtherService(); >>> } >>> >>> public interface IMyOtherService >>> { >>> string SayHello(); >>> } >>> ... >>> >>> ChannelFactory<IMyService> factory = new ChannelFactory<IMyService>( >>> ... ); >>> IMyService myService = factory.CreateChannel(); >>> >>> // following line should create a proxy for an instance of >>> IMyOtherService on the server >>> IMyOtherService otherService = myService.GetOtherService(); >>> >>> // following should call the SayHello method on server object instance, >>> i.e. marshalled by ref >>> string s = otherService.SayHello(); >>> >>> Is this possible? Or does WCF only support passing of data objects by >>> value? >>> >>> TIA >>> >>> MikeS. >>> >> >> > > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Marshalling returned objects by reference I'm new to WCF so am not sure that this applies, but I found an excellent article at http://msdn.microsoft.com/windowsvis...TremoteWCF.asp which discusses using a factory type of service which returns references to other services. The trick is to return an EndpointAddress10 from your GetOtherService(), and then on the client turn that into a channel. The article has all the messy details... Kim |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Marshalling returned objects by reference Mike want to avoid exposing interface but methods described in the article don't allow that ![]() Arkady "Kim Johnson" <k_r_j@sbcglobal.net> wrote in message news:OG4Z7VDBHHA.1224@TK2MSFTNGP04.phx.gbl... > I'm new to WCF so am not sure that this applies, but I found an excellent > article at > http://msdn.microsoft.com/windowsvis...TremoteWCF.asp > which discusses using a factory type of service which returns references > to other services. The trick is to return an EndpointAddress10 from your > GetOtherService(), and then on the client turn that into a channel. The > article has all the messy details... > > > Kim > |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| messages returned that were not sent by me | Live Mail | |||
| Marshalling ArrayList | .NET General | |||
| Objects returned from functions?? | PowerShell | |||
| (apparent) Marshalling related problem in x64 but works in x86 | .NET General | |||