我已经使用wsHTTPBinding配置了WCF服务,但即使这样我也收到错误
Contract requires Session, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it.
这是服务合同定义
<ServiceContract(SessionMode:=SessionMode.Required)>
Public Interface IPrivateService
这是服务实现定义
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
Public Class PrivateService
Implements IPrivateService
以下是配置设置
<services>
<service behaviorConfiguration="behaviorAction" name="Viking.Service.PrivateService">
<endpoint address="RequiredService" binding="wsHttpBinding" bindingConfiguration="bindingAction" contract="Viking.Service.IPrivateService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="bindingAction" transactionFlow="false" sendTimeout="00:30:00" receiveTimeout="00:30:00">
<reliableSession enabled="true"/>
</binding>
</wsHttpBinding>
</bindings>
非常欣赏有关此问题的任何建议。
答案 0 :(得分:24)
如果您使用的是wcf 4.0,请打开web.config / app.config并在<system.serviceModel>
标记内添加以下标记。
<protocolMapping>
<add scheme="http" binding="wsHttpBinding"/>
</protocolMapping>