zoukankan      html  css  js  c++  java
  • 外置接口请求

    1. 请求接口

    /**
     * 请求接口
     *
     * @param url
     * @param paramsStr
     * @param type      Connection.Method.POST
     * @param heads
     * @return
     */
    public JSONObject sendUpload(String url, String paramsStr, Connection.Method type, Map<String, String> heads) {
        //发送上传订单请求
        String erpUploadResponse = null;
        try {
            Connection connection = Jsoup.connect(url).ignoreContentType(true)
                    .header("Accept", "*/*")
                    .header("Content-Type", "application/json; charset=UTF-8")
                    .method(type)
                    .timeout(2000000);
            if (heads != null) {
                for (Map.Entry<String, String> entry : heads.entrySet()) {
                    connection.header(entry.getKey(), entry.getValue());
                }
            }
            if (type == Connection.Method.POST) {
                connection.requestBody(paramsStr);
            }
            erpUploadResponse = connection.execute().body();
        } catch (IOException e) {
            logger.error("## FEITE面单上传接口出错!URL={},param={}, type={}", url, paramsStr, type);
        }
    
        return JSONObject.parseObject(erpUploadResponse);
    }

    2. 请求方式

    JSONObject responseJson = sendUpload(erpQueryTraceId, JSON.toJSONString(param), Connection.Method.POST, null);
  • 相关阅读:
    中断
    按键
    uart stdio的移植1
    串口通信实战
    串口通信相关知识详解
    SOC时钟
    arm-linux-ld: cannot find sdram_init.o
    SDRAM初始化
    代码重定位实战
    s5pv210的启动过程
  • 原文地址:https://www.cnblogs.com/yifanSJ/p/10209887.html
Copyright © 2011-2022 走看看