locked
netTcpBindings question RRS feed

  • Question

  • User-1993844047 posted
    <?xml version="1.0"?>
    <configuration>
      <system.serviceModel>
        <bindings>
          <netTcpBinding>
            <binding name="netTcp">
              <reliableSession enabled="true"/>
            </binding>        
          </netTcpBinding>      
        </bindings>
        <services>       
          <service name="Service1">         
            <endpoint address="" binding="basicHttpBinding" contract="_1_00.IGetApprovals"/>
            <endpoint address="mex" contract="_1_00.IGetApprovals" binding="mexHttpBinding"/>         
            <endpoint address="rest" binding="webHttpBinding" behaviorConfiguration="restfulBehavior" contract="_1_00.IGetApprovals"/>       
           
            <endpoint address="" binding="netTcpBinding" bindingConfiguration="netTcp" contract="_1_00.IEmpService"/>
            <endpoint address="mex" contract="_1_00.IEmpService" binding="netTcpBinding" bindingConfiguration="netTcp"/>         
            <endpoint address="rest" binding="netTcpBinding" bindingConfiguration="netTcp" contract="_1_00.IEmpService"/>                     
          </service>              
        </services>
        
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, set the value below to false 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>
          <endpointBehaviors>
            <behavior name="restfulBehavior">
              <webHttp automaticFormatSelectionEnabled="true"/>
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <directoryBrowse enabled="true"/>
      </system.webServer>  
       
      
      <connectionStrings>
        <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Initial Catalog=aspnetdb;Integrated Security=True" providerName="System.Data.SqlClient" />
        <add name="RCS_2_02ConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=RCS_2_02;Integrated Security=True" providerName="System.Data.SqlClient" />
      </connectionStrings>
      
      <system.web>
        <roleManager enabled="true" />
        <membership>
          <providers>
            <clear />
            <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
          </providers>
        </membership>
    
        <profile>
          <providers>
            <clear />
            <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
          </providers>
        </profile>
     
        <authentication mode="Forms" />
        <compilation debug="true" />
      </system.web> 
      
    </configuration>

    I want to use netTcpBindings since I communicate with the clients using sessions.

    However, when I add 2 additional endpoints with netTcpBindings, the IEmpService cannot get to work.

    Contract requires Session, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it.

    Thanks

    Jack

    Friday, March 13, 2015 3:29 AM

Answers

All replies

  • User-1993844047 posted
    <configuration>
      <system.serviceModel>
        <bindings>              
          <netTcpBinding>
            <binding name="netTcp">
              <reliableSession enabled="true"/>
            </binding>        
          </netTcpBinding>      
        </bindings>
        <services>
          <!--<service behaviorConfiguration ="_1_00.IFollowuppersonServiceBehaviour" name="Service1">-->
            <service name="Service1">
            <!-- these endpoint are necessary to return SOAP service -->
            <endpoint address="" binding="basicHttpBinding" contract="_1_00.IGetApprovals"/>
            <endpoint address="mex" contract="_1_00.IGetApprovals" binding="mexHttpBinding"/>
            <!--To call this endpoint use: [service].svc/rest/[method_Name]-->
            <endpoint address="rest" binding="webHttpBinding" behaviorConfiguration="restfulBehavior" contract="_1_00.IGetApprovals"/>
    
          </service>
    
          
          <service 
           name="_1_00.IEmpService">
            <endpoint address=""
                      binding="netTcpBinding"
                      bindingConfiguration=""
                      name="NetTcpBindingEndpoint"
                      contract="_1_00.IEmpService">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
    
            <endpoint address="mex"
                      binding="mexHttpBinding"
                      contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="net.tcp://localhost:8523/RCS_Approvals/EmployeeService" />
              </baseAddresses>
            </host>
          </service>
          
          
          
          <!--<service name=""> 
            <endpoint address="" binding="NetTcpBinding"  contract="_1_00.IEmpService"/>
            <endpoint address="mex" contract="_1_00.IEmpService" binding="NetTcpBinding" />         
            <endpoint address="rest" binding="NetTcpBinding" contract="_1_00.IEmpService"/>                     
          </service>              -->
          
        </services>
        
        <behaviors>

    I didn't know why _1_00.IEmpService still uses basicHttpBinding, are there any reasons why?

    Could anyone please shed some lights on this?

    Thanks

    Jack

    Friday, March 13, 2015 8:46 AM
  • User475983607 posted

    You have two services to choose from.  The client must explicitly select the service (by name) otherwise the client defaults to the first service in the list.   Which in your case is the Basic binding.

    Friday, March 13, 2015 9:22 AM
  • User-1993844047 posted

    The wcf test client can't accept both services at the same time?

    I test it out, and fnd out the first service is good.

    But the later service is accepting basicHttpbinding from wcf test client....

    How can I separate these services out to use different bindings?

    Or Do I use 2 different service models anyways?

    Update:

    I strongly believe the settings have something wrong in the "behaviors" section.

    One strange thing is when I comment out both of the services,

    The results are the same. But I confirm I got just one web.config in my project!

    Thanks

    Jack

    Friday, March 13, 2015 9:28 AM
  • User503812343 posted

    check your service is name is aligned to your service contracts

    check below article which shows how to use multiple bindings in one wcf service

    http://dotnetmentors.com/multiple-wcf-services-in-one-solution-with-multiple-endpoints-and-hosting.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, March 20, 2015 3:12 AM