2013-02-28 85 views
4

我正在按照書中的教程來實現Windows Phone的推送通知。這是服務的標記:未找到WCF端點

<%@ 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> 
+0

請發表您的config文件 – Jocke 2013-02-28 09:15:36

+0

閱讀本http://msdn.microsoft.com/en-us/library/aa702697.aspx – Jocke 2013-02-28 09:18:07

+0

我已經添加了.config文件,謝謝.. – Bv202 2013-02-28 09:20:46

回答

8

你缺少你的web.config中的端點配置。

添加到您的web.config:

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

basicHttpsBinding或WebHttpBinding? – EdmundYeung99 2013-03-07 01:43:43

+0

應該與此行相同 Aron 2013-03-07 02:03:02

0

對於那些誰心不在焉地實現該方法在Service.svc,其定義是IService缺席導致相同的異常。

這是被遺忘的

[OperationContract] 
string CheckHMAC(string hMac); 

但實施

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