简体   繁体   中英

Contract requires Session, but Binding ‘WSHttpBinding’ doesn’t support it or isn’t configured properly to support it

I have specified the service contract to require the session.

[ServiceContract(SessionMode = SessionMode.Required)] 
public interface ITicketSales
{
}

The service decorated like this:

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Single)]
public class TicketSalesService : ITicketSales
{
}

Here is my App.config file:

<system.serviceModel>    
<services>     
  <service name="InternetRailwayTicketSales.TicketSalesImplementations.TicketSalesService" behaviorConfiguration="defaultBehavior">

    <host>
      <baseAddresses>
        <add baseAddress = "https://localhost/TicketSales/"></add>
      </baseAddresses>
    </host>

    <endpoint address="MainService" binding="wsHttpBinding" bindingConfiguration="wsSecureConfiguration"
      contract="InternetRailwayTicketSales.TicketSalesInterface.ITicketSales" />
    <endpoint address="mex" binding="mexHttpsBinding"
      contract="IMetadataExchange"/>
  </service>
</services>

<bindings>
  <wsHttpBinding>
    <binding name="wsSecureConfiguration">
      <security mode="Transport">
        <transport clientCredentialType="None"></transport>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

<behaviors>
  <serviceBehaviors>
    <behavior name="defaultBehavior">
      <serviceThrottling maxConcurrentInstances="5000" maxConcurrentSessions="5000"/>
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="True" />
    </behavior>
  </serviceBehaviors>
</behaviors>

When I press F5 I receive the error message "Contract requires Session, but Binding 'WSHttpBinding' doesn't support it or isn't configured properly to support it."

I really need the channel which supports SSL and requires session.

You can support sessions by enabling message security:

<binding name="wsHttpSecureSession">
<security>
<message establishSecurityContext="true"/>
</security>
</binding>

If you need to go with transport security you may need to specify a client credential type

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM