• 客户端调用接口


     1 public void CallBackCheck(string barcode, string ticketcount, string zybbillno)
     2         {
             //接口参数的定义 json格式
    3 string json = "{"checkNo": "" + barcode + "","checkOrderType": "1","operateTime": "" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "","orderDetailId": "" + zybbillno + "","ticketCount": "" + ticketcount + ""}"; 4 string code = "checkNo=" + barcode;
    //接口签名验证
    5 string sign = MD5Encrypt(code);
             //从配置文件获取接口的地址 8 string url = TwiConfigHelper.GetAppSettingValue("zybQ"); 9 //string postData = string.Format("sdk=13812095997&code=wuxi0303&phones={0}&msg={1}&resulttype=text",
             //需要向接口传递的参数 10 string postData = string.Format("noticeParam={0}&noticeType=1&sign={1}", 11 json, 12 sign 13 ); 14 15 try 16 { 17 HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); 18 httpWebRequest.ContentType = "application/x-www-form-urlencoded"; 19 httpWebRequest.Method = "POST"; 20 httpWebRequest.Timeout = 20000; 21 byte[] btBodys = Encoding.UTF8.GetBytes(postData); 22 httpWebRequest.ContentLength = btBodys.Length; 23 httpWebRequest.GetRequestStream().Write(btBodys, 0, btBodys.Length); 24 HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); 25 StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream()); 26 string responseContent = streamReader.ReadToEnd(); 27 httpWebResponse.Close(); 28 streamReader.Close(); 29 httpWebRequest.Abort(); 30 httpWebResponse.Close(); 31 //MessageBox.Show(responseContent); 32 } 33 catch (Exception ex) 34 { 35 //MessageBox.Show(ex.Message); 36 } 37 }
    更多技术交流+QQ:318617848
  • 相关阅读:
    代码扫描工具
    事务注解加在Controller 和 Service上有哪些区别
    什么是嵌套事务
    配置工程日志
    利用mkvirtualenv工具搭建python2和python3环境
    python接口自动化1-发送get请求
    面试题:使用存储过程造10w条测试数据,数据不重复
    python测试开发
    接口自动化测试持续集成+postman+newman+git+jenkins+钉钉
    app专项测试
  • 原文地址:https://www.cnblogs.com/huyaguang/p/5863772.html
Copyright © 2020-2023  润新知