Web服务响应数据在多个请求上不匹配

时间:2018-11-29 07:44:28

标签: asp.net web-services

我们有适用于移动应用程序的Web服务,并且在更换服务器之前一切正常。最近,在网络服务响应中遇到问题之后,我们已将服务器移至Azure平台VM和SQL MI。 Web服务一个响应错误地映射到另一个请求的响应,例如,当用户1击中具有相应ID值的Web服务并且同时user2击中其ID时,用户1和用户2都获得与user1或user2相同的响应。仅在200次点击中出现10次。如果出现任何错误或错误之处,请提出建议。下面是代码,(这里我包括一些用于查找响应的日志)

根据以下函数“ GetJobAssignmentDetails_fhits”,“ Model_No”数字是获取用户各自详细信息的主键值。该功能用于获取各个用户的上述详细信息(客户,地址等)。

我们还检查了移动设备的角度,但是在移动应用程序中似乎没有问题,因为我们使用浏览器使用wsdl来访问具有相关参数的Web服务,并且其自身的响应是错误的。我们过去经常通过浏览器访问Web服务,该浏览器的唯一参数值为桌面中2个不同用户的唯一参数值,在那里我们在某个时间点每个用户都收到相同的响应。

下面是代码

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;
}

0 个答案:

没有答案