wcf - WCF :No protocol binding matches the given address 中的运行时错误

标签 wcf

当我使用以下配置运行 WCF 服务时,我想从我的 VS2010 运行 WCF 服务。

<system.serviceModel>
<services>
  <service name="WcfSample.Service1" behaviorConfiguration="servicebehaviour1">
    <endpoint  address ="http://localhost:8080/service1/Service1.svc" contract="WcfSample.IService1" binding="wsHttpBinding"></endpoint>
    <endpoint address="" binding="mexHttpBinding" contract ="IMetadataExchange"></endpoint>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="servicebehaviour1">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="false"/>
      <!-- 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>
<!--<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />-->

我收到如下异常

No protocol binding matches the given address 'http://localhost:8080/service1/Service1.svc'. Protocol bindings are configured at the Site level in IIS or WAS configuration.



如果我想在我给定的地址运行我的 WCF,我应该这样做。

最佳答案

WCF 服务的托管不采用您在配置文件的端点中定义的地址

<endpoint 
      address="http://localhost:8080/service1/Service1.svce"

所以你定义的上面一个是不正确的,而不是你需要做的如下

您的服务地址是 Web 服务器和虚拟目录加上 SVC 文件名,如下所示
http://servername/vrirualdirectoryname/svcfiename.svc/

您可以定义如下相对地址:
<service name="WcfSample.Service1">
   <endpoint name="" 
             address="ServiceAddress" 
             binding="wsHttpBinding"   
             contract="WcfSample.IService1" />
</service>

所以最后你消费服务的服务地址是
http://servername/vrirualdirectoryname/svcfiename.svc/ServiceAddress

所以像这样你可以做而不是直接指定地址。

注意:

上面的代码表明服务将托管在 IIS 服务器上。

关于wcf - WCF :No protocol binding matches the given address 中的运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14291715/

相关文章:

c# - JQuery 按钮未通过 ajax 触发服务调用

.net - WCF 最佳实践的引用项目

asp.net - N层和SOA架构有什么区别

c# - 在消息检查器中获取操作名称?

.net - WCF:我应该如何维护客户端和服务器中的契约(Contract)类?

c# - 带有 POCO + WCF + WPF 的 EF。在客户端重用 POCO 类还是使用 DTO?

c# - ExceptionShielding 有更好的替代品吗?

c# - WCF 能否处理对同一终结点的同时调用?

WCF Rest 服务客户端 - 参数名称区分大小写

wcf - TCP/IP 无法建立传出连接