[英]WCF: There was no channel actively listening
I created a WCF rest service in my ASP.NET (C#) application, and it seems to be working fine when I try to browse to it via web browser at the following localhost:81/ExternalServices/WS/SPP/REST/SPPService.svc 我在我的ASP.NET(C#)应用程序中创建了一个WCF休息服务,当我尝试通过以下localhost的Web浏览器浏览它时,它似乎正常工作 :81 / ExternalServices / WS / SPP / REST / SPPService。 SVC
However, if I try to hit one of its methods, I get the below error message: localhost:81/ExternalServices/WS/SPP/REST/SPPService.svc/GetDetails 但是,如果我尝试使用其中一个方法,我会收到以下错误消息:localhost:81 / ExternalServices / WS / SPP / REST / SPPService.svc / GetDetails
Message : There was no channel actively listening at ' http://MachineName.abc.local:81/ExternalServices/WS/SPP/REST/SPPService.svc/GetDetails '. 消息 :没有频道主动收听' http://MachineName.abc.local:81 / ExternalServices / WS / SPP / REST / SPPService.svc / GetDetails '。 This is often caused by an incorrect address URI.
这通常是由错误的地址URI引起的。 Ensure that the address to which the message is sent matches an address on which a service is listening.
确保将消息发送到的地址与服务正在侦听的地址匹配。
Contract : 合同 :
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();
}
}
Implementation : 实施 :
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";
}
}
}
The .SVC File (SPPService.svc) .SVC文件(SPPService.svc)
<%@ ServiceHost Service = "ABC.WebApp.ExternalServices.WS.SPP.REST.SPPService" Language="C#" %>
Web.Config 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>
A very helpful feature of WCF is the help page. WCF的一个非常有用的功能是帮助页面。 It exposes all available services along with the correct URIs.
它公开了所有可用的服务以及正确的URI。
It can be located at: http://MachineName/Service.svc/help . 它位于: http://MachineName/Service.svc/help 。
In my situation, it was: localhost:81/ExternalServices/WS/SPP/REST/SPPService.svc/help 在我的情况下,它是:localhost:81 / ExternalServices / WS / SPP / REST / SPPService.svc / help
This led me to see that the Web.Config file along with IIS were using HTTPS binding on port 82. 这让我看到Web.Config文件和IIS在端口82上使用HTTPS绑定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.