Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - Limitation in WCF: ineritance of generic interfaces

 
 
Old 11-08-2006   #1 (permalink)
Mike Scott


 
 

Limitation in WCF: ineritance of generic interfaces

I seem to have found a limitation in WCF when using generic interfaces. For
example:

[ServiceContract]
public interface IGeneric<T>
{
[OperationContract]
T Get();
}

[ServiceContract]
public interface IAggregate : IGeneric<int>, IGeneric<string>
{
}

Trying to use IAggregate fails because there are two Get() methods, one
which takes an int and one which takes a string. WCF's exception message
helpfully suggests adding a Name="xxx" parameter to the OperationContract.
However, since the Get() method is defined in IGeneric<T>, it's not possible
to put separate Name="xxx" parameters of the closed generic methods.

Comments?

MikeS.



My System SpecsSystem Spec
Old 11-08-2006   #2 (permalink)
Arkady Frenkel


 
 

Re: Limitation in WCF: ineritance of generic interfaces

WCF doesn't not support open generic types , so the only way to use
[ServiceContract]
public interface ISomeInterface<SomeConcreteType>
{
[OperationContract]
T Get();
}

Arkady

"Mike Scott" <someone@microsoft.com> wrote in message
news:et7Crm0AHHA.4808@TK2MSFTNGP03.phx.gbl...
>I seem to have found a limitation in WCF when using generic interfaces. For
>example:
>
> [ServiceContract]
> public interface IGeneric<T>
> {
> [OperationContract]
> T Get();
> }
>
> [ServiceContract]
> public interface IAggregate : IGeneric<int>, IGeneric<string>
> {
> }
>
> Trying to use IAggregate fails because there are two Get() methods, one
> which takes an int and one which takes a string. WCF's exception message
> helpfully suggests adding a Name="xxx" parameter to the OperationContract.
> However, since the Get() method is defined in IGeneric<T>, it's not
> possible to put separate Name="xxx" parameters of the closed generic
> methods.
>
> Comments?
>
> MikeS.
>



My System SpecsSystem Spec
Old 11-08-2006   #3 (permalink)
Mike Scott


 
 

Re: Limitation in WCF: ineritance of generic interfaces

Hi again

I know that WCF doesn't support open generic types. But my example uses
closed generic types, i.e. IGeneric<int> and IGeneric<string>. This is not
the problem.

The problem is not being able to differentiate the names of two closed
generic methods resulting in deriving an interface from a generic interface.
The following is closed:

[ServiceContract]
public interface IAggregate : IGeneric<int>, IGeneric<string>
{
}

It has two methods called Get(), one that takes an int and the other a
string. They will be named GetOf_Int32 and GetOf_String by the runtime. But
I can't see a way to "get at" these methods so that they can have a Name
assigned. For example, if they were overloads you could do this:

[ServiceContract]
public interface IAggregate
{
[OperationContract(Name="GetByInt")]
int Get( int value );

[OperationContract(Name="GetByString")]
int Get( string value );
}

Unfortunately, the serializer doesn't seem to be aware of the fact that it's
possible to derive an interface multiple times from different closed
"versions" of a single generic interface. If it did, it could differentiate
the names itself.

MikeS.


"Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
news:%23UsziD1AHHA.4592@TK2MSFTNGP03.phx.gbl...
> WCF doesn't not support open generic types , so the only way to use
> [ServiceContract]
> public interface ISomeInterface<SomeConcreteType>
> {
> [OperationContract]
> T Get();
> }
>
> Arkady
>
> "Mike Scott" <someone@microsoft.com> wrote in message
> news:et7Crm0AHHA.4808@TK2MSFTNGP03.phx.gbl...
>>I seem to have found a limitation in WCF when using generic interfaces.
>>For example:
>>
>> [ServiceContract]
>> public interface IGeneric<T>
>> {
>> [OperationContract]
>> T Get();
>> }
>>
>> [ServiceContract]
>> public interface IAggregate : IGeneric<int>, IGeneric<string>
>> {
>> }
>>
>> Trying to use IAggregate fails because there are two Get() methods, one
>> which takes an int and one which takes a string. WCF's exception message
>> helpfully suggests adding a Name="xxx" parameter to the
>> OperationContract. However, since the Get() method is defined in
>> IGeneric<T>, it's not possible to put separate Name="xxx" parameters of
>> the closed generic methods.
>>
>> Comments?
>>
>> MikeS.
>>

>
>



My System SpecsSystem Spec
Old 11-08-2006   #4 (permalink)
Arkady Frenkel


 
 

Re: Limitation in WCF: ineritance of generic interfaces

Hi!
What I mean that you can't use next because it still open type

[ServiceContract]
public interface IGeneric<T>
{
[OperationContract]
T Get();
}



Arkady


"Mike Scott" <someone@microsoft.com> wrote in message
news:Oypf$H2AHHA.4680@TK2MSFTNGP04.phx.gbl...
> Hi again
>
> I know that WCF doesn't support open generic types. But my example uses
> closed generic types, i.e. IGeneric<int> and IGeneric<string>. This is not
> the problem.
>
> The problem is not being able to differentiate the names of two closed
> generic methods resulting in deriving an interface from a generic
> interface. The following is closed:
>
> [ServiceContract]
> public interface IAggregate : IGeneric<int>, IGeneric<string>
> {
> }
>
> It has two methods called Get(), one that takes an int and the other a
> string. They will be named GetOf_Int32 and GetOf_String by the runtime.
> But I can't see a way to "get at" these methods so that they can have a
> Name assigned. For example, if they were overloads you could do this:
>
> [ServiceContract]
> public interface IAggregate
> {
> [OperationContract(Name="GetByInt")]
> int Get( int value );
>
> [OperationContract(Name="GetByString")]
> int Get( string value );
> }
>
> Unfortunately, the serializer doesn't seem to be aware of the fact that
> it's possible to derive an interface multiple times from different closed
> "versions" of a single generic interface. If it did, it could
> differentiate the names itself.
>
> MikeS.
>
>
> "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
> news:%23UsziD1AHHA.4592@TK2MSFTNGP03.phx.gbl...
>> WCF doesn't not support open generic types , so the only way to use
>> [ServiceContract]
>> public interface ISomeInterface<SomeConcreteType>
>> {
>> [OperationContract]
>> T Get();
>> }
>>
>> Arkady
>>
>> "Mike Scott" <someone@microsoft.com> wrote in message
>> news:et7Crm0AHHA.4808@TK2MSFTNGP03.phx.gbl...
>>>I seem to have found a limitation in WCF when using generic interfaces.
>>>For example:
>>>
>>> [ServiceContract]
>>> public interface IGeneric<T>
>>> {
>>> [OperationContract]
>>> T Get();
>>> }
>>>
>>> [ServiceContract]
>>> public interface IAggregate : IGeneric<int>, IGeneric<string>
>>> {
>>> }
>>>
>>> Trying to use IAggregate fails because there are two Get() methods, one
>>> which takes an int and one which takes a string. WCF's exception message
>>> helpfully suggests adding a Name="xxx" parameter to the
>>> OperationContract. However, since the Get() method is defined in
>>> IGeneric<T>, it's not possible to put separate Name="xxx" parameters of
>>> the closed generic methods.
>>>
>>> Comments?
>>>
>>> MikeS.
>>>

>>
>>

>
>



My System SpecsSystem Spec
Old 11-09-2006   #5 (permalink)
Arkady Frenkel


 
 

Re: Limitation in WCF: ineritance of generic interfaces

Additionally , that limitation of SOA in all , if you put two( few ) methods
with the same name in the service. Look at
http://www-128.ibm.com/developerworks/library/ws-peer2/

a.. Methods: A white-space delimited list of the methods to expose in the
Web service. Note that this seems to imply that a Web service cannot expose
two methods with the same name, but there is nothing in the SOAP
specification that prevents this.

In WCF when you Trace the message flow you'll see <ActivityName> - name of
method to execute as "....Interface.Method." so when it come yet no data
arrive to check which ( from set ) method to call

Arkady


"Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
news:OUUxfz2AHHA.3928@TK2MSFTNGP03.phx.gbl...
> Hi!
> What I mean that you can't use next because it still open type
>
> [ServiceContract]
> public interface IGeneric<T>
> {
> [OperationContract]
> T Get();
> }
>
>
>
> Arkady
>
>
> "Mike Scott" <someone@microsoft.com> wrote in message
> news:Oypf$H2AHHA.4680@TK2MSFTNGP04.phx.gbl...
>> Hi again
>>
>> I know that WCF doesn't support open generic types. But my example uses
>> closed generic types, i.e. IGeneric<int> and IGeneric<string>. This is
>> not the problem.
>>
>> The problem is not being able to differentiate the names of two closed
>> generic methods resulting in deriving an interface from a generic
>> interface. The following is closed:
>>
>> [ServiceContract]
>> public interface IAggregate : IGeneric<int>, IGeneric<string>
>> {
>> }
>>
>> It has two methods called Get(), one that takes an int and the other a
>> string. They will be named GetOf_Int32 and GetOf_String by the runtime.
>> But I can't see a way to "get at" these methods so that they can have a
>> Name assigned. For example, if they were overloads you could do this:
>>
>> [ServiceContract]
>> public interface IAggregate
>> {
>> [OperationContract(Name="GetByInt")]
>> int Get( int value );
>>
>> [OperationContract(Name="GetByString")]
>> int Get( string value );
>> }
>>
>> Unfortunately, the serializer doesn't seem to be aware of the fact that
>> it's possible to derive an interface multiple times from different closed
>> "versions" of a single generic interface. If it did, it could
>> differentiate the names itself.
>>
>> MikeS.
>>
>>
>> "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
>> news:%23UsziD1AHHA.4592@TK2MSFTNGP03.phx.gbl...
>>> WCF doesn't not support open generic types , so the only way to use
>>> [ServiceContract]
>>> public interface ISomeInterface<SomeConcreteType>
>>> {
>>> [OperationContract]
>>> T Get();
>>> }
>>>
>>> Arkady
>>>
>>> "Mike Scott" <someone@microsoft.com> wrote in message
>>> news:et7Crm0AHHA.4808@TK2MSFTNGP03.phx.gbl...
>>>>I seem to have found a limitation in WCF when using generic interfaces.
>>>>For example:
>>>>
>>>> [ServiceContract]
>>>> public interface IGeneric<T>
>>>> {
>>>> [OperationContract]
>>>> T Get();
>>>> }
>>>>
>>>> [ServiceContract]
>>>> public interface IAggregate : IGeneric<int>, IGeneric<string>
>>>> {
>>>> }
>>>>
>>>> Trying to use IAggregate fails because there are two Get() methods, one
>>>> which takes an int and one which takes a string. WCF's exception
>>>> message helpfully suggests adding a Name="xxx" parameter to the
>>>> OperationContract. However, since the Get() method is defined in
>>>> IGeneric<T>, it's not possible to put separate Name="xxx" parameters of
>>>> the closed generic methods.
>>>>
>>>> Comments?
>>>>
>>>> MikeS.
>>>>
>>>
>>>

>>
>>

>
>



My System SpecsSystem Spec
Old 11-09-2006   #6 (permalink)
Mike Scott


 
 

Re: Limitation in WCF: ineritance of generic interfaces

I don't think what you're saying is correct. This works fine:

[ServiceContract]
public interface IAggregate : IGeneric<int>
{
}

IOW, it's not the "generic-ness" of the interfaces that's the problem. It's
the fact, as I've explained, that when IAggregate derives twice from the
IGeneric interface that there's a problem at runtime, simply because there's
no way to adorn the specific Get() methods with unique names.

Cheers,

Mike.

"Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
news:OUUxfz2AHHA.3928@TK2MSFTNGP03.phx.gbl...
> Hi!
> What I mean that you can't use next because it still open type
>
> [ServiceContract]
> public interface IGeneric<T>
> {
> [OperationContract]
> T Get();
> }
>
>
>
> Arkady
>
>
> "Mike Scott" <someone@microsoft.com> wrote in message
> news:Oypf$H2AHHA.4680@TK2MSFTNGP04.phx.gbl...
>> Hi again
>>
>> I know that WCF doesn't support open generic types. But my example uses
>> closed generic types, i.e. IGeneric<int> and IGeneric<string>. This is
>> not the problem.
>>
>> The problem is not being able to differentiate the names of two closed
>> generic methods resulting in deriving an interface from a generic
>> interface. The following is closed:
>>
>> [ServiceContract]
>> public interface IAggregate : IGeneric<int>, IGeneric<string>
>> {
>> }
>>
>> It has two methods called Get(), one that takes an int and the other a
>> string. They will be named GetOf_Int32 and GetOf_String by the runtime.
>> But I can't see a way to "get at" these methods so that they can have a
>> Name assigned. For example, if they were overloads you could do this:
>>
>> [ServiceContract]
>> public interface IAggregate
>> {
>> [OperationContract(Name="GetByInt")]
>> int Get( int value );
>>
>> [OperationContract(Name="GetByString")]
>> int Get( string value );
>> }
>>
>> Unfortunately, the serializer doesn't seem to be aware of the fact that
>> it's possible to derive an interface multiple times from different closed
>> "versions" of a single generic interface. If it did, it could
>> differentiate the names itself.
>>
>> MikeS.
>>
>>
>> "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
>> news:%23UsziD1AHHA.4592@TK2MSFTNGP03.phx.gbl...
>>> WCF doesn't not support open generic types , so the only way to use
>>> [ServiceContract]
>>> public interface ISomeInterface<SomeConcreteType>
>>> {
>>> [OperationContract]
>>> T Get();
>>> }
>>>
>>> Arkady
>>>
>>> "Mike Scott" <someone@microsoft.com> wrote in message
>>> news:et7Crm0AHHA.4808@TK2MSFTNGP03.phx.gbl...
>>>>I seem to have found a limitation in WCF when using generic interfaces.
>>>>For example:
>>>>
>>>> [ServiceContract]
>>>> public interface IGeneric<T>
>>>> {
>>>> [OperationContract]
>>>> T Get();
>>>> }
>>>>
>>>> [ServiceContract]
>>>> public interface IAggregate : IGeneric<int>, IGeneric<string>
>>>> {
>>>> }
>>>>
>>>> Trying to use IAggregate fails because there are two Get() methods, one
>>>> which takes an int and one which takes a string. WCF's exception
>>>> message helpfully suggests adding a Name="xxx" parameter to the
>>>> OperationContract. However, since the Get() method is defined in
>>>> IGeneric<T>, it's not possible to put separate Name="xxx" parameters of
>>>> the closed generic methods.
>>>>
>>>> Comments?
>>>>
>>>> MikeS.
>>>>
>>>
>>>

>>
>>

>
>



My System SpecsSystem Spec
Old 11-09-2006   #7 (permalink)
Mike Scott


 
 

Re: Limitation in WCF: ineritance of generic interfaces

Hi

Having two methods with the same name isn't a problem. Look at this:

[ServiceContract]
public interface IFoo
{
[OperationContract]
void Do();
}

[ServiceContract]
public interface IBar
{
[OperationContract]
void Do();
}

[ServiceContract]
public interface IFooBar : IFoo, IBar
{
}

If you try to use IFooBar over WCF the formatter will complain because there
are two Do() methods. The solution is to use the OperationContract attribute
to give them unique names. So this works:

[ServiceContract]
public interface IFoo
{
[OperationContract(Name="IFoo.Do"]
void Do();
}

[ServiceContract]
public interface IBar
{
[OperationContract(Name="IBar.Do"]
void Do();
}

[ServiceContract]
public interface IFooBar : IFoo, IBar
{
}

Like I say, the above works perfectly with WCF. But with the *generic* case
which I showed earlier in the thread, there's no way to specify different
names for the methods defined in the generic interface when you use the same
generic interface more than once as a parent of the derived interface.

It's nothing to do with the fact that the interfaces are generic, but that
there's no way to tell the formatter to use different names for the
different closed instances of the methods.

Cheers,

MikeS.

"Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
news:%23PvFTU9AHHA.1196@TK2MSFTNGP03.phx.gbl...
> Additionally , that limitation of SOA in all , if you put two( few )
> methods with the same name in the service. Look at
> http://www-128.ibm.com/developerworks/library/ws-peer2/
>
> a.. Methods: A white-space delimited list of the methods to expose in the
> Web service. Note that this seems to imply that a Web service cannot
> expose two methods with the same name, but there is nothing in the SOAP
> specification that prevents this.
>
> In WCF when you Trace the message flow you'll see <ActivityName> - name of
> method to execute as "....Interface.Method." so when it come yet no data
> arrive to check which ( from set ) method to call
>
> Arkady
>
>
> "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
> news:OUUxfz2AHHA.3928@TK2MSFTNGP03.phx.gbl...
>> Hi!
>> What I mean that you can't use next because it still open type
>>
>> [ServiceContract]
>> public interface IGeneric<T>
>> {
>> [OperationContract]
>> T Get();
>> }
>>
>>
>>
>> Arkady
>>
>>
>> "Mike Scott" <someone@microsoft.com> wrote in message
>> news:Oypf$H2AHHA.4680@TK2MSFTNGP04.phx.gbl...
>>> Hi again
>>>
>>> I know that WCF doesn't support open generic types. But my example uses
>>> closed generic types, i.e. IGeneric<int> and IGeneric<string>. This is
>>> not the problem.
>>>
>>> The problem is not being able to differentiate the names of two closed
>>> generic methods resulting in deriving an interface from a generic
>>> interface. The following is closed:
>>>
>>> [ServiceContract]
>>> public interface IAggregate : IGeneric<int>, IGeneric<string>
>>> {
>>> }
>>>
>>> It has two methods called Get(), one that takes an int and the other a
>>> string. They will be named GetOf_Int32 and GetOf_String by the runtime.
>>> But I can't see a way to "get at" these methods so that they can have a
>>> Name assigned. For example, if they were overloads you could do this:
>>>
>>> [ServiceContract]
>>> public interface IAggregate
>>> {
>>> [OperationContract(Name="GetByInt")]
>>> int Get( int value );
>>>
>>> [OperationContract(Name="GetByString")]
>>> int Get( string value );
>>> }
>>>
>>> Unfortunately, the serializer doesn't seem to be aware of the fact that
>>> it's possible to derive an interface multiple times from different
>>> closed "versions" of a single generic interface. If it did, it could
>>> differentiate the names itself.
>>>
>>> MikeS.
>>>
>>>
>>> "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
>>> news:%23UsziD1AHHA.4592@TK2MSFTNGP03.phx.gbl...
>>>> WCF doesn't not support open generic types , so the only way to use
>>>> [ServiceContract]
>>>> public interface ISomeInterface<SomeConcreteType>
>>>> {
>>>> [OperationContract]
>>>> T Get();
>>>> }
>>>>
>>>> Arkady
>>>>
>>>> "Mike Scott" <someone@microsoft.com> wrote in message
>>>> news:et7Crm0AHHA.4808@TK2MSFTNGP03.phx.gbl...
>>>>>I seem to have found a limitation in WCF when using generic interfaces.
>>>>>For example:
>>>>>
>>>>> [ServiceContract]
>>>>> public interface IGeneric<T>
>>>>> {
>>>>> [OperationContract]
>>>>> T Get();
>>>>> }
>>>>>
>>>>> [ServiceContract]
>>>>> public interface IAggregate : IGeneric<int>, IGeneric<string>
>>>>> {
>>>>> }
>>>>>
>>>>> Trying to use IAggregate fails because there are two Get() methods,
>>>>> one which takes an int and one which takes a string. WCF's exception
>>>>> message helpfully suggests adding a Name="xxx" parameter to the
>>>>> OperationContract. However, since the Get() method is defined in
>>>>> IGeneric<T>, it's not possible to put separate Name="xxx" parameters
>>>>> of the closed generic methods.
>>>>>
>>>>> Comments?
>>>>>
>>>>> MikeS.
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



My System SpecsSystem Spec
Old 11-10-2006   #8 (permalink)
Arkady Frenkel


 
 

Re: Limitation in WCF: ineritance of generic interfaces

You show using with close type - int and I wrote open type - T
Arkady

"Mike Scott" <someone@microsoft.com> wrote in message
news:uOIQJyCBHHA.5060@TK2MSFTNGP02.phx.gbl...
>I don't think what you're saying is correct. This works fine:
>
> [ServiceContract]
> public interface IAggregate : IGeneric<int>
> {
> }
>
> IOW, it's not the "generic-ness" of the interfaces that's the problem.
> It's the fact, as I've explained, that when IAggregate derives twice from
> the IGeneric interface that there's a problem at runtime, simply because
> there's no way to adorn the specific Get() methods with unique names.
>
> Cheers,
>
> Mike.
>
> "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
> news:OUUxfz2AHHA.3928@TK2MSFTNGP03.phx.gbl...
>> Hi!
>> What I mean that you can't use next because it still open type
>>
>> [ServiceContract]
>> public interface IGeneric<T>
>> {
>> [OperationContract]
>> T Get();
>> }
>>
>>
>>
>> Arkady
>>
>>
>> "Mike Scott" <someone@microsoft.com> wrote in message
>> news:Oypf$H2AHHA.4680@TK2MSFTNGP04.phx.gbl...
>>> Hi again
>>>
>>> I know that WCF doesn't support open generic types. But my example uses
>>> closed generic types, i.e. IGeneric<int> and IGeneric<string>. This is
>>> not the problem.
>>>
>>> The problem is not being able to differentiate the names of two closed
>>> generic methods resulting in deriving an interface from a generic
>>> interface. The following is closed:
>>>
>>> [ServiceContract]
>>> public interface IAggregate : IGeneric<int>, IGeneric<string>
>>> {
>>> }
>>>
>>> It has two methods called Get(), one that takes an int and the other a
>>> string. They will be named GetOf_Int32 and GetOf_String by the runtime.
>>> But I can't see a way to "get at" these methods so that they can have a
>>> Name assigned. For example, if they were overloads you could do this:
>>>
>>> [ServiceContract]
>>> public interface IAggregate
>>> {
>>> [OperationContract(Name="GetByInt")]
>>> int Get( int value );
>>>
>>> [OperationContract(Name="GetByString")]
>>> int Get( string value );
>>> }
>>>
>>> Unfortunately, the serializer doesn't seem to be aware of the fact that
>>> it's possible to derive an interface multiple times from different
>>> closed "versions" of a single generic interface. If it did, it could
>>> differentiate the names itself.
>>>
>>> MikeS.
>>>
>>>
>>> "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
>>> news:%23UsziD1AHHA.4592@TK2MSFTNGP03.phx.gbl...
>>>> WCF doesn't not support open generic types , so the only way to use
>>>> [ServiceContract]
>>>> public interface ISomeInterface<SomeConcreteType>
>>>> {
>>>> [OperationContract]
>>>> T Get();
>>>> }
>>>>
>>>> Arkady
>>>>
>>>> "Mike Scott" <someone@microsoft.com> wrote in message
>>>> news:et7Crm0AHHA.4808@TK2MSFTNGP03.phx.gbl...
>>>>>I seem to have found a limitation in WCF when using generic interfaces.
>>>>>For example:
>>>>>
>>>>> [ServiceContract]
>>>>> public interface IGeneric<T>
>>>>> {
>>>>> [OperationContract]
>>>>> T Get();
>>>>> }
>>>>>
>>>>> [ServiceContract]
>>>>> public interface IAggregate : IGeneric<int>, IGeneric<string>
>>>>> {
>>>>> }
>>>>>
>>>>> Trying to use IAggregate fails because there are two Get() methods,
>>>>> one which takes an int and one which takes a string. WCF's exception
>>>>> message helpfully suggests adding a Name="xxx" parameter to the
>>>>> OperationContract. However, since the Get() method is defined in
>>>>> IGeneric<T>, it's not possible to put separate Name="xxx" parameters
>>>>> of the closed generic methods.
>>>>>
>>>>> Comments?
>>>>>
>>>>> MikeS.
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



My System SpecsSystem Spec
Old 11-10-2006   #9 (permalink)
Arkady Frenkel


 
 

Re: Limitation in WCF: ineritance of generic interfaces

That work because you open type still in use and that not allow to change
name as you did with Name attribute
Arkady

"Mike Scott" <someone@microsoft.com> wrote in message
news:etIB21CBHHA.2328@TK2MSFTNGP02.phx.gbl...
> Hi
>
> Having two methods with the same name isn't a problem. Look at this:
>
> [ServiceContract]
> public interface IFoo
> {
> [OperationContract]
> void Do();
> }
>
> [ServiceContract]
> public interface IBar
> {
> [OperationContract]
> void Do();
> }
>
> [ServiceContract]
> public interface IFooBar : IFoo, IBar
> {
> }
>
> If you try to use IFooBar over WCF the formatter will complain because
> there are two Do() methods. The solution is to use the OperationContract
> attribute to give them unique names. So this works:
>
> [ServiceContract]
> public interface IFoo
> {
> [OperationContract(Name="IFoo.Do"]
> void Do();
> }
>
> [ServiceContract]
> public interface IBar
> {
> [OperationContract(Name="IBar.Do"]
> void Do();
> }
>
> [ServiceContract]
> public interface IFooBar : IFoo, IBar
> {
> }
>
> Like I say, the above works perfectly with WCF. But with the *generic*
> case which I showed earlier in the thread, there's no way to specify
> different names for the methods defined in the generic interface when you
> use the same generic interface more than once as a parent of the derived
> interface.
>
> It's nothing to do with the fact that the interfaces are generic, but that
> there's no way to tell the formatter to use different names for the
> different closed instances of the methods.
>
> Cheers,
>
> MikeS.
>
> "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
> news:%23PvFTU9AHHA.1196@TK2MSFTNGP03.phx.gbl...
>> Additionally , that limitation of SOA in all , if you put two( few )
>> methods with the same name in the service. Look at
>> http://www-128.ibm.com/developerworks/library/ws-peer2/
>>
>> a.. Methods: A white-space delimited list of the methods to expose in the
>> Web service. Note that this seems to imply that a Web service cannot
>> expose two methods with the same name, but there is nothing in the SOAP
>> specification that prevents this.
>>
>> In WCF when you Trace the message flow you'll see <ActivityName> - name
>> of method to execute as "....Interface.Method." so when it come yet no
>> data arrive to check which ( from set ) method to call
>>
>> Arkady
>>
>>
>> "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
>> news:OUUxfz2AHHA.3928@TK2MSFTNGP03.phx.gbl...
>>> Hi!
>>> What I mean that you can't use next because it still open type
>>>
>>> [ServiceContract]
>>> public interface IGeneric<T>
>>> {
>>> [OperationContract]
>>> T Get();
>>> }
>>>
>>>
>>>
>>> Arkady
>>>
>>>
>>> "Mike Scott" <someone@microsoft.com> wrote in message
>>> news:Oypf$H2AHHA.4680@TK2MSFTNGP04.phx.gbl...
>>>> Hi again
>>>>
>>>> I know that WCF doesn't support open generic types. But my example uses
>>>> closed generic types, i.e. IGeneric<int> and IGeneric<string>. This is
>>>> not the problem.
>>>>
>>>> The problem is not being able to differentiate the names of two closed
>>>> generic methods resulting in deriving an interface from a generic
>>>> interface. The following is closed:
>>>>
>>>> [ServiceContract]
>>>> public interface IAggregate : IGeneric<int>, IGeneric<string>
>>>> {
>>>> }
>>>>
>>>> It has two methods called Get(), one that takes an int and the other a
>>>> string. They will be named GetOf_Int32 and GetOf_String by the runtime.
>>>> But I can't see a way to "get at" these methods so that they can have a
>>>> Name assigned. For example, if they were overloads you could do this:
>>>>
>>>> [ServiceContract]
>>>> public interface IAggregate
>>>> {
>>>> [OperationContract(Name="GetByInt")]
>>>> int Get( int value );
>>>>
>>>> [OperationContract(Name="GetByString")]
>>>> int Get( string value );
>>>> }
>>>>
>>>> Unfortunately, the serializer doesn't seem to be aware of the fact that
>>>> it's possible to derive an interface multiple times from different
>>>> closed "versions" of a single generic interface. If it did, it could
>>>> differentiate the names itself.
>>>>
>>>> MikeS.
>>>>
>>>>
>>>> "Arkady Frenkel" <arkadyf@hotmailxdotx.com> wrote in message
>>>> news:%23UsziD1AHHA.4592@TK2MSFTNGP03.phx.gbl...
>>>>> WCF doesn't not support open generic types , so the only way to use
>>>>> [ServiceContract]
>>>>> public interface ISomeInterface<SomeConcreteType>
>>>>> {
>>>>> [OperationContract]
>>>>> T Get();
>>>>> }
>>>>>
>>>>> Arkady
>>>>>
>>>>> "Mike Scott" <someone@microsoft.com> wrote in message
>>>>> news:et7Crm0AHHA.4808@TK2MSFTNGP03.phx.gbl...
>>>>>>I seem to have found a limitation in WCF when using generic
>>>>>>interfaces. For example:
>>>>>>
>>>>>> [ServiceContract]
>>>>>> public interface IGeneric<T>
>>>>>> {
>>>>>> [OperationContract]
>>>>>> T Get();
>>>>>> }
>>>>>>
>>>>>> [ServiceContract]
>>>>>> public interface IAggregate : IGeneric<int>, IGeneric<string>
>>>>>> {
>>>>>> }
>>>>>>
>>>>>> Trying to use IAggregate fails because there are two Get() methods,
>>>>>> one which takes an int and one which takes a string. WCF's exception
>>>>>> message helpfully suggests adding a Name="xxx" parameter to the
>>>>>> OperationContract. However, since the Get() method is defined in
>>>>>> IGeneric<T>, it's not possible to put separate Name="xxx" parameters
>>>>>> of the closed generic methods.
>>>>>>
>>>>>> Comments?
>>>>>>
>>>>>> MikeS.
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



My System SpecsSystem Spec
Old 12-11-2006   #10 (permalink)
Sara Wong [MS]


 
 

RE: Limitation in WCF: ineritance of generic interfaces

Mike,

This is a known limiation. You can work around it by using the
[ServiceContract] attributes on the class where you implements all the closed
generic method. You can then specify names like below:

public interface IGeneric<T>
{
T Get();
}

[ServiceContract]
public class Aggregates : IGeneric<int>, I Generic<string>
{
[OperationContract(Name="GetInt")]
public int Get() { return ...}

[OperationContract(Name="GetString")]
public string() { return ...}

}

Hope this helps.

Thanks,
Sara



"Mike Scott" wrote:

> I seem to have found a limitation in WCF when using generic interfaces. For
> example:
>
> [ServiceContract]
> public interface IGeneric<T>
> {
> [OperationContract]
> T Get();
> }
>
> [ServiceContract]
> public interface IAggregate : IGeneric<int>, IGeneric<string>
> {
> }
>
> Trying to use IAggregate fails because there are two Get() methods, one
> which takes an int and one which takes a string. WCF's exception message
> helpfully suggests adding a Name="xxx" parameter to the OperationContract.
> However, since the Get() method is defined in IGeneric<T>, it's not possible
> to put separate Name="xxx" parameters of the closed generic methods.
>
> Comments?
>
> MikeS.
>
>
>

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Video Capture Interfaces VB Script
Unable to set INetFWRule Interfaces property Vista security
Bridge network interfaces? Vista networking & sharing
switching between Basic & Aero interfaces Vista account administration
Using Interfaces PowerShell


Vista Forums 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 Ltd

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