找不到WCF端点

时间:2013-02-28 08:33:32

标签: c# wcf windows-phone-7

我正在按照书中的教程来实现Windows Phone的推送通知。这是该服务的标记:

<%@ ServiceHost Language="C#" Debug="true" Service="Service.PushService" CodeBehind="PushService.svc.cs" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>

如您所见,工厂已添加,但我并不了解它的用途。运行该服务时,出现"endpoint not found"错误。当我从标记中删除工厂时,错误消失,但我得到一个空页。

知道什么可能导致此错误或如何解决它?如果您需要更多代码,请告诉我。

由于

编辑: 我的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>

2 个答案:

答案 0 :(得分:8)

您缺少web.config中的端点配置。

将此添加到您的web.config:

<system.serviceModel>
  <services>
    <service name="Service.PushService">
      <endpoint address="" binding="basicHttpsBinding"
                contract="Service.IPushService" />
    </service>
  </services>
</system.serviceModel>

答案 1 :(得分:0)

对于那些在Service.svc中缺席实现该方法的人来说,IService中缺少其定义会导致相同的异常。

这是被遗忘的

[OperationContract]
 string CheckHMAC(string hMac);

但已实施

[WebInvoke(Method = "GET", UriTemplate = "/CheckHMAC/{hMac}")]
public string CheckHMAC(string hMac)
{//}