基本的HTTP绑定未正确配置。

6
我已经配置了一个使用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>

非常感谢您对此问题的任何建议。

1个回答

24

如果您正在使用wcf 4.0,则打开web.config/app.config文件,并在<system.serviceModel>标签内添加以下标记。

  <protocolMapping>
  <add scheme="http" binding="wsHttpBinding"/>
</protocolMapping>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接