Issue with redefined .Net custome type in the proxy class for a web service...

K

Kris

Hi there,

I have web service which uses custom .Net types as parameter/return types. These custom types r defined in a seperate assembly and being refered in the web service using "using" directive for that assembly.

Now when I Add a Web Reference to the client application which consumes this web service, it is generating a proxy class for the web service in which it is REDEFINING the custome types and adding relevent schema types, instead of just using the using directive for the assembly containg custom types. Note that I have this assembly as part of the solution but not in GAC.

The issue with this is it is conflicting between the types defined in client application(I used using directive for this custom types assembly) and one returned from the webmethods invokation. Is there any way to have proxy class generated for the web service refer these custom types using that assembly's using directive instead of redefining them in the proxy class.

It works fine if I manually delete the custom types from the proxy class generated and specify using directive for the assembly containg custom types. But I need this to happen automatically as I have several web services which r refering those custom types and also the issue is becoming even worse if there are any updates in the web service code and do update web references in the client project.

Any help will be greatly appreciated...

Thanks in advance...
Kris

Posted via DevelopmentNow Groups
www.developmentnow.com/g
www.developmentnow.com
 
D

DalePres

The proxy generated by the Add Web Reference wizard is always going to based
on reading the WSDL from the web service. Methods I have used to solve
similar problems include any or combinations of:

1. manually editing the proxy class,
2. creating the custom class by deriving from MarshalByRefObject. Create
the instance your client needs on the server and then the server and client
are now using the same class and can share it.
3 (and this is the easiest where it works). Add the XMLInclude attribute to
your custom class and to any classes within your custom class.

DalePres
MCAD, MCDBA, MCSE
 
K

Krishna Kanthi

Hi All,

Thanks for all ur replies. I checked this article before on shared types
on msdn. As I said before I have several .Net custom types defined in
one assembly and I am using them in several web services(around 50). All
I am looking for is to see if there is any way to add a reference to
this assembly automatically in the proxy classes generated.

I added a using directive for this custom types assembly in the actual
web service implementation code. And the issue is when the proxy class
is generated(during Add WebReference/or wsdl.exe) it is redefining those
custom types in each proxy class instead of adding the using directive
as it is in the actual web service imlementation code(in asmx.cs file).

Any idea?

thnaks,
Kris
 
D

DalePres

The problem may be in the implementation in the client. Rather than point
the client to the custom type in the assembly, you might try creating the
type as a public member of the web service and then declare the custom type
in the client as an instance of the web service class member. In that way,
you get the web service and its client identifying the same class rather
than them acting like they are looking at two identical but separate
classes.

HTH

DalePres
MCAD, MCDBA, MCSE
 
K

Kris

Well the problem with this is I am using the same custom type as
parameter/return type in the client application. And I also have several
client applications which use these custom types. Hence I can not do
what u have suggested here.

Also, why the proxy generated is redefining the custom type instead of
adding a using directive at the top, as it does for several builtin .Net
types?

Any ideas further will be appreciated.

Thanks,
Kris
 
D

DalePres

Keep in mind that web services are supposedly to be cross platform and
standards based. Microsoft is limited on how much they can vary from those
standards and still be accepted in the marketplace.

If you want to have better control over types, inlcuding sharing types via
the GAC, look into .Net Remoting using the BinaryFormatter.

HTH

DalePres
 
D

Dan Rogers

Hi,

In short, no. Web services do not share implementations explicitely as a
philosophical tenet. So the automatically generated proxy code does not
magically copy an external DLL into it's local implementation.

You have a few choices: Hand code the proxy you want to have all of your
clients use. This proxy code would be an assembly (just some code, eh?)
that imports the shared assembly by reference. Then you would ship both
DLL's to all of your clients, and they would all get the right types.

A simple solution is to tell the people generating the proxies to name the
proxy with the same namespace as the shared assembly. They should NOT use
your shared DLL, but should get all of their definitions from the new proxy
class - which has shadow methods and approximations of the data types. No
methods from the shared assembly will be avaliable - but this is the way
that web service based coupling is supposed to work.

--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top