![](/img/trans.png)
[英]Getting EndpointNotFoundException: There was no channel actively listening in 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.