By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,932 Members | 1,540 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,932 IT Pros & Developers. It's quick & easy.

two references to the same class in WebService client problem

P: n/a
Hi,
I have the following problem. I've created 2 WebServices (A and B) that
reference to the same assembly - Credentials. Each WebService (A and B)
expose method GetCredentials that returns the Credentials class.

public class ServiceA : System.Web.Services.WebService
{
[WebMethod]
public Credentials GetCredentials()
{
return (new Credentials());
}
}

The same code i in ServiceB.

Now I create a client and add the 2 Web references to WebServiceA and
WebServiceB. Here is the problem.

The following piece of code in my client is not compiled:

ServiceA a = new ServiceA();
ServiceB b = new ServiceB();

Credentials ca = a.GetCredentials();
Credentials cb = b.GetCredentials();

The compiler is confused which class I'm referencing and require an explicit
type conversion between 2 instances of Credentials. But they are the same
class! Any ideas?

Thanks in advance
Nov 23 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Hello Ed,
Unfortunately you have to convert one credential object to the other.
I dont know the intension behind this code but, One thing you could do to
solve the problem is have a service that only does getCredentials so now
you have 3 services. A, B and the new GetCredentials service. That way you
can have a single type and not worry about conversion.

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
Hi,
I have the following problem. I've created 2 WebServices (A and B)
that
reference to the same assembly - Credentials. Each WebService (A and
B)
expose method GetCredentials that returns the Credentials class.
public class ServiceA : System.Web.Services.WebService
{
[WebMethod]
public Credentials GetCredentials()
{
return (new Credentials());
}
}
The same code i in ServiceB.

Now I create a client and add the 2 Web references to WebServiceA and
WebServiceB. Here is the problem.

The following piece of code in my client is not compiled:

ServiceA a = new ServiceA();
ServiceB b = new ServiceB();
Credentials ca = a.GetCredentials();
Credentials cb = b.GetCredentials();
The compiler is confused which class I'm referencing and require an
explicit type conversion between 2 instances of Credentials. But they
are the same class! Any ideas?

Thanks in advance

Nov 23 '05 #2

P: n/a
Dilip,

Thanks a lot for the reply. Do you think there might be a way to overcome
this if I'll use WSDL rather than Visual Studio to add the references? There
is no way to tell the framework that all the services refer to the same
Class? It seems like I'm not doing something unique, so I was hoping there is
a solution, may be some attribute...

"Dilip Krishnan" wrote:
Hello Ed,
Unfortunately you have to convert one credential object to the other.
I dont know the intension behind this code but, One thing you could do to
solve the problem is have a service that only does getCredentials so now
you have 3 services. A, B and the new GetCredentials service. That way you
can have a single type and not worry about conversion.

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
Hi,
I have the following problem. I've created 2 WebServices (A and B)
that
reference to the same assembly - Credentials. Each WebService (A and
B)
expose method GetCredentials that returns the Credentials class.
public class ServiceA : System.Web.Services.WebService
{
[WebMethod]
public Credentials GetCredentials()
{
return (new Credentials());
}
}
The same code i in ServiceB.

Now I create a client and add the 2 Web references to WebServiceA and
WebServiceB. Here is the problem.

The following piece of code in my client is not compiled:

ServiceA a = new ServiceA();
ServiceB b = new ServiceB();
Credentials ca = a.GetCredentials();
Credentials cb = b.GetCredentials();
The compiler is confused which class I'm referencing and require an
explicit type conversion between 2 instances of Credentials. But they
are the same class! Any ideas?

Thanks in advance


Nov 23 '05 #3

P: n/a
Take a look at the generated proxy, use(wsdl.exe instead of add web
refernce), now for the services you'll have two Credential type each
belong to ServiceA and another is to ServiceB, remove the credential
class definition in your ServiceB(or ServiceA).. and if you put this two
files under the same namespace, it will share the type

regards
erymuzuan

Ed Gonen wrote:
Dilip,

Thanks a lot for the reply. Do you think there might be a way to overcome
this if I'll use WSDL rather than Visual Studio to add the references? There
is no way to tell the framework that all the services refer to the same
Class? It seems like I'm not doing something unique, so I was hoping there is
a solution, may be some attribute...

"Dilip Krishnan" wrote:

Hello Ed,
Unfortunately you have to convert one credential object to the other.
I dont know the intension behind this code but, One thing you could do to
solve the problem is have a service that only does getCredentials so now
you have 3 services. A, B and the new GetCredentials service. That way you
can have a single type and not worry about conversion.

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

Hi,
I have the following problem. I've created 2 WebServices (A and B)
that
reference to the same assembly - Credentials. Each WebService (A and
B)
expose method GetCredentials that returns the Credentials class.
public class ServiceA : System.Web.Services.WebService
{
[WebMethod]
public Credentials GetCredentials()
{
return (new Credentials());
}
}
The same code i in ServiceB.

Now I create a client and add the 2 Web references to WebServiceA and
WebServiceB. Here is the problem.

The following piece of code in my client is not compiled:

ServiceA a = new ServiceA();
ServiceB b = new ServiceB();
Credentials ca = a.GetCredentials();
Credentials cb = b.GetCredentials();
The compiler is confused which class I'm referencing and require an
explicit type conversion between 2 instances of Credentials. But they
are the same class! Any ideas?

Thanks in advance


Nov 23 '05 #4

P: n/a
Right, this is not something unique.

What Dilip suggests will work, but there is a better way. What you should
do is modify the generated types (generated by "Add Web Reference...") so
that they share a single type. This article discusses the issue in greater
detail.
http://msdn.microsoft.com/library/en...ce07162002.asp

The same difficulty arises if you use wsdl.exe and build the proxies from
the command line. The same workaround applies.

In whidbey (.NET 2.0, which is in beta now), the situation is much better.
You can specify a single shared type and there is no need for manual
modification of the generated proxy (Stub) code.

Best,

-Dino

"Ed Gonen" <Ed*****@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
Dilip,

Thanks a lot for the reply. Do you think there might be a way to overcome
this if I'll use WSDL rather than Visual Studio to add the references?
There
is no way to tell the framework that all the services refer to the same
Class? It seems like I'm not doing something unique, so I was hoping there
is
a solution, may be some attribute...

"Dilip Krishnan" wrote:
Hello Ed,
Unfortunately you have to convert one credential object to the other.
I dont know the intension behind this code but, One thing you could do to
solve the problem is have a service that only does getCredentials so now
you have 3 services. A, B and the new GetCredentials service. That way
you
can have a single type and not worry about conversion.

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
> Hi,
> I have the following problem. I've created 2 WebServices (A and B)
> that
> reference to the same assembly - Credentials. Each WebService (A and
> B)
> expose method GetCredentials that returns the Credentials class.
> public class ServiceA : System.Web.Services.WebService
> {
> [WebMethod]
> public Credentials GetCredentials()
> {
> return (new Credentials());
> }
> }
> The same code i in ServiceB.
>
> Now I create a client and add the 2 Web references to WebServiceA and
> WebServiceB. Here is the problem.
>
> The following piece of code in my client is not compiled:
>
> ServiceA a = new ServiceA();
> ServiceB b = new ServiceB();
> Credentials ca = a.GetCredentials();
> Credentials cb = b.GetCredentials();
> The compiler is confused which class I'm referencing and require an
> explicit type conversion between 2 instances of Credentials. But they
> are the same class! Any ideas?
>
> Thanks in advance
>


Nov 23 '05 #5

P: n/a
Thanks,
That is exactly what I was doing when got your reply :). This works fine
but, of course, the problem is that I'll have to do that every time I update
the Web References, as the file is regenerated. I'm just so surprised Visual
Studio does not take care on this... Am I right?

Ed

"erymuzuan" wrote:
Take a look at the generated proxy, use(wsdl.exe instead of add web
refernce), now for the services you'll have two Credential type each
belong to ServiceA and another is to ServiceB, remove the credential
class definition in your ServiceB(or ServiceA).. and if you put this two
files under the same namespace, it will share the type

regards
erymuzuan

Ed Gonen wrote:
Dilip,

Thanks a lot for the reply. Do you think there might be a way to overcome
this if I'll use WSDL rather than Visual Studio to add the references? There
is no way to tell the framework that all the services refer to the same
Class? It seems like I'm not doing something unique, so I was hoping there is
a solution, may be some attribute...

"Dilip Krishnan" wrote:

Hello Ed,
Unfortunately you have to convert one credential object to the other.
I dont know the intension behind this code but, One thing you could do to
solve the problem is have a service that only does getCredentials so now
you have 3 services. A, B and the new GetCredentials service. That way you
can have a single type and not worry about conversion.

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
Hi,
I have the following problem. I've created 2 WebServices (A and B)
that
reference to the same assembly - Credentials. Each WebService (A and
B)
expose method GetCredentials that returns the Credentials class.
public class ServiceA : System.Web.Services.WebService
{
[WebMethod]
public Credentials GetCredentials()
{
return (new Credentials());
}
}
The same code i in ServiceB.

Now I create a client and add the 2 Web references to WebServiceA and
WebServiceB. Here is the problem.

The following piece of code in my client is not compiled:

ServiceA a = new ServiceA();
ServiceB b = new ServiceB();
Credentials ca = a.GetCredentials();
Credentials cb = b.GetCredentials();
The compiler is confused which class I'm referencing and require an
explicit type conversion between 2 instances of Credentials. But they
are the same class! Any ideas?

Thanks in advance

Nov 23 '05 #6

P: n/a
Dino,
Thanks for the reply. It seems like in all cases I'll have to edit the the
proxy files after generation manually (or write a simple utility that does
that). Am I missing anything? That is what the article you mention says. Is
that correct? And are you saying there is a solution for that in 2.0?

"Dino Chiesa [Microsoft]" wrote:
Right, this is not something unique.

What Dilip suggests will work, but there is a better way. What you should
do is modify the generated types (generated by "Add Web Reference...") so
that they share a single type. This article discusses the issue in greater
detail.
http://msdn.microsoft.com/library/en...ce07162002.asp

The same difficulty arises if you use wsdl.exe and build the proxies from
the command line. The same workaround applies.

In whidbey (.NET 2.0, which is in beta now), the situation is much better.
You can specify a single shared type and there is no need for manual
modification of the generated proxy (Stub) code.

Best,

-Dino

"Ed Gonen" <Ed*****@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
Dilip,

Thanks a lot for the reply. Do you think there might be a way to overcome
this if I'll use WSDL rather than Visual Studio to add the references?
There
is no way to tell the framework that all the services refer to the same
Class? It seems like I'm not doing something unique, so I was hoping there
is
a solution, may be some attribute...

"Dilip Krishnan" wrote:
Hello Ed,
Unfortunately you have to convert one credential object to the other.
I dont know the intension behind this code but, One thing you could do to
solve the problem is have a service that only does getCredentials so now
you have 3 services. A, B and the new GetCredentials service. That way
you
can have a single type and not worry about conversion.

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

> Hi,
> I have the following problem. I've created 2 WebServices (A and B)
> that
> reference to the same assembly - Credentials. Each WebService (A and
> B)
> expose method GetCredentials that returns the Credentials class.
> public class ServiceA : System.Web.Services.WebService
> {
> [WebMethod]
> public Credentials GetCredentials()
> {
> return (new Credentials());
> }
> }
> The same code i in ServiceB.
>
> Now I create a client and add the 2 Web references to WebServiceA and
> WebServiceB. Here is the problem.
>
> The following piece of code in my client is not compiled:
>
> ServiceA a = new ServiceA();
> ServiceB b = new ServiceB();
> Credentials ca = a.GetCredentials();
> Credentials cb = b.GetCredentials();
> The compiler is confused which class I'm referencing and require an
> explicit type conversion between 2 instances of Credentials. But they
> are the same class! Any ideas?
>
> Thanks in advance
>


Nov 23 '05 #7

P: n/a
Hello erymuzuan,
Take a look at the generated proxy, use(wsdl.exe instead of add web
refernce), now for the services you'll have two Credential type each
belong to ServiceA and another is to ServiceB, remove the credential
class definition in your ServiceB(or ServiceA).. and if you put this
two files under the same namespace, it will share the type

Wouldnt advise this as you will loose all your changes every time you regenerate
the proxy class

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

Nov 23 '05 #8

P: n/a
Hello Ed,
Yes in 2.0 you can share types.... :) [0]

[0] - http://www.theserverside.net/blogs/s...SStrikesBackP6

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
Dino,
Thanks for the reply. It seems like in all cases I'll have to edit the
the
proxy files after generation manually (or write a simple utility that
does
that). Am I missing anything? That is what the article you mention
says. Is
that correct? And are you saying there is a solution for that in 2.0?
"Dino Chiesa [Microsoft]" wrote:
Right, this is not something unique.

What Dilip suggests will work, but there is a better way. What you
should do is modify the generated types (generated by "Add Web
Reference...") so that they share a single type. This article
discusses the issue in greater detail.
http://msdn.microsoft.com/library/en...service0716200
2.asp

The same difficulty arises if you use wsdl.exe and build the proxies
from the command line. The same workaround applies.

In whidbey (.NET 2.0, which is in beta now), the situation is much
better. You can specify a single shared type and there is no need for
manual modification of the generated proxy (Stub) code.

Best,

-Dino

"Ed Gonen" <Ed*****@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
Dilip,

Thanks a lot for the reply. Do you think there might be a way to
overcome
this if I'll use WSDL rather than Visual Studio to add the
references?
There
is no way to tell the framework that all the services refer to the
same
Class? It seems like I'm not doing something unique, so I was hoping
there
is
a solution, may be some attribute...
"Dilip Krishnan" wrote:

Hello Ed,
Unfortunately you have to convert one credential object to the
other.
I dont know the intension behind this code but, One thing you could
do to
solve the problem is have a service that only does getCredentials
so now
you have 3 services. A, B and the new GetCredentials service. That
way
you
can have a single type and not worry about conversion.
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
> Hi,
> I have the following problem. I've created 2 WebServices (A and B)
> that
> reference to the same assembly - Credentials. Each WebService (A
> and
> B)
> expose method GetCredentials that returns the Credentials class.
> public class ServiceA : System.Web.Services.WebService
> {
> [WebMethod]
> public Credentials GetCredentials()
> {
> return (new Credentials());
> }
> }
> The same code i in ServiceB.
> Now I create a client and add the 2 Web references to WebServiceA
> and WebServiceB. Here is the problem.
>
> The following piece of code in my client is not compiled:
>
> ServiceA a = new ServiceA();
> ServiceB b = new ServiceB();
> Credentials ca = a.GetCredentials();
> Credentials cb = b.GetCredentials();
> The compiler is confused which class I'm referencing and require
> an
> explicit type conversion between 2 instances of Credentials. But
> they
> are the same class! Any ideas?
> Thanks in advance
>

Nov 23 '05 #9

P: n/a
Thanks a lot, the whole thread was very helpful

"Dilip Krishnan" wrote:
Hello Ed,
Yes in 2.0 you can share types.... :) [0]

[0] - http://www.theserverside.net/blogs/s...SStrikesBackP6

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
Dino,
Thanks for the reply. It seems like in all cases I'll have to edit the
the
proxy files after generation manually (or write a simple utility that
does
that). Am I missing anything? That is what the article you mention
says. Is
that correct? And are you saying there is a solution for that in 2.0?
"Dino Chiesa [Microsoft]" wrote:
Right, this is not something unique.

What Dilip suggests will work, but there is a better way. What you
should do is modify the generated types (generated by "Add Web
Reference...") so that they share a single type. This article
discusses the issue in greater detail.
http://msdn.microsoft.com/library/en...service0716200
2.asp

The same difficulty arises if you use wsdl.exe and build the proxies
from the command line. The same workaround applies.

In whidbey (.NET 2.0, which is in beta now), the situation is much
better. You can specify a single shared type and there is no need for
manual modification of the generated proxy (Stub) code.

Best,

-Dino

"Ed Gonen" <Ed*****@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...

Dilip,

Thanks a lot for the reply. Do you think there might be a way to
overcome
this if I'll use WSDL rather than Visual Studio to add the
references?
There
is no way to tell the framework that all the services refer to the
same
Class? It seems like I'm not doing something unique, so I was hoping
there
is
a solution, may be some attribute...
"Dilip Krishnan" wrote:

> Hello Ed,
> Unfortunately you have to convert one credential object to the
> other.
> I dont know the intension behind this code but, One thing you could
> do to
> solve the problem is have a service that only does getCredentials
> so now
> you have 3 services. A, B and the new GetCredentials service. That
> way
> you
> can have a single type and not worry about conversion.
> HTH
> Regards,
> Dilip Krishnan
> MCAD, MCSD.net
> dkrishnan at geniant dot com
> http://www.geniant.com
>> Hi,
>> I have the following problem. I've created 2 WebServices (A and B)
>> that
>> reference to the same assembly - Credentials. Each WebService (A
>> and
>> B)
>> expose method GetCredentials that returns the Credentials class.
>> public class ServiceA : System.Web.Services.WebService
>> {
>> [WebMethod]
>> public Credentials GetCredentials()
>> {
>> return (new Credentials());
>> }
>> }
>> The same code i in ServiceB.
>> Now I create a client and add the 2 Web references to WebServiceA
>> and WebServiceB. Here is the problem.
>>
>> The following piece of code in my client is not compiled:
>>
>> ServiceA a = new ServiceA();
>> ServiceB b = new ServiceB();
>> Credentials ca = a.GetCredentials();
>> Credentials cb = b.GetCredentials();
>> The compiler is confused which class I'm referencing and require
>> an
>> explicit type conversion between 2 instances of Credentials. But
>> they
>> are the same class! Any ideas?
>> Thanks in advance
>>


Nov 23 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.