Jersey post方法请求发送有效负载

时间:2014-12-25 12:26:38

标签: java jersey

    URL url = new URL("http://nvmbd1bkb150v03.rjil.ril.com/system/ws/v11/gh/search/?portalId=400100000001003&usertype=customer&$format=json");
    String payload="portalId=400100000001003&Q1-1-1000000931=1000000919&usertype=customer&%24format=json";
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setDoInput(true);
    connection.setDoOutput(true);
    connection.setRequestMethod("POST");
    connection.setRequestProperty("session_id", session_id);
    connection.setRequestProperty("Accept", "application/json");
    connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
    OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
    //writer.write(payload);
    writer.close();
    BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    while ((line = br.readLine()) != null) {
            jsonString.append(line);
    }
    //br.close();
    //connection.disconnect();
} catch (Exception e) {
        throw new RuntimeException(e.getMessage());
}
out.println(jsonString.toString());

这是我的所有代码。我想阅读该Web服务,但它给了我错误。请帮忙。

0 个答案:

没有答案