Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

Marshalling returned objects by reference

 
 
Thread Tools Display Modes
Old 11-07-2006   #1 (permalink)
Mike Scott
Guest


 

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.


Old 11-08-2006   #2 (permalink)
Arkady Frenkel
Guest


 

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.
>



Old 11-08-2006   #3 (permalink)
Mike Scott
Guest


 

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.
>>

>
>



Old 11-08-2006   #4 (permalink)
Arkady Frenkel
Guest


 

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.
>>>

>>
>>

>
>



Old 11-09-2006   #5 (permalink)
Kim Johnson
Guest


 

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


Old 11-09-2006   #6 (permalink)
Arkady Frenkel
Guest


 

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
>



 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Objects returned from functions?? Martin Zugec PowerShell 7 07-07-2008 12:01 PM
(apparent) Marshalling related problem in x64 but works in x86 d-42 .NET General 2 05-05-2008 03:42 PM
Returned email Jarhed marine Vista mail 2 12-05-2007 05:06 PM
Sent mail returned Daisey Vista mail 8 11-01-2007 07:26 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50