RE: Custom classes with web services
From: Dan Rogers (danro_at_microsoft.com)
Date: 12/01/04
- Next message: Dan Rogers: "RE: Basic question about creating/setting up webservices"
- Previous message: news.microsoft.com: "Basic question about creating/setting up webservices"
- In reply to: Chris Dunaway: "Custom classes with web services"
- Next in thread: Chris Dunaway: "Re: Custom classes with web services"
- Reply: Chris Dunaway: "Re: Custom classes with web services"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 01 Dec 2004 19:38:44 GMT
Hi Chris,
What you are experiencing is the automatic behavior of the generated proxy.
What you need to do is work with a modified proxy, as you have discovered,
or serialize to XML as the means to move data between your classes. The
proxy is an assembly that is generated as a part of the project where you
do an add-web-reference. The way I recommend you work with this is to open
the proxy code - no need to change references, per se. Just comment out
the additional copy of the classes in question in the code for the proxy
class, and then add a "imports" statement for your custom DLL namespace at
the top of that file. This should make the proxy actually use your shared
DLL rather than the projection that is created by reading the WSDL file
from the web service.
As far as changing your web service, this is possibly an area that you want
to think about. If changes to your web service break the interface to your
existing clients, then perhaps you are still very early on in development.
In a production environment, you typically won't have the luxury of
breaking an unknown number of callers - so I would suggest that this is a
cost of dealing with an early-on stage in development where it is normal to
be futzing around with the members of your classes and method interfaces.
I hope this helps,
Dan Rogers
Microsoft Corporation
--------------------
>From: Chris Dunaway <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net">
>Subject: Custom classes with web services
>User-Agent: 40tude_Dialog/2.0.10.1
>MIME-Version: 1.0
>Content-Type: text/plain; charset="us-ascii"
>Content-Transfer-Encoding: 7bit
>Date: Wed, 1 Dec 2004 11:33:25 -0600
>Message-ID: <1vdp14koua85a.g1bp8fgo9ojk.dlg@40tude.net>
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
>NNTP-Posting-Host: 216.143.212.98
>Lines: 1
>Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
phx.gbl
>Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservices:26941
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
>
>I have a custom class called User with fields like Name, Address, etc.
>This is compiled into a .dll.
>
>I also have a Windows app that will reference a couple of web services.
>
>Both the Windows app and the Webservices will use this User class.
>
>Each web service references the .dll to get the user class. My Windows app
>also references the .dll to get the User class.
>
>My problem arises when I reference the web services. I can reference them
>ok but they each have their own version of the User class! Further, they
>are not compatible.
>
>For example, my .dll with the User class has a namespace of MyNamespace and
>the two web services are as follows:
>
>Authenticate.asmx references the .dll and has the following method:
>
>Imports MyNamespace
>
><WebMethod> _
>Public Function Login(usr as String, pwd As String) As User
>End Function
>
>
>MainWebService.asmx also references the .dll has the folowing method:
>
>Imports MyNamespace
>
><WebMethod> _
>Public Sub Process(usr As User)
>End Sub
>
>All seems OK but when I reference both web services from my windows App, I
>get two 'extra' User classes. I want to call them this way:
>
>Public Sub CallWebServices()
> Dim oAuth As New Authenticate
> Dim oMain As New MainWebService
> Dim oUsr As MyNamespace.User
>
> oUsr = oAuth.Login("user","password")
> 'The line above fails stating that an object of type MyNamespace.User
> 'cannot be converted to an object of type Authenticate.User
> 'If I use the following:
>
> Dim oUsr2 As Authenticate.User
> oUsr2 = oAuth.Login("user", "password")
> 'The above seems to work OK but then the following line fails saying
> 'An object of type Authenticate.User cannot be converted to
> 'MainWebService.User
>
> oMain.Process(oUsr2) 'This fails
>
>End Sub
>
>I can change the Reference.vb files for each web service to use the correct
>user class (the one in MyNamespace) but if I update the web service then
>the changes will be lost.
>
>How can I use a custom class in a Windows App that references a web service
>and have the web service return the correct types?
>
>--
>Chris
>
>dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
>
>To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
>replace certain words in my E-Mail address.
>
- Next message: Dan Rogers: "RE: Basic question about creating/setting up webservices"
- Previous message: news.microsoft.com: "Basic question about creating/setting up webservices"
- In reply to: Chris Dunaway: "Custom classes with web services"
- Next in thread: Chris Dunaway: "Re: Custom classes with web services"
- Reply: Chris Dunaway: "Re: Custom classes with web services"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|