[RESOLVED] WCF duplex service and Sharepoint
Wondering if anyone has experience with Sharepoint developing and WCF services because I'm having a hard time with this one :p
We have a client application that connects to a sharepoint server and it needs to retrieve some data from that server (We also have an application server-side to do that work). The data is quite big and it take a lot of time to prepare it before sending it to the client so we want to use WCF service in order to stream that data from the server to the client. This part is quite simple as it is only a "Request/Response" WCF service.
The problem I have is the fact that preparing the data on the server takes some time. We want to be able to inform the client about the different stages (progress) we are going through before sending the data. In order to do that I though I could use a duplex wcf service (Callbacks) in order to let the client know what the server is currently doing, but it seems that Sharepoint cannot host Duplex WCF services.
If anyone has any idea on how I could achieve that pls let me know. Any help would be greatly appreciated.
I'll let you know if I find something in the mean time.
Thanks
Re: WCF duplex service and Sharepoint
One way I though about doing it would be to have the client to send a GUID with its request and maintaining lets say a dictionary in wich I would add an entry for each client that requested the data and while the data is prepared update that entry with the step/progress that is currently going on for its request. Then the client, while he has not received its data yet can poll another service, again passing its GUID, that will check the dictionary and send back the current state/progress of the original client's request.
Not sure that is a good or efficient way to do it though :S
Re: WCF duplex service and Sharepoint
I managed to build a prototype using 2 WCF services, both using BasicHttpBinding and a static class that uses a static Dictionary<Guid, string> which will contain the current progress/step of the request identified by the Guid.
When I Request a large amount of data that needs a lot of steps performed (processing) before being sent, from Service1, each time a new step is performed, the entry is updated in the Dictionary. During that time, I have a second Thread that regularly request the current step from the Service2, which returns the value from the dictionary. This way I don't have to use Duplex communications (CallBacks) which I liked more but cannot be hosted in Sharepoint. This way the client is informed about what is currently happening before we start streaming the data.
It seems to work pretty fine for now. I'll have to make more tests and make sure that everything runs perfectly though as I use some backgroundworkers. Then I'll have to check if it all works fine in Sharepoint :P