5

我正在按照书中的教程为 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>
4

2 回答 2

9

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

将此添加到您的 web.config:

<system.serviceModel>
  <services>
    <service name="Service.PushService">
      <endpoint address="" binding="basicHttpsBinding"
                contract="Service.IPushService" />
    </service>
  </services>
</system.serviceModel>
于 2013-03-05T10:09:31.400 回答
0

对于那些在Service.svc中没有实现IService中没有定义它的方法的人会导致同样的异常。

这被遗忘了

[OperationContract]
 string CheckHMAC(string hMac);

但实施

[WebInvoke(Method = "GET", UriTemplate = "/CheckHMAC/{hMac}")]
public string CheckHMAC(string hMac)
{//}
于 2016-12-20T13:20:57.220 回答