我正在尝试向我的ASP.NET MVC应用程序添加WCF服务。设置完成后,每当我想测试它时都会出错。
这是我的代码:
BackgroundTask.svc
public class BackgroundTask : IBackgroundTask
{
public void ShutdownVm()
{
}
public void UpdateTable()
{
}
}
IBackgroundTask.cs
[ServiceContract]
public interface IBackgroundTask
{
[OperationContract]
void ShutdownVm();
[OperationContract]
void UpdateTable();
}
的Web.config
<system.serviceModel>
<services>
<service behaviorConfiguration="bgtBehaviour" name="IsolutionsAzureManager.Controllers.BackgroundTask">
<endpoint address="BackgroundTask" binding="basicHttpBinding"
bindingConfiguration="" name="" contract="IsolutionsAzureManager.Controllers.IBackgroundTask" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:44304/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="bgtBehaviour">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
因此,每当我想测试我的WFC服务时,我都会收到此错误:
错误:无法从https://localhost:44304/Controllers/BackgroundTask.svc
错误:HTML文档不包含Web服务发现信息。
有人能看到错误吗?
答案 0 :(得分:0)
因为您试图通过Https获取mex端点,所以您还需要切换到mexHttpsBinding并且
启用httpsGetEnabled
设置:
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
或者,通过http(http://localhost:44304/Controllers/BackgroundTask.svc
)获取端点,然后在客户端构建服务引用工件后切换回https。