1.使用jar

httpcomponents-client-4.5.6-bin.tar.gz

解压后倒入lib中的所有包

2.参考代码如下

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;

import org.apache.http.util.EntityUtils;

public class HttpClientTest {
public static void main (String args[]) throws ClientProtocolException, IOException {
String url="http://**********/tppservice/es/zytWtService";
String outputStr="{\"head\":{\"userId\":\"\",\"subsystem\":\"ZYT_APP\",\"subject\":\"ZYT_WT_001\",\"token\":\"TPP_ZYT\",\"sign\":\"d5682c3f2bede511d3f0b1fac3598454\",\"serialNo\":\"1412660\",\"transDate\":\"2018-11-02 16:09:20\"},\"busi\":{\"flag\":\"1\",\"pwd\":\"www123456\",\"userName\":\"18500000058\"}}";
HttpClient httpClient = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
StringEntity postingString = new StringEntity(outputStr);// json传递
post.setEntity(postingString);
post.setHeader("Content-type", "application/json");
HttpResponse response = httpClient.execute(post);
String content = EntityUtils.toString(response.getEntity());
System.out.println(content);
}
}

3.包导的不对会报NoClassDefFoundError: org.apache.commons.logging.LogFactory异常,是依赖的包没有导完整

HTTP发送RAW请求注意的问题的更多相关文章

  1. requests发送HTTP请求

    requests库是一个流行的用于发送Http请求的Python第三方库, 其设计简洁高效可以完美替代默认的urllib. 使用pip安装requests: pip install requests ...

  2. Python3发送post请求,自动记住cookie

    转载自:http://www.cnblogs.com/meitian/p/4607737.html 在做登录的post请求时,需要记住cookie,否则不能访问登录后的页面. 下面是登录的代码: #c ...

  3. postman: 用于网页调试和发送Http请求的chrome插件

    一 简介 Postman 是一款功能超级强大的用于发送 HTTP 请求的 Chrome插件 .做web页面开发和测试的人员应该是无人不晓无人不用!其主要特点 特点: 创建 + 测试:创建和发送任何的H ...

  4. 【liferay】1、使用alloy-UI发送ajax请求

    1.首先liferay要发送ajax请求,那么就需要在jsp中定义resourceURL <portlet:resourceURL var="workDeal" id=&qu ...

  5. python接口自动化(六)--发送get请求接口(详解)

    简介 如果想用python做接口测试,我们首先有不得不了解和学习的模块.它就是第三方模块:Requests. 虽然Python内置的urllib模块,用于访问网络资源.但是,它用起来比较麻烦,而且,缺 ...

  6. postman发送json请求,使用案例

    介绍:  postman是一个很好的http模拟器,,可以发送get.post.put等各种请求,是测试服务接口相当好的工具. postman发送json请求,使用案例 发送json的具体步骤: 1. ...

  7. 使用Fiddler发送POST请求

    使用Fiddler发送POST请求 在测试过程中,有时会遇到需要修改请求中带的参数,去验证权限的安全问题,但是一些post请求,我们在浏览器中不能直接修改他的参数,然后去提交验证. 而fiddler可 ...

  8. 如何使用fiddller跟踪windows进程发送的请求20140911

    总结点:如何使用fiddller跟踪windows进程发送的请求 案例如下: 需求:运维工具提出需求,对每个插件的配置文件,同步到运维中心时先加密,然后传输到运维中心解密,存储到数据库 测试分析:这个 ...

  9. python接口自动化2-第一次发送get请求

    前言 Requests: 让 HTTP 服务人类,唯一的一个非转基因的 Python HTTP 库,人类可以安全享用: Requests继承了urllib2的所有特性,能满足当前网络的需求,支持Pyt ...

随机推荐

  1. Ubuntu使用总结二

    Ubuntu使用 - 1.ubuntu怎么切换到root用户,切换到root账号方法 ubuntu怎么切换到root用户,我们都知道使用su root命令,去切换到root权限,此时会提示输入密码, ...

  2. 去除 chrome 上保存密码后的 input 框的屎黄色背景

    网上找的设置 background-color,background-image 没用,后来找到这个方法测试有效: input:-webkit-autofill { transition: backg ...

  3. js转盘游戏

    1----- @-webkit-keyframes spin { 0%   { -webkit-transform: rotate(0deg); -ms-transform: rotate(0deg) ...

  4. django-枚举类型扩展方法

    原文地址:https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.get_FOO_disp ...

  5. ImportError: dynamic module does not define module export function (PyInit__sqlite3)

    使用python3.6 中的django-admin创建项目的时候报错 ImportError: dynamic module does not define module export functi ...

  6. sql注入-输入’or 1=1#

    比如:在用户名输入框中输入:’or 1=1#,密码随便输入,这时候的合成后的SQL查询语句为:     select * from users where username='' or 1=1#' a ...

  7. Java高级特性 第14节 解析XML文档(2) - SAX 技术

    一.SAX解析XML文档 SAX的全称是Simple APIs for XML,也即XML简单应用程序接口.与DOM不同,SAX提供的访问模式是一种顺序模式,这是一种快速读写XML数据的方式.当使用S ...

  8. 使用OwnCloud搭建自己的云盘

    使用OwnCloud搭建自己的云盘 1.用途 ownCloud是一款开源的私有云框架,可以通过它实现个人网盘的功能,ownCloud提供了各个平台的文件同步客户端,因此搭建好ownCloud之后即可使 ...

  9. 常用java的正则表达式

    package everyDayPratise; import java.util.regex.Pattern; public class RegexExample { public static v ...

  10. Azure CosmosDB (13) CosmosDB数据建模

    <Windows Azure Platform 系列文章目录> 我们在使用NoSQL的时候,如Azure Cosmos DB,可以非常快速的查询非结构化,或半结构化的数据.我们需要花一些时 ...