Web Services WCF:没有正在侦听的通道

vwoqyblh  于 2022-11-15  发布在  其他
关注(0)|答案(2)|浏览(180)

我在ASP.NET(C#)应用程序中创建了一个WCF rest服务,当我尝试通过Web浏览器在以下本地主机上浏览它时,它似乎**工作正常 *::81/ExternalServices/WS/SPP/REST/SPPService.svc
但是,如果我尝试访问它的某个方法,则会收到以下错误消息:服务器端服务器端服务器端

消息:没有通道正在侦听“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配置

<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>
kzmpq1sx

kzmpq1sx1#

WCF的一个非常有用的特性是帮助页面。它公开了所有可用的服务沿着正确的URI。
它可以位于:http://MachineName/Service.svc/help
在我的情况下,它是:服务器端服务器端
这使我看到Web.config文件沿着IIS在端口82上使用HTTPS绑定。

jk9hmnmh

jk9hmnmh2#

当IIS配置为允许HTTPS连接并且关联的安全证书已过期时,我收到此错误。失败的服务还配置为需要安全“传输”绑定(以支持HTTPS连接)。在Windows应用程序事件日志中发现了这些错误,这些错误反映了向受影响的服务发出请求时出现的HTTP 404错误。在从IIS中删除HTTPS绑定并从失败的服务中删除安全要求后,一切都重新开始工作。

相关问题