I have always thought that the WCF duplex communication method in Sl is a little tricky. If it is implemented in http mode, the efficiency is too low. If it is implemented in TCP mode in sl4, it is the same as socket, so I have not studied it, however, this is easy to implement when the performance requirement is not high (for example, the weather forecast/stock information is updated every five minutes on the webpage.
Compared with traditional WCF, the biggest difference between WCF duplex communication is that traditional WCF usually calls services from clients, that is, the client pulls information from the server, in addition to allowing the client to pull information from the server, the server can also actively push information to the client.
Of course, this implementation consumes performance. The server will save a "Callback channel" so that information can be pushed to the client through this channel, the client also needs to have corresponding callback functions to handle them-a bit similar to "long links in Ajax" and "server push" Technology
Sl3 official documentation http://msdn.microsoft.com/zh-cn/library/dd470106 (vs.95 ). in aspx, a client sends the order to the server and then forwards the result back to the client after processing by the server. However, there are two parts in the SDK that do not indicate the details, debugging failure may be misled.
1. If bindingextensions is configured in Web. config of the server, follow the official configuration instructions:
<Extensions>
<Bindingextensions>
<Add name = "pollingduplexhttpbinding"
Type = "system. servicemodel. configuration. pollingduplexhttpbindingcollectionelement, system. servicemodel. pollingduplex, Version = 2.0.5.0, culture = neutral, publickeytoken = 31bf3856ad364e35"/>
</Bindingextensions>
</Extensions>
Prompt will be displayed when you browse SVCProgramFailed to load the set. In this case, remove ", version = 2.0.5.0, culture = neutral, publickeytoken = 31bf3856ad364e35" above and change it
<Extensions>
<Bindingextensions>
<Add name = "pollingduplexhttpbinding" type = "system. servicemodel. configuration. pollingduplexhttpbindingcollectionelement, system. servicemodel. pollingduplex"/>
</Bindingextensions>
</Extensions>
In addition, if system. servicemodel. pollingduplex. dll is not found in the bin directory after generation, you can manually copy it to the bin directory.
2. If the client cannot access the client during debugging, check whether there is a policy file clientaccesspolicy. xml on the server. The reference content is as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<Access-Policy>
<Cross-domain-access>
<Policy>
<Allow-from http-request-headers = "soapaction">
<Domain uri = "*"/>
</Allow-from>
<Grant-to>
<Resource Path = "/" include-subpaths = "true"/>
</Grant-to>
</Policy>
</Cross-Domain-access>
</Access-Policy>
Source codeDownload: duplexwcf_sl.rar (edited by vs2010, which may need to be manually modified when opened in vs2008)