找不到配置绑定扩展,绑定存在但服务无法看到它

时间:2014-09-12 08:46:58

标签: c# wcf

我尝试过使用我能找到的所有解决方案,但却无法使其正常运行。我正在尝试将本地计算机连接到连接为https的服务器。我得到的最新错误是: -

找不到配置绑定扩展'system.serviceModel / bindings / WSHttpBinding_IService'。验证此绑定扩展是否已在system.serviceModel / extensions / bindingExtensions中正确注册,并且拼写正确。

当我查看我的web.config时,我可以在绑定部分看到WSHttpBinding_IService。我不知道我做错了什么。我的web.config是: -

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="baseaddress" value="https://Silvertest.Example.com/Silver"/>
  </appSettings>
  <connectionStrings>
    <add name="" connectionString=""/>
  </connectionStrings>
  <system.web>

<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.5">
  <assemblies>
    <add assembly="System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
  </assemblies>
</compilation>
<pages controlRenderingCompatibilityVersion="4.0"/>
<httpRuntime targetFramework ="4.5"  />
</system.web>
<system.serviceModel>
<services>
  <service name="Silver" >
    <endpoint address=""  binding="WSHttpBinding_IService" contract="IService"  />
    <host>
      <baseAddresses>
        <add baseAddress="https://Silvertest.Example.com/Silver/service.svc"/>
      </baseAddresses>
    </host>
  </service >
</services>
<client>
  <endpoint address="https://Silvertest.Example.com/Silver/Service.svc"
    binding="WSHttpBinding" bindingConfiguration="wsHttpBinding"
    contract="IService" name="SecureWCF" />
</client>
<protocolMapping>
  <add scheme="https" binding="WSHttpBinding_IService" bindingConfiguration="SecureWCF" />
</protocolMapping>
<extensions>
  <endpointExtensions>

  </endpointExtensions>
</extensions>
<bindings>
  <wsHttpBinding>
    <binding name="WSHttpBinding_IService" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
      maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
      textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00"
        enabled="false" />
      <security mode="Transport">
        <transport clientCredentialType ="None"/>
      </security>
    </binding>

  </wsHttpBinding>
  <basicHttpBinding>
    <binding closeTimeout="10:01:00" openTimeout="10:01:00" receiveTimeout="00:10:00"
      sendTimeout="10:01:00" allowCookies="false" bypassProxyOnLocal="false"
      hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
      maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
      textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
      messageEncoding="Text">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
        maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="Transport">
        <transport clientCredentialType="None" />
        <message/>
      </security>
    </binding>
    <binding name="BasicHttpBinding_IRemote" />
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled  ="true"/>
      <!-- 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="true"/>
    </behavior>
    <behavior name="SecureWCF">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled  ="true"/>
      <!-- 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="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

1 个答案:

答案 0 :(得分:0)

您的客户端和服务器端点配置对于初学者来说是错误的。试试这个:

<endpoint address="https://Silvertest.Example.com/Silver/Service.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService"
contract="IService" name="SecureWCF" />

您必须为服务器端点元素和客户端端点元素指定bindingbindingConfiguration属性。确保绑定配置元素也匹配(除非您使用SSL卸载,但我假设您没有)。