2
我目前在WPF应用程序中托管几个Web服务。我也启用了自动帮助页面来简化服务文档。每个OperationContract
都装有一个Description
属性,其中包含有关该方法的信息。缺少基于任务的WCF服务的帮助描述
但是,无论何时我查看我的帮助页面,我都会意识到只有返回类型为void
的方法才能在此处正确显示其Description
属性。返回的方法Task
或Task<t>
只会说“Service at localhost:XXXXX/ServiceEndpoint”。
由于此模式用于IPC,因此我非常依赖异步操作合同,因此其中大多数将返回Task
或Task<t>
。有没有办法解决这个问题,以便帮助正确显示?
namespace App
{
[ServiceContract]
public interface IMainService
{
[OperationContract]
[WebGet(UriTemplate = "visibility")]
[Description("Gets the main window visibility.")]
Task<bool> GetVisibilityAsync();
[OperationContract]
[WebInvoke(UriTemplate = "visibility", Method = "PUT")]
[Description("Sets the main window visibility.")]
Task SetVisibilityAsync(bool isVisible);
[OperationContract]
[WebInvoke(UriTemplate = "menu", Method = "PUT")]
[Description("Navigates to the main menu.")]
void NavigateToMainMenu();
[OperationContract]
[WebInvoke(UriTemplate = "shutdown", Method = "PUT")]
[Description("Requests the application to shutdown.")]
void RequestApplicationShutdown();
}
}
这里是我的app.config
<system.web>
<compilation debug="false" targetFramework="4.5" />
</system.web>
<system.serviceModel>
<services>
<service name="App.MainService" behaviorConfiguration="rpcServiceBehavior">
<endpoint binding="webHttpBinding"
contract="App.IMainService"
behaviorConfiguration="webHttpBehavior"
name="RpcEndpoint"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:25565/main"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="rpcServiceBehavior" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>