Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Threading WebService
Hi,
 
I have created web service. Server is pushing data to my service frequently (1000 in in 15 min). I want to send acknoledgement saying xml is correct and need to process that data after sendin acklowledge.
 
How can i achieve this in web service?
[WebMethod]
public string temp(string)
{
     //validate xml
     // store into obj

i want to implement threading here 
     //send acknowledgement

 
     //do some calculations on data and store into database
 }
Please help me how to achieve this?
 
Thank you.
Posted 6-Jul-12 9:05am
rk2881464
Edited 7-Jul-12 0:55am
v3
Comments
Wes Aday at 6-Jul-12 14:11pm
   
So go ahead and create a thread. You already know what it is that you want to do so go do it.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Personally I don't think putting threading into a web service is a very good idea especially if it's IIS hosted as you run the risk of putting the IIS worker processes into an unhealthy state. I'd create another WCF service, self hosted, as is always my preference, which is hidden somewhere behind your web servers. This service does the processing.
 
When you create this service, make use of the IsOneWay option on the operation contract option. With one way contracts the call doesn't wait for the process to the complete, it simply sends the data.
 
The following is information about one way contracts.
 
http://msdn.microsoft.com/en-us/library/ms733035.aspx[^]
 
Note all the examples return void. That's because they don't wait, they can't return anything so they have to return void.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I wish i could use WCF. But requirement is to use VS 2005 and web service(ASMX / SOAP) only. So if you can please give any other suggetion to acheive this in web service.
 
Thank you.
  Permalink  
Comments
Stephen Hewison at 6-Jul-12 16:18pm
   
Another option is once the XML is validated store it in a job queue within SQL. Then have a bog standard windows service which polls the queue table for jobs.
Stephen Hewison at 6-Jul-12 16:20pm
   
By a job queue I mean a table which store the XML in the order they were received. Your service then process them in the order they were received.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 CPallini 235
1 DamithSL 225
2 OriginalGriff 198
3 George Jonsson 170
4 Maciej Los 165
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 7 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100