There are so many examples of building custom web service for SharePoint. Unfortunatelly, the step includes modification of SharePoint built-in file (ISAPI\spdisco.aspx). This kind of modification is dangerous - especially when there is patch release by Microsoft; it will be overriden. Moreover, modifying SharePoint's built-in file leaving SharePoint farm in un-supported state.
This project requires Visual Studio 2010 and SharePoint 2010.
Description
This solution offers different approach that basically avoid modifying spdisco.aspx. In order to do that there are couple things that we do:
Following diagram shows how the solution works:

The key of this solution is HttpHandler process which will intercepts all request to _vti_bin/spdisco.aspx and replacing with the new process. In the new process, the HttpHandler will combine spdisco.aspx and any other *.spdisco.aspx in the ISAPI folder.
public void ProcessRequest(HttpContext context)
{
StringWriter sw1 = new StringWriter();
// Original - cop spdisco.aspx
context.Server.Execute("spdisco.disco.aspx", sw1);
XmlDocument spdiscoXml = new XmlDocument();
spdiscoXml.LoadXml(sw1.ToString());
var files = Directory.GetFiles(context.Server.MapPath(""), "*.spdisco.aspx");
foreach (var file in files)
{
StringWriter sw2 = new StringWriter();
context.Server.Execute(System.IO.Path.GetFileName(file), sw2);
XmlDocument otherSPDiscoXml = new XmlDocument();
otherSPDiscoXml.LoadXml(sw2.ToString());
foreach (XmlNode importedNode in otherSPDiscoXml.DocumentElement.ChildNodes)
{
spdiscoXml.DocumentElement.AppendChild(spdiscoXml.ImportNode(importedNode, true));
}
}
context.Response.Write(String.Format("<?xml version='1.0' encoding='utf-8' ?> {0}", spdiscoXml.InnerXml));
}
public void ProcessRequest(HttpContext context) { StringWriter sw1 = new StringWriter(); // Original - cop spdisco.aspx context.Server.Execute("spdisco.disco.aspx", sw1); XmlDocument spdiscoXml = new XmlDocument(); spdiscoXml.LoadXml(sw1.ToString()); var files = Directory.GetFiles(context.Server.MapPath(""), "*.spdisco.aspx"); foreach (var file in files) { StringWriter sw2 = new StringWriter(); context.Server.Execute(System.IO.Path.GetFileName(file), sw2); XmlDocument otherSPDiscoXml = new XmlDocument(); otherSPDiscoXml.LoadXml(sw2.ToString()); foreach (XmlNode importedNode in otherSPDiscoXml.DocumentElement.ChildNodes) { spdiscoXml.DocumentElement.AppendChild(spdiscoXml.ImportNode(importedNode, true)); } } context.Response.Write(String.Format("<?xml version='1.0' encoding='utf-8' ?> {0}", spdiscoXml.InnerXml)); }
Next important things is to register HttpHandler to the web.config.
<?xml version="1.0" encoding="utf-8" ?>
<actions>
<add path="configuration" id="{24E2107B-6288-4C54-912D-3D5CE7BEEDE0}">
<location path="_vti_bin/spdisco.aspx">
<system.webServer>
<handlers>
<add name="DemoWSHandler" verb="*" path="*_vti_bin/spdisco.aspx" type="DemoWS.HttpHandler, DemoWS , Version=1.0.0.0, Culture=neutral, PublicKeyToken=293c0f6de57e7690" />
</handlers>
</system.webServer>
</location>
</add>
</actions>
<?xml version="1.0" encoding="utf-8" ?> <actions> <add path="configuration" id="{24E2107B-6288-4C54-912D-3D5CE7BEEDE0}"> <location path="_vti_bin/spdisco.aspx"> <system.webServer> <handlers> <add name="DemoWSHandler" verb="*" path="*_vti_bin/spdisco.aspx" type="DemoWS.HttpHandler, DemoWS , Version=1.0.0.0, Culture=neutral, PublicKeyToken=293c0f6de57e7690" /> </handlers> </system.webServer> </location> </add> </actions>
1. Writing Custom Web Services for SharePoint Products and Technology (http://msdn.microsoft.com/en-us/library/dd583131(v=office.11).aspx)
2. SharePoint Architecture (http://msdn.microsoft.com/en-us/library/bb892189(v=office.12).aspx )
3. Architectural Overview of Windows SharePoint Services (http://msdn.microsoft.com/en-us/library/dd583133(v=office.11).aspx)
4. Modifying Built-In SharePoint Files (http://msdn.microsoft.com/en-us/library/bb803457(v=office.12).aspx)
5. My blog - Ideas for Free (http://blog.libinuko.com)