C# – Increment through a list of webservices in a directory and list available Webmethods


I have a number of different webservices in the C# web application I'm building and would like to create a quick documentation page which lists all of the webservices and the available web methods in each. Rather than having to keep the documentation page up-to-date whenever I change/add a webmethod it would be good if the documentation was dynamic.

For each webmethod I'd like to get the Description attribute from the Webmethod deceleration and (if possible) the list of parameters for each method.

I know I can get a lot of this info from the web service summary page that .NET serves for a .asmx page but I don't want to force the user to have to keep clicking away from the main documentation page.

Thanks in advance.

Best Solution

A quick solution would be to write a custom Http Handler:

public class InformationHandler : IHttpHandler
    public void ProcessRequest(HttpContext context)
        // Select the assembly that contains the web service classes
        var assemblyThatContainsTheWebService = Assembly.GetExecutingAssembly();

        // Select all types in this assembly deriving from WebService
        var webServiceTypes = 
            from type in assemblyThatContainsTheWebService.GetTypes()
            where type.BaseType == typeof(WebService)
            select type;

        context.Response.ContentType = "text/plain";

        foreach (var type in webServiceTypes)
            context.Response.Write(string.Format("Methods for web service {0}:{1}", type, Environment.NewLine));
            // Select all methods marked with the WebMethodAttribute
            var methods = 
                from method in type.GetMethods()
                where method.GetCustomAttributes(typeof(WebMethodAttribute), false).Count() > 0
                select method;

            foreach (var method in methods)


    public bool IsReusable
            return false;