|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionVisual Studio .NET provides us with a simple mechanism for adding documentation to Web Services through the use of attributes. The There are a few limitations to documenting your Web Services in this way. Firstly, it becomes unwieldy when you need to provide any level of detail. For example, adding a table of parameters and values would mean lines of concatenated strings containing hard-to-read escaped HTML. Secondly, this approach doesn't lend itself well to having translators, technical writers, and editors working on the documentation as they need access to the code. Thirdly, the page has a fixed style that might not fit in with your corporate image. This article tackles the above problems by moving the documentation and stylesheet out of the implementation and into standalone files. BackgroundBy default, the documentation for all Web Services is generated by a page named DefaultWsdlHelpGenerator.aspx located in the .NET Framework configuration directory (usually named C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFIG). When DefaultWsdlHelpGenerator.aspx loads, its Each item within the Each The proposed solutionMicrosoft provides us with a way to override the default documentation generation on a per-machine or per-application basis. The key lies in editing web.config as follows, where MyServiceDescriptionGenerator.aspx is the name of the page you want to use for documentation. <?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<webServices>
<wsdlHelpGenerator href="MyServiceDescriptionGenerator.aspx"/>
</webServices>
</system.web>
</configuration>
Modifying web.config to use a different aspx file is simple enough, but things are complicated by the fact that this file is also responsible for generating example code for use with the SOAP and HTTP protocols. As a result, we can't simply replace the file with the HTML required to document web service as we'd no longer have a mechanism to provide examples to our Web Service consumers. This solution takes a copy of the existing DefaultWsdlHelpGenerator.aspx and makes the changes required to externalize the documentation and style sheet. The changes are intended to be as unobtrusive as possible so newer versions of DefaultWsdlHelpGenerator.aspx can be brought on board more easily. The changes are summarized as follows:
The bulk of the new code lives within Using the codeTo use the new documentation generator in your code, do the following:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||