C# 未找到 WCF 端点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15130879/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WCF endpoint not found
提问by Bv202
I'm following a tutorial in a book to implement push notifications for Windows Phone. This is the markup of the service:
我正在按照书中的教程为 Windows Phone 实现推送通知。这是服务的标记:
<%@ ServiceHost Language="C#" Debug="true" Service="Service.PushService" CodeBehind="PushService.svc.cs" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
As you see, a factory is added, although I don't really understand what it's for. When running the service, I get a "endpoint not found"
error. When I remove the factory from the markup, the error disappears, but I get an empty page.
如您所见,添加了一个工厂,尽管我不太明白它的用途。运行该服务时,出现"endpoint not found"
错误。当我从标记中删除工厂时,错误消失了,但我得到了一个空白页面。
Any idea what could cause this error or how to fix it? If you need more code, please tell me.
知道什么可能导致此错误或如何修复它吗?如果您需要更多代码,请告诉我。
Thanks
谢谢
EDIT: My web.config:
编辑:我的 web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
采纳答案by Aron
You are missing the endpoint configuration in your web.config.
您在 web.config 中缺少端点配置。
Add this to your web.config:
将此添加到您的 web.config:
<system.serviceModel>
<services>
<service name="Service.PushService">
<endpoint address="" binding="basicHttpsBinding"
contract="Service.IPushService" />
</service>
</services>
</system.serviceModel>
回答by ibubi
For those who absently implement the method in Service.svc that its definition is absent in IService causes the same exception.
对于那些没有在 Service.svc 中实现方法的人来说,它的定义在 IService 中不存在会导致相同的异常。
This is forgotten
这个忘记了
[OperationContract]
string CheckHMAC(string hMac);
But implemented
但已执行
[WebInvoke(Method = "GET", UriTemplate = "/CheckHMAC/{hMac}")]
public string CheckHMAC(string hMac)
{//}