问题
I know that WSDualHttpBinding, NetTcpBinding, and NetPeerTcpBinding bindings all support duplex/callback service operations.
I can't find anywhere on the internet anyone even asking if duplex is somehow supported for ajax calls. Maybe the reason for my inability to find anything on this is because I am completely misunderstanding some key WCF concept that makes the question the dumbest question there is...
I know that the webHttpBinding binding along with <enableWebScript/>
gneerates the js necessary for proxy objects client-side.
Is this impossible because duplex services need that callbackservice to be hosted and there is no way to do that client-side ? (If that makes sense..)
My app is layered as follows:
1. WebSite1 - ajax calls to WebSite1.MyClientService.
2. WebSite1.MyClientService - WCF Self-hosted service that references MyServiceProxies DLL.
3. MyServiceProxies DLL - Custom proxies (used instead of "Add Service reference" auto-generated proxies) that inherit from ClientBase. This simply delegates actual service calls out to base.Channel.OperationName() at [MyService : IMyService at WinService WCF Host EXE].
4. WinService WCF Host EXE - This is running as a windows service, as a singleton, allowing multi-threaded calls. The calls from WebSite1 query the in-memory values held by this singleton. This singleton will eventually commit all data held in-memory to database via seperate data layer.
The WinService is configured to use duplex calls over net.tcp. The WinService will run on same machine as WebSite1 IIS App.
回答1:
I can't find anywhere on the internet anyone even asking if duplex is somehow supported for ajax calls. Maybe the reason for my inability to find anything on this is because I am completely misunderstanding some key WCF concept that makes the question the dumbest question there is...
Not dumb, maybe, because I think it's AJAX you don't understand, not WCF.
It doesn't really make sense to have a duplex contract in AJAX. A duplex contract has to expect the server to call the contract operations at any time. It's not like publish/subscribe, for instance, or solicit response, where an action by the client is necessary before messages start arriving. With a duplex contract, messages could arrive at any time.
Who's going to listen to them? Not the browser. If the browser were going to react to unsolicited messages coming in from some remote machine and then running code - well, that sounds a lot like the definition of a virus, doesn't it?
I don't think you're going to find support for duplex contracts in JavaScript for quite some time.
来源:https://stackoverflow.com/questions/1066336/wcf-asp-net-duplex-support-using-ajax