2011-06-17 200 views
11

我希望我的摘要,參數信息,返回信息等(列在下面)顯示在.net爲.asmx Web服務生成的標準幫助頁面上。.asmx Web服務文檔

/// <summary> 
/// Brief description 
/// </summary> 
/// <param name="fakeParamOne">Fake Param One Description</param> 
/// <returns>Bool representing foo</returns> 

,我已經試過了影響以任何方式自動生成的幫助頁面的唯一的事情是這樣的:

[WebMethod(Description = "Does awesome things.")] 

我敢肯定,我失去了一些東西很簡單(或它的不可能做我想做的事)。有什麼建議麼?

+0

有沒有自動的方式做你的要求。事實上,WCF中的幫助頁面已被放棄,因爲它的實用性非常有限。 –

+1

「WCF中的幫助頁面已被放棄,因爲它的功用非常有限」?請您再說一遍???你在開玩笑我! – Jenda

回答

22

就像@John Saunders評論中提到的那樣,沒有一種真正的自動方式來使用XML方法註釋來顯示在WSDL幫助中,但是有幾種替代方法可以獲得您想要的內容。

的WebMethod Description屬性可以被設置爲HTML格式

下面是一個例子:

const string someWebMethodDescription = @" 
<table> 
    <tr> 
     <td>Summary:</td><td>[My Summary]</td> 
    </tr> 
    <tr> 
     <td>Parameters:</td><td>&nbsp;</td> 
    </tr> 
    <tr> 
     <td>fakeParam:</td><td>[My Fake Param Description]</td> 
    </tr> 
</table>"; 

[WebMethod(Description=someWebMethodDescription)] 
public List<string> SomeWebMethod 

其結果爲:

Web Method with Custom HTML Description

或者,創建自定義WSDL幫助頁面

<configuration> 
    <system.web> 
     <webServices> 
     <wsdlHelpGenerator href="docs/HelpPage.aspx"/> 
     </webServices> 
    </system.web> 
</configuration> 

檢查這個CodeProject上的職位的詳細信息,使自己的HelpPage:

Improving the ASP.NET Webservice Help Generator to Reflect Inheritance - CodeProject