hi all,
I have created WCF Rest services. When i am hitting the same request continuously from client(i.e from Android mobile) it is using diifrerent threads and thread.sleep is also not working.
My code is below like this..
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
public class Service1 : IService1
{
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "VerifyLogin")]
public bool VerifyLogin(Login loginCred)
{
bool res = false;
string strThreadPrint= "";
try
{
strThreadPrint= Thread.CurrentThread.ManagedThreadId.ToString() + " time at : "+DateTime.Now;
Thread.Sleep(5000);
dbcon = new DBConnection();
//for testing here i am throwing an exception so that its going to catch block and responce sent back to client with exception details as shown in catch block.
dbcon.VerifyLogin(loginCred.Username.Trim(), loginCred.Password.Trim());
}
catch (Exception sqlex)
{
objErrorClass = new ErrorClass("Login class", sqlex.Message + " --- " + strThreadPrint, "CNMK");
throw new WebFaultException<ErrorClass>(objErrorClass, System.Net.HttpStatusCode.BadRequest);
}
}
}
when i am sending request using fiddler with following Requestbody {"Username":"13","Password":"dgdf"}
At that time i am getting the responce as in Json format
{"ErrorDesc":"login failed --- 33 time at :09/04/2013 12:31:30"}
{"ErrorDesc":"login failed --- 35 time at :09/04/2013 12:31:30"}
{"ErrorDesc":"login failed --- 41 time at :09/04/2013 12:31:30"}
{"ErrorDesc":"login failed --- 45 time at :09/04/2013 12:31:30"}
So the instance mode and concurrency mode not working for wcf restful services????
or am i doing any wrong in my code?? please help me