c# - 使用 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;
}
}
在此处输入代码
解决方案
推荐阅读
- php - PHP & JSON | Json 编码向一个值添加多个零
- android - 如何在崩溃后很长时间调试我的 android 应用程序
- python - 在对 numpy 数组进行迭代时,我无法调用存储在数组中的对象的方法
- python - 获取 TypeError:无法腌制 _thread.RLock 对象
- python - TypeError:预期的 str、字节或 os.PathLike 对象,而不是元组。怎么解决?
- excel - Excel:将“12.50 美元”数据粘贴到工作表中 -> 自定义数字格式可以将其视为粘贴操作中的数字吗?
- flutter - 如何在 Flutter 中将项目添加到自定义列表?
- sqlite - QSqlTableModel::removeRow() 无法设置 QSqlTableModel::OnManualSubmit
- c++ - 无法找到数组值的最小值和最大值 - C++
- node.js - 不能要求剧作家