zoukankan      html  css  js  c++  java
  • 客户端调用接口

     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
  • 相关阅读:
    spring——依赖注入
    jsp课程笔记(一)
    spring入门程序(一)
    关于java项目导入到eclipse无法访问的问题
    lnmp一键下载及安装
    spring配置文件application.Context配置文件的约束信息快速获取
    Tomcat下载与安装
    Nginx配置java项目在Tomcat下访问
    webstrom快捷键合集
    Ubuntu 开启SSH服务以及有关设置:安装,指定端口号、免密登录、远程拷贝
  • 原文地址:https://www.cnblogs.com/huyaguang/p/5863772.html
Copyright © 2011-2022 走看看