[英]Adding WCF service reference in ASP.NET MVC app fails
我正在嘗試將WCF服務添加到我的ASP.NET MVC應用程序中。 設置好之后,每當要測試時都會收到錯誤消息。
這是我的代碼:
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服務發現信息。
誰能看到錯誤?
因為您嘗試通過Https獲取mex端點,所以還需要切換到mexHttpsBinding並啟用httpsGetEnabled
設置:
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
另外,也可以通過http( http://localhost:44304/Controllers/BackgroundTask.svc
)獲取端點,然后在客戶端構建了服務引用工件后,立即切換回https。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.