zoukankan      html  css  js  c++  java
  • C# 模拟from表单提交webservice

    public static string test( string user_id, string eventId, string page, string pageSize, string message)//接口需要的参数自定义
    {
    string postUrl = "http:";//接口连接
    string ret = string.Empty;//返回字符串
    try
    {
    NameValueCollection na = new NameValueCollection();//添加参数
    na.Add("user_id", user_id);
    na.Add("eventId", eventId);
    na.Add("pageOffset", page);
    na.Add("pageSize", pageSize);

    byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(na.ToString());//编码格式
    //HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(postUrl));
    System.Net.WebClient WebClientObj = new System.Net.WebClient();
    byte[] bytes = WebClientObj.UploadValues(postUrl, "POST", na);//提交方式POST
    string st = System.Text.Encoding.UTF8.GetString(bytes);得到返回的json
    ret = st;
    }
    catch (Exception ex)
    {
    }
    return ret;
    }

  • 相关阅读:
    solr总结
    jeesite
    Freemarker模板的使用简介
    Sd
    Sd
    Sd
    Standard Java集合类问题待整理
    Standard
    Linux并发服务器设计
    Java 生产者消费者 & 例题
  • 原文地址:https://www.cnblogs.com/li-lun/p/4698788.html
Copyright © 2011-2022 走看看