Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

I am having trouble with inheriting from another web service.

Could anyone please be so kind to explain to me how to do it.

What i want to achieve is to inherit in my web service from another web service and be able to see methods of that web service when i view it in a browser.

For example.

I have web service a at htpp://localhost/example1/a.asmx. Next i want to create web service b and use web service a as a base class and be able to override and use its methods.

Thanks for the help.

Kind Regards

Terence
Posted

In the codebehind of b.asmx, amend the class declaration to look something like this:

C#
public class b : a
{
//overrides etc. here
}
 
Share this answer
 
If you don't own the code for the web service you want to inherit from, then create a proxy class from the web service WSDL

* Open visual studio command prompt
* WSDL[^] /out:C:\myProxyClass.cs http://localhost/example1/a.asmx?WSDL

That will generate a proxy class with all the web service methods that are in the service a.asmx

Include the file generated at C:\myProxyClass.cs in the project where you want to override it.

Now inherit a class as stated by Jim

C#
public class MyDerivedClass : ProxyClass 
{   
}


For methods that you want to override, you'll need to go into the source code of the proxy class and mark the methods as virtual
 
Share this answer
 
Comments
SwitcherSoft 11-Apr-11 7:37am    
Thank you for the answer, this is the way i did it. When i run the web service from a browser. The base class methods i am not able to see. When you override it with WebMethod(true) then it shows up. Thanks for taking the time anyway.

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