Click here to Skip to main content
15,745,232 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have created on web service which receives request from one mobile application and forward it to one another server,and it reply back to the mobile application with the response which my web service has received.
Now my question is, how i can handle multiple requests from multiple mobile application to my web service, so my web service can serve each mobile application.

public class Service1 : System.Web.Services.WebService
         public string postXMLData(String Session, String Token)
             string destinationUrl = "";
             String requestXml= "getmydata;";

             HttpWebRequest request = (HttpWebRequest)WebRequest.Create(destinationUrl);
             byte[] bytes;
             bytes = System.Text.Encoding.ASCII.GetBytes(requestXml);
             request.ContentType = "text/xml; encoding='utf-8'";
             request.ContentLength = bytes.Length;
             request.Method = "POST";
             Stream requestStream = request.GetRequestStream();
             requestStream.Write(bytes, 0, bytes.Length);
             HttpWebResponse response;
             response = (HttpWebResponse)request.GetResponse();
             if (response.StatusCode == HttpStatusCode.OK)
                 Stream responseStream = response.GetResponseStream();
                 string responseStr = new StreamReader(responseStream).ReadToEnd().Trim();
                 return responseStr;
                 return "Problem in getting resp";
             return null;

What I have tried:

Do i need to use Async task in my Web service to handle this ?
Updated 14-Sep-16 2:00am
F-ES Sitecore 14-Sep-16 7:06am    
This is the job of the hosting service. If your webservice is hosted in IIS then IIS handles all this for you, you don't need to do anything.
Richard Deeming 14-Sep-16 9:34am    
This is the same question you posted yesterday:[^]

Which I answered for you. Yesterday.

Why should anyone bother spending the time producing a detailed answer for you if you're just going to ignore it and re-post your question?!

1 solution

As mentioned in comments the server should handle that for you. If you find that your server cannot handle the load then you implement load balancing or some other technique but your code will stay the same, essentially.
Share this answer

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