none
Web Service response data is mismatch for multiple web service request at a time RRS feed

  • Question

  • Dear Support Team,

    We have created a web service for mobile app and it was working fine. Recently, we have moved our server to Azure platform VM and SQL MI after that we are facing the challenges in the web service response. The web service one response wrongly mapping to another request's response

    E.g when user 1 hitting the web service with respective primary key value and same time user2 hit with his primary key then user 1 and user 2 both getting the same response of either user1 or user2. This issue occurs only in rare scenarios (i.e 10 out of 200 hits approx at a time).

    Kindly suggest me if anything wrong or where the mistake has done. below is the code, (here I have included some logs for finding the response)

    Example Code:

    public class JobSeq
        {
            private string sJobCode;        
            private string sCustCode;
            private string sCustName;        
            private string sContactPerson;
            private string sContactNo;
            private string sCustAddress;        
            private int sJSno;  
    
            [System.Xml.Serialization.XmlElementAttribute]
            public int JSno
            {
                get { return sJSno; }
                set { sJSno = value; }
            }
           
            //Job Code
            [System.Xml.Serialization.XmlElementAttribute]
            public string JobCode
            {
                get { return sJobCode; }
                set { sJobCode = value; }
            }
            //Customer Code
            [System.Xml.Serialization.XmlElementAttribute]
            public string CustomerCode
            {
                get { return sCustCode; }
                set { sCustCode = value; }
            }
            //Customer Name
            [System.Xml.Serialization.XmlElementAttribute]
            public string CustomerName
            {
                get { return sCustName; }
                set { sCustName = value; }
            }
            //Customer Address
            [System.Xml.Serialization.XmlElementAttribute]
            public string Address
            {
                get { return sCustAddress; }
                set { sCustAddress = value; }
            }
            //Contact Person
            [System.Xml.Serialization.XmlElementAttribute]
            public string ContactPerson
            {
                get { return sContactPerson; }
                set { sContactPerson = value; }
            }
            //Contact No
            [System.Xml.Serialization.XmlElementAttribute]
            public string ContactNo
            {
                get { return sContactNo; }
                set { sContactNo = value; }
            }
            
            [System.Xml.Serialization.XmlElementAttribute]
            public string RowCount { get; set; }
    
            [System.Xml.Serialization.XmlElementAttribute]
            public string TotRowCount { get; set; }
    
            [System.Xml.Serialization.XmlElementAttribute]
            public string NewJob { get; set; }
    
            [System.Xml.Serialization.XmlElementAttribute]
            public string Accecptjob { get; set; }
        }
    
    
    [WebMethod(Description = "Testing", CacheDuration = 0, EnableSession = false)]
            public JobDetails_Test GetJobAssignmentDetails_fhits(string Model_No, bool isHistory, string utcStTime, string utcEndTime, string currLatLng, int PageNo, int RowCount, bool isNewjob)
            {
               // Trinetra_App.BAL.Configurations objC = new Trinetra_App.BAL.Configurations();
                          DateTime dtStTime = DateTime.Now;
                ModelNumber = Model_No.ToString();
                DataSet ds = new DataSet();
                SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConString"].ToString());
                SqlCommand command = new SqlCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "rvlf_sp_GetDetails1";
                command.Connection = conn;
    
                DataTable dtTable = new DataTable();
    
                JobDetails_Test objJobDetails_std1 = new JobDetails_Test();
                Hashtable param_std1 = new Hashtable();
                try
                {
                    param_std1.Add("@cModelCode", Model_No);
                    command.Parameters.AddWithValue("@cModelCode", Model_No);
                    if (isHistory == true)
                    {
                        command.Parameters.AddWithValue("@bIsHistory", "1");
                        command.Parameters.AddWithValue("@dStDate", utcStTime);
                        command.Parameters.AddWithValue("@dEndDate", utcEndTime);
                        param_std1.Add("@bIsHistory", "1");
                        param_std1.Add("@dStDate", utcStTime);
                        param_std1.Add("@dEndDate", utcEndTime);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@cCurrLatLng", currLatLng);
                        command.Parameters.AddWithValue("@Isnewjob", isNewjob);
                        param_std1.Add("@cCurrLatLng", currLatLng);
                        param_std1.Add("@Isnewjob", isNewjob);
                    }
    
                    //ds = objC.ExecuteDataSet(param_std1, "rvlf_sp_GetJobDetails1", true);
    
                    SqlDataAdapter adapter = new SqlDataAdapter();
                    adapter.SelectCommand = command;
                    adapter.Fill(ds);
                    if (ds.Tables.Count != 0)
                    {
                        if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                        {
                            
                            StringWriter sw = new StringWriter();
                            ds.WriteXml(sw, XmlWriteMode.IgnoreSchema);
                            
                            List<JobSeq> objJobAssignment_std1 = new List<JobSeq>();
                            PagedDataSource objPds = new PagedDataSource();
                            objPds.DataSource = ds.Tables[0].DefaultView;
                            objPds.AllowPaging = true;
                            objPds.PageSize = RowCount;
                            objPds.CurrentPageIndex = PageNo - 1;
    
                            foreach (DataRow item in ds.Tables[0].Rows)
                            {
                                JobSeq objJobSeq = new JobSeq();
                                objJobSeq.JobCode = item["JobCode"].ToString();
                                objJobSeq.JSno = Convert.ToInt32(item["Sno"].ToString());
                                objJobSeq.CustomerCode = item["CustId"].ToString();
                                objJobSeq.CustomerName = item["CustName"].ToString();
                                objJobSeq.Address = item["CustomerAddress"].ToString();
                                objJobSeq.ContactPerson = item["ContactPerson"].ToString();
                                objJobSeq.ContactNo = item["Phone"].ToString(); 
    
                                if (isHistory)
                                {
                                    objJobSeq.SignatureBytes = new byte[] { };
                                    objJobSeq.AttachmentBytes = new byte[] { };
                                }
                                objJobAssignment_std1.Add(objJobSeq);
                            }
                           
    
                            objJobDetails_std1.Assignment = objJobAssignment_std1;
                            if (ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0)
                            {
                                objJobDetails_std1.NewJob = Convert.ToInt32(ds.Tables[1].Rows[0]["NewJob"].ToString());
                                objJobDetails_std1.Accecptjob = Convert.ToInt32(ds.Tables[1].Rows[0]["Accecptjob"].ToString());
                            }
                            else
                            {
                                objJobDetails_std1.NewJob = 0;
                                objJobDetails_std1.Accecptjob = 0;
                            }
                            objJobDetails_std1.Response_Status = "Success";
                        }
                        else
                        {
                            objJobDetails_std1.Response_Status = "Data not available";
                        }
                    }
                    else
                    {
                        objJobDetails_std1.Response_Status = "Data not available";
                    }
                }
                catch (Exception ex)
                {
                    objJobDetails_std1.Response_Status = ex.Message.ToString();
                   
                    StackFrame stackFrame = new StackFrame();
                    MethodBase methodBase = stackFrame.GetMethod();
                    
                    ModelNumber = string.Empty;
                }
                finally
                {
                    param_std1.Clear();
                    param_std1 = null;
                    ds.Dispose();
                    ds = null;
                }
                
                return objJobDetails_std1;
            }
    

    Regards,Sakthi Gopinath

    Thursday, November 29, 2018 7:50 AM

Answers