• HttpInvoker GET/POST方式


    1、GET方式

    HttpGet httpGet = new HttpGet("http://localhost:8080/randomCode/getSouthUuid");
    String sourceId = "100001";
    String appkey = "34";
    List<NameValuePair> arrayList = new ArrayList<NameValuePair>();
    arrayList.add(new BasicNameValuePair("clientId", sourceId));
    arrayList.add(new BasicNameValuePair("appkey", appkey));
    // 设置参数
    String string = EntityUtils.toString(new UrlEncodedFormEntity(arrayList, "utf-8"));
    httpGet.setURI(new URI(httpGet.getURI().toString() + "?" + string));
    String str = httpInvoker.invoke(httpGet, HttpInvoker.STRING_ENTITY_HANDLER);

    2、POST方式

    HttpPost post = new HttpPost(url);
    logger.debug("testpath --------->"+TESTPATH)
    // 创建参数列表
    List<NameValuePair> arrayList = new ArrayList<NameValuePair>();
    arrayList.add(new BasicNameValuePair("code", "xxx"));
    arrayList.add(new BasicNameValuePair("redirect_uri", "xxx"));
    arrayList.add(new BasicNameValuePair("grant_type", "xxx"));
    // url格式编码
    UrlEncodedFormEntity uefEntity = new UrlEncodedFormEntity(arrayList, "UTF-8");
    post.setEntity(uefEntity);
    String str = httpInvoker.invoke(post, HttpInvoker.STRING_ENTITY_HANDLER);
    JSONObject json = JSONObject.parseObject(str);
    String values = json.get("xxx").toString();

  • 相关阅读:
    css属性操作2(外边距与内边距<盒子模型>)
    css的属性操作1
    css伪类
    属性选择器二
    属性选择器1
    03_MySQL重置root密码
    02_Mysql用户管理之Navicat下载及安装
    18.扩散模型
    17.广播模型
    16.友谊悖论
  • 原文地址:https://www.cnblogs.com/wangxiaoheng/p/7299424.html
Copyright © 2020-2023  润新知