//获取要传递的值
postData = “keyValue=” + keyValue + “&IFlag=” + IFlag +"&cDefine2=" + cDefine2;
转化成二进制数组
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
//获取路径
string uriString = System.Configuration.ConfigurationManager.AppSettings[“WEB_HOST”].ToString() + “IQC/PUArrivalVoch/AddBarCode”;
/// string uriString = “http://localhost:6688/IQC/PUArrivalVoch/AddBarCode”;
var myWebClient = new System.Net.WebClient();
///
myWebClient.Headers.Add(“Content-Type”, “application/x-www-form-urlencoded”);
byte[] responseArray = myWebClient.UploadData(uriString, “POST”, byteArray);
//将返回的字节数据转成字符串
string result = System.Text.Encoding.UTF8.GetString(responseArray, 0, responseArray.Length);
// result.
JObject obj = (JObject)JsonConvert.DeserializeObject(result);
-----------------------------方法名-------------------------------------------
UploadData(String, Byte[])
将数据缓冲区上载到由 URI 标识的资源。
UploadData(Uri, Byte[])
将数据缓冲区上载到由 URI 标识的资源。
UploadData(String, String, Byte[])
使用指定的方法将数据缓冲区上载到指定资源。
UploadData(Uri, String, Byte[])
使用指定的方法将数据缓冲区上载到指定资源。