Custom classes with web services

From: Chris Dunaway ("dunawayc[[at]_lunchmeat_sbcglobal[dot]]net")
Date: 12/01/04


Date: Wed, 1 Dec 2004 11:33:25 -0600

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.


Relevant Pages

  • Re: Path to Class Library
    ... copy the dll (and all dll's it references) to the bin folder of the ... | I've recently created a web service, which uses code within a class ... | shared code libraray DLL? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Deploy All Dependent Files
    ... To learn why Publish isn't getting all the second-level references would require study of the MSBUILD output, and I doubt I'll have enough time this week. ... Look in the output from the build of your web service project for calls to your VB project and see if you can see a step being skipped, or some other reason why not all of the references are gathered or copied. ... Web Service Application - I understand that references in this project will populate, but I have another project in the same solution, which is a set of VB.Net classes (so another project, another DLL, but in the same solution). ... "John Saunders" wrote in message ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Dynamic web reference in a DLL
    ... I have a class library (DLL) that references a web service. ... John Saunders | MVP - Windows Server System - Connected System Developer ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: ThreadAbortException
    ... COM components want to be called from Single Threading Apartments (which is ... From the Web Service, create a thread obj - the thread will call the COM ... > I am calling a VB Dll from VB.Net Web Service. ... > windows app or windows service. ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Need help sharing a DLL on SAME machine
    ... If the error is "cannot use your dll because it is being ... > a Winodws based app on THE SAME machine. ... > If I test the Web service, the DLL works, but if I try to run the Windows ... > I then restart IIS and run the Windows app, ...
    (microsoft.public.dotnet.framework)