gpt4 book ai didi

wcf - 合约需要 Session,但 Binding ‘WSHttpBinding’ 不支持它或未正确配置以支持它

转载 作者:太空宇宙 更新时间:2023-11-03 13:08:33 25 4
gpt4 key购买 nike

我已指定需要 session 的服务契约(Contract)。

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

服务装饰成这样:

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

这是我的 App.config 文件:

<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>

当我按 F5 时,我收到错误消息“契约(Contract)需要 session ,但绑定(bind)‘WSHttpBinding’不支持它或未正确配置以支持它。”

我真的需要支持 SSL 并需要 session 的 channel 。

最佳答案

您可以通过启用消息安全来支持 session :

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

如果您需要传输安全,您可能需要指定客户端凭证类型

关于wcf - 合约需要 Session,但 Binding ‘WSHttpBinding’ 不支持它或未正确配置以支持它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7915141/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com