2010-06-05 41 views
0



我得到了运行自定义绑定的WCF服务,现在它使用httpTransport。如何使用WCF获取PerSession上下文?

<customBinding> 
    <binding name="myHttpBindingConf"> 
     <context contextManagementEnabled="true" protectionLevel="None" 
        contextExchangeMechanism="ContextSoapHeader" /> 
     <textMessageEncoding/> 
     <httpTransport useDefaultWebProxy="false" /> 
    </binding> 
</customBinding> 

我做了一个自定义IExtension<OperationContext>去购买在特定的情况下我的数据由以下这些指令: http://hyperthink.net/blog/a-simple-ish-approach-to-custom-context-in-wcf/

我想用一个ContextMode.PerSession上下文。

哪个运输选择获得会话管理?
如何设置新的传输并启用对象发现?
如何强制PerSession上下文?

+0

我将它与WsHttpBinding的运行以及指定。 如果您遇到同样的麻烦,您可以在这里查看我的Web.config: http://code.google.com/p/tte-knbc/source/browse/trunk/BusinessLayer/Web.config 您可能会在CECIL-L – christophe31 2010-06-16 13:30:10

回答

1

建立会话的能力不一定仅取决于使用的传输。例如。您可以使用WS-SecureConversion建立会话并仍然使用HTTP传输。

检查http://msdn.microsoft.com/en-us/library/ms733040.aspx“系统提供的会话类型”部分。

此外,您通常会将您的服务实例绑定到会话,而不是操作上下文。

0

你在你的服务的实现,而不是在配置文件中

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)] 
public class MyService : IMyService 
+0

的调试器下降整个项目,事实上,我不知道如何在C#中的自定义行为中处理此问题,如教程中所述... – christophe31 2010-06-05 17:08:52