Ask a Question related to ASP.NET Web Services, Design and Development.
-
Jeff Cooper #1
Inheritence and Web Services
Hi Folks,
Sorry, this is kinda long, but I couldn't find an answer anywhere... Any
ideas would be appreciated.
I have several web services (several asmx files) in a project. They all are
variations of some basic functionality, but each with different functions.
However, there are a few functions that are common to all.
So, I created a service called myMainService and put the common functions
into it:
<System.Web.Services.WebService(Namespace:="http ://tempuri.org/VHFDBQS/myMai
nService")> _
Public Class myMainService
Inherits System.Web.Services.WebService
... functions here ...
End Class
Now, I create another webservice and declare is as follows:
<System.Web.Services.WebService(Namespace :=
"http://tempuri.org/VHFDBQS/myDerivedService")> _
Public Class myDerivedService
Inherits myMainService
... some functions specific to this class ...
End Class
.... more services are also created, each in its own asmx file ---
myOtherDerivedService, YetAnotherDerivedService, etc, all with "Inherits
myMainService"...
In my aspnet application, I would like to pass a reference to any of the the
derived classes to a function. I have a function in the app that accepts a
paramter of myMainService.myMainService:
Private Function SetupMyService(ByVal Svc As myMainService.myMainService)
Svc.Credentials = Net.CredentialCache.DefaultCredentials
If Svc.CookieContainer Is Nothing Then
Svc.CookieContainer = New System.Net.CookieContainer
End If
'SetConnectionString is a function in the base class myMainService
Svc.SetConnectionString(HttpContext.Current.Sessio n("ConnectionString"))
End Function
Since I'm declaring this function as accepting myMainService, my aspnet
project has a web reference to myMainService along with web references to
each of the derived services. This way, the function knows what
myMainService is.
My thinking is, I can set the object passed in Svc = myDerivedService or
myOtherDerivedService or whatever. Example
Dim Obj as new myDerivedService.myDerivedService
SetupMyService(Obj)
I also tried this:
Dim Obj as myMainService.myMainService = myDerivedService.myDerivedService
SetupMyService(Obj)
Neither works. I'm told: "Value of type
'ServicesProject.myDerivedService.myDerivedService cannot be converted to
'ServicesProject.myMainService.myMainService."
Why would this be? If I create a regular class in an application, derive
another class from it, I can pass an object referencing the derived class to
a function declared to accept the baseclass. Why can't the same be done with
Web Services?
Is there some strange rule about inheriting from other web services and can
anyone suggest a fix or workaround?
Thanks,
Jeff
Jeff Cooper Guest
-
Web Services help please
I need to publish a CFMX web service that return data in XML format like the code below. Can anyone please show me sample code how I would do this?... -
services??
On our win 2003 server we are sometimes having a very heavy load in the 30 - 60 % area. The top memory consumer seems to be "services.exe". Can... -
Inheritence
Hi everyone, How can I extend (inherit) multiple classes ??? like eg: class A extends C,D {} -
Inheritence Diagram of Ruby classes...
Hello All, Has anyone got, or know of a diagram that shows how the ruby classes are ordered in terms of inheritence? Thanks, Thomas Adam ... -
Networking Services - services.msc
Hi, I'd like to know which services are responsible for home networking. i.e. which services do I need to be running for others to have access...



Reply With Quote

