Click here to Skip to main content
15,861,340 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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?
C#
[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
Updated 6-Jul-12 23:55pm
v3
Comments
[no name] 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.

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.
 
Share this answer
 
v2
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.
 
Share this answer
 
Comments
Stephen Hewison 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 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900