簡體   English   中英

WCF:沒有頻道主動收聽

[英]WCF: There was no channel actively listening

我在我的ASP.NET(C#)應用程序中創建了一個WCF休息服務,當我嘗試通過以下localhost的Web瀏覽器瀏覽它時,它似乎正常工作 :81 / ExternalServices / WS / SPP / REST / SPPService。 SVC

但是,如果我嘗試使用其中一個方法,我會收到以下錯誤消息:localhost:81 / ExternalServices / WS / SPP / REST / SPPService.svc / GetDetails

消息 :沒有頻道主動收聽' http://MachineName.abc.local:81 / ExternalServices / WS / SPP / REST / SPPService.svc / GetDetails '。 這通常是由錯誤的地址URI引起的。 確保將消息發送到的地址與服務正在偵聽的地址匹配。

合同

namespace ABC.WebApp.ExternalServices.WS.SPP.REST
{
    [ServiceContract]
    public interface ISPPService
    {
        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "GetProductionDetail")]
        string GetProductionDetail(Stream data);

        [OperationContract]
        [WebGet]
        string GetDetails();
    }
}

實施

namespace ABC.WebApp.ExternalServices.WS.SPP.REST
{
    [AspNetCompatibilityRequirements(RequirementsMode =  AspNetCompatibilityRequirementsMode.Allowed)]
    public class SPPService : ISPPService
    {
        public string GetProductionDetail(Stream xmlRequest)
        {
            return "hello";
        }

        public string GetDetails()
        {
            return "hello2";
        }
    }
}

.SVC文件(SPPService.svc)

<%@ ServiceHost Service = "ABC.WebApp.ExternalServices.WS.SPP.REST.SPPService" Language="C#" %>

Web.Config中

<system.serviceModel>
<services>
  <service name="ABC.WebApp.ExternalServices.WS.Disb.Rest.DisbService" behaviorConfiguration="defaultBehaviour">
    <endpoint name="webHttpsBinding" address="" binding="webHttpBinding" contract="ABC.WebApp.ExternalServices.WS.Disb.Rest.IDisbService"
       behaviorConfiguration="webHttp" bindingConfiguration="webHttpTransportSecurity">
    </endpoint>
    <endpoint name="mexHttpsBinding" address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"></endpoint>
  </service>
  <service name="ABC.WebApp.ExternalServices.WS.SPP.REST.SPPService" behaviorConfiguration="defaultBehaviour">
    <endpoint name="webHttpsBinding" address="" binding="webHttpBinding" contract="ABC.WebApp.ExternalServices.WS.SPP.REST.ISPPService"
       behaviorConfiguration="webHttp" bindingConfiguration="webHttpTransportSecurity">
    </endpoint>
    <endpoint name="mexHttpsBinding" address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"></endpoint>
  </service>      
</services>
<bindings>
  <webHttpBinding>
    <binding name="webHttpTransportSecurity">
      <security mode="Transport"></security>
    </binding>
  </webHttpBinding>
</bindings>
<behaviors>
  <endpointBehaviors>
    <behavior name="webHttp">
      <webHttp helpEnabled="true" />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="defaultBehaviour">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"></serviceHostingEnvironment>

WCF的一個非常有用的功能是幫助頁面。 它公開了所有可用的服務以及正確的URI。

它位於: http://MachineName/Service.svc/help

在我的情況下,它是:localhost:81 / ExternalServices / WS / SPP / REST / SPPService.svc / help

這讓我看到Web.Config文件和IIS在端口82上使用HTTPS綁定。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM