system.serviceModel/bindings/wsHttpBinding上的绑定没有..错误

本文关键字:绑定 错误 serviceModel bindings wsHttpBinding system | 更新日期: 2023-09-27 18:28:58

我正在尝试在我的WCF基于web的服务中包括两个端点-wsHttp和netTcp。如下面的Web.config所示,我已经添加了它们,但当我编译并在web浏览器中单击Service.svc时,收到了以下错误:

错误页面:

Server Error in '/MyService' Application. Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The binding at system.serviceModel/bindings/wsHttpBinding does not have a configured binding named 'wsHttpBinding'. This is an invalid value for bindingConfiguration.
Source Error:
Line 16: </baseAddresses> Line 17:         </host>  Line 18:  <endpoint address="http://localhost:8090/Services/MyService" Line 19:                   binding="wsHttpBinding" Line 20:                 bindingConfiguration="wsHttpBinding"

Source File: C:'MyService'web.config    Line: 18
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

Web.config:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="false" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <protocolMapping>
      <add scheme="http" binding="wsHttpBinding"/>
    </protocolMapping>
    <services>
      <service
        name="Microsoft.ServiceModel.Samples.MyService">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:9001/"/>
          </baseAddresses>
        </host>
        <endpoint address="http://localhost:8090/Services/MyService"
                  binding="wsHttpBinding"
                  bindingConfiguration="wsHttpBinding"
                  name="MyService_WsHttp"
                  contract="Microsoft.ServiceModel.Samples.IService" />
        <endpoint address="net.tcp://localhost:9000/Services/MyService"
                  binding="netTcpBinding"
                  bindingConfiguration="tcpBinding"
                  name="MyService_Tcp"
                  contract="Microsoft.ServiceModel.Samples.IService" />    
      </service>
    </services>
    <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"/>
          <!-- 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="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

system.serviceModel/bindings/wsHttpBinding上的绑定没有..错误

去掉这个:

          bindingConfiguration="wsHttpBinding"

从这里:

address="http://localhost:8090/Services/MyService" 
                  binding="wsHttpBinding" 
                  bindingConfiguration="wsHttpBinding" 

我认为你没有正确回答这个问题,我确信他想实现绑定配置,因此不删除bindingConfiguration="wsHttpBinding,只需确保和点中的绑定与配置文件中的绑定匹配即可。希望这将工作

例如:

<bindings>
      <netTcpBinding>
        <!--Configure the Service operation instance object timeout of an endpoint -->
        <binding name="netTCP" receiveTimeout="00:00:10" />
      </netTcpBinding>
    </bindings>
<endpoint address="PerSessionService" binding="netTcpBinding" contract="InstanceContext_PerSessionService.IPerSessionService" bindingConfiguration="netTCP">