I'm building WCF rest service and it's client. I plan, that client does not know much about the service, just right URL's to call methods and expected results.
My service contract is:
[WebInvoke(Method="POST", UriTemplate="/tasks")]
[OperationContract]
void SubmitTask(Transaction task);
[WebGet(UriTemplate = "/tasks/{taskId}")]
[OperationContract]
[XmlSerializerFormat]
Transaction GetTask(string taskId);
SubmitTask is realized like:
SubmitTask(Transaction task)
{
DoSomethingWithTask(task);
task.Status = "SomeStatus";
DoSomethingElseWithTaks(task);
task.Status = "SomeOtherStatus";
}
What I expect on client:
ButtonClick()
{
SubmitTask(task);
while(true)
{
string status = Transaction GetTask(task.taskId).Status;
Textbox.Text+= status;
if(status==ok)
break;
Thread.Sleep(1000);
}
}
The problem is - GetTask is not performed on service side, while all SubmitTask operations are completed, so I get only last task status on client side. How to realize asynchronos operation performing in this situation?
Thanks in advance!
Have you read this interesting little article? Tweaking WCF to build highly scalable async REST API and the following article that is very good and which will hopefully provide the answer you desire Fixing WCF to build highly scalable async REST API
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With