Click to See Complete Forum and Search --> : Can I use web service to host my classes?
wild_bill
Sep 11th, 2005, 09:10 AM
My company uses a set of classes for every data access function. The bad part is distributing these dlls with every project that accesses a database. Is there a way to reference these classes in a web service, then have all the applications reference the web service to access the classes?
Here's what I'm trying to do:
Dim WebServ1 as New WebService1
Dim myClass1 as New WebServ1.MyClass1
Dim myClass2 as New WebServ1.MyClass2
Edit: I found this http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT15.asp
Is remoting my only option?
RobDog888
Sep 12th, 2005, 01:57 PM
Moved to ASP.NET. :)
mendhak
Sep 14th, 2005, 05:43 AM
No, it's actually very simple to use a web service for this. The classes you have for your data access and manipulation function can be referenced in your web service project.
But it won't exactly be the way you're trying to do in your post. Instead you'll need to work with functions (called web methods in context of the web services) and work with the values being returned by it. For example, if you wish to return a class that you've created, you'll need to make sure its serializable. Else you can return the basic .NET types such as datasets, strings, integers, etc.
wild_bill
Sep 14th, 2005, 08:11 AM
Thanks for the reply. Is there a simple test to check if a class is serializable?
mendhak
Sep 14th, 2005, 09:46 AM
If it is serializable, it'll have the <Serializable()> attribute in its definition ;)
http://www.c-sharpcorner.com/Code/2003/July/ClassSerialization.asp
wild_bill
Sep 14th, 2005, 03:29 PM
Will I have to add WebMethod tags to every function/sub I wish to use inside the class?
mendhak
Sep 15th, 2005, 09:12 AM
Yes, to every method you want accessible to the outside.
wild_bill
Sep 15th, 2005, 09:31 AM
Here's what I've got so far:
<WebMethod()> _
Public Function GetBusException() As ExceptionBC
Dim exc As New ExceptionBC
End Function
<WebMethod()> _
Public Function GetDalExc() As ExceptionData
Return New ExceptionData
End Function
Dim clsws As wsLCL.Service1
Dim dalExc As wsLCL.ExceptionData = clsws.GetDalExc
Dim busExc As wsLCL.ExceptionBC = clsws.GetBusException
I can view all the public variables and properties, but non of the routines or functions. There are hundreds functions that I wish to access, so adding a web method tag would be a hassle. Is the a way to host an entire class object rather than just the objects inside it?
mendhak
Sep 17th, 2005, 01:44 PM
Uhm... I'm not sure what you're trying to do, but if you want the class returned, you have to make its definition serializable. It'll be any generic method in your web service which returns this class. Does that make more sense now?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.