首页 > 解决方案 > 使用 json 将数据发布到 web 服务

问题描述

我使用 json 将数据发布到网络服务,但是当我的数据类型是波斯字符串时,网络服务会以这种格式接收 ????? 例如,我发送 عادی 但收到这种格式的网络服务 ???? 例如“1400/12/14” -----> ????????

 [WebMethod]
public string SendData(int TelFormNo, string regionName, string importance)
{

    MyCDB mcc = new MyCDB();
    DataSet ds = new DataSet();
    mcc.connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["WConn"].ConnectionString;
    mcc.AddTable(ref ds, "select * from Eblagh where TelFormNo=" + TelFormNo, "dsResult");


    DaryaftKhabar eblaghData = new DaryaftKhabar();

    eblaghData.SourceRequest = "122";
    eblaghData.IncId = TelFormNo;
    eblaghData.DateRegister = string.Format(ds.Tables["dsResult"].Rows[0]["E_CallDT"].ToString().Substring(0, 4)+ '/' + ds.Tables["dsResult"].Rows[0]["E_CallDT"].ToString().Substring(4, 2)+ '/' + ds.Tables["dsResult"].Rows[0]["E_CallDT"].ToString().Substring(6, 2));
    eblaghData.TimeRegister = (ds.Tables["dsResult"].Rows[0]["E_CallDT"].ToString().Substring(8, 2)+ ':' + ds.Tables["dsResult"].Rows[0]["E_CallDT"].ToString().Substring(10, 2)+ ":00").ToString();
    eblaghData.Eteladahande = ds.Tables["dsResult"].Rows[0]["E_RefEmpName"].ToString();
    eblaghData.Family = ds.Tables["dsResult"].Rows[0]["E_UName"].ToString();
    eblaghData.Phon = ds.Tables["dsResult"].Rows[0]["E_UPhone"].ToString();
    eblaghData.RegionName = regionName;
    eblaghData.Subject = ds.Tables["dsResult"].Rows[0]["E_Problem"].ToString();
    eblaghData.Importance = importance;
    
    string serialisedData = JsonConvert.SerializeObject(eblaghData);
    string url = "http://172.29.253.140:8000/dms/";
    System.Net.WebClient client = new System.Net.WebClient();
    client.Headers[HttpRequestHeader.ContentType] = "application/json";
    var response = client.UploadString(url, serialisedData);
  
    return response;

}

}

在此处输入代码

标签: c#asp.netjsonweb-servicesstring-formatting

解决方案


推荐阅读