I have a working duplex WCF service with WSDualHttpBinding
. My problem is figuring out a way to store the callback channel with a unique id. The service is intended to be long-running. Can I simply grab the OperationContext.Current.GetCallbackChannel()
return value when a "Subscribe" method is called and store it in a list or dictionary? Is it guaranteed to be valid until the connection is alive?
相关问题
- How to make a .svc file write to asp.net Trace.axd
- WCF Service Using Client Certificates Requires Ano
- WCF error with net.tcp "The service endpoint faile
- WCF Service Reference Support Files Not Updating
- WCF Web Service: Upload a file, Process that file,
相关文章
- Service层和Dao层一定要对应吗?
- k8s 访问Pod 时好时坏
- WCF发布Windows服务 POST方式报错 GET方式没有问题 应该怎么解决?
- XCopy or MOVE do not work when a WCF Service runs
- Async task does not work properly (doInBackground
- Could not find default endpoint element that refer
- The 'DbProviderFactories' section can only
- Do I need to expose a constructor in a WCF DataCon
The easiest way would be to have the client submit a key value in the Subscribe method of your service. You could then save the Callback channel in a dictionary. This dictionary would probably need to be a static variable or singleton class whose lifespan is greater than the Service Class's lifespan since most service class's have a PerCall lifetime and get disposed of after the service call is complete. Beware of threading issues!
The callback channel can be faulted at any time either on the client or the service side. The service has to handle the possibility of a faulted channel and to remove the faulted channel from the dictionary. WSDuallHttpBinding is a "Stateless" binding so any faults in the client won't be detected on the service side until the service side attempts to call them. NetTcpBinding will raise the ChannelFaulted event if the client gets into a faulted state. For that reason I would recommend the NetTcpBinding if it fits your requirements.