Click here to Skip to main content
15,886,037 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi Everyone,

How can I inherit an abstract class written in a web service class by a class within a project that referenced that web service?

EG:

Web Service Class
C#
[WebService(Namespace = "...")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class AppService : System.Web.Services.WebService
{
    public abstract class InheritMe<T>
    {
        ...
    }
}



Local Class
C#
class ConcreteClass : WebService.AppService.InheritMe<int>
{
    ...
}



Please, I really need help.
Thanks in advance..
Posted
Updated 8-Nov-11 14:48pm
v5
Comments
Jephunneh Malazarte 8-Nov-11 3:41am    
Interesting question... I don't have the answer for now :)
I am hoping to have an idea why need to inherit the class from webservice.
unknowndentified10111 8-Nov-11 3:43am    
Thanks for the reply. I have a generic data access class that can only be inherited. That's why I need an abstract class, but if it is a concrete class, how can I access it?
[no name] 8-Nov-11 3:53am    
But why you need to inherit abstract class from web service? Don't you afford to make the same abstract class in the application where you are using your web service...
unknowndentified10111 8-Nov-11 4:01am    
The abstract generic data access class has methods that connects to the database within the same server as the web service. It can also be done by making the data access class concrete and instantiate it in the local concrete class and create methods for each method of that data access class, I just want to inherit it so that it would be easier, but if there has no other option, how can I access a concrete class written inside a web service class?
Jephunneh Malazarte 8-Nov-11 4:42am    
oh so the reason why you need that is to call the method defined in your webservice? is that correct? coz i have a solution if that's the case.

http://forums.asp.net/t/1509177.aspx/1[^]

I am sure this will help you.Enjoy
 
Share this answer
 
Comments
unknowndentified10111 8-Nov-11 4:46am    
Thanks for the answer but my question is how to inherit an abstract class from a web service class, not from a class to the web service class, to the class within the project that referenced that web service. Your reply is highly appreciated though.

What's the problem?


If your abstract class is declared as the following:


C#
namespace MyWebServiceNamespace
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class AppService : System.Web.Services.WebService
    {
        // ...

        public abstract class InheritMe<T>
        {
            // ...
        }

        // ...
    }
}

you can inherit it as the following:


C#
public class MyClass : MyWebServiceNamespace.AppService.InheritMe<int>
{
}

Because your class is declared in a WebService you also have to add a reference to System.Web.Services, in the project that contains the class that inherits your abstract class.

 
Share this answer
 
Comments
unknowndentified10111 8-Nov-11 20:16pm    
That would only work if the class that inherit the web service class is in the same project as the web service or it referenced the project of that web service. What I have was the class that needs to inherit the web service class is in a project that web referenced that web service.
Shmuel Zang 9-Nov-11 10:46am    
Why do you want to do something like that? What is the problem with declaring the abstract class, in a separate project and, reference this project from the WebService's project and from the other project that inherits the abstract class?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900