接口中数据流的格式发送请求和解析流请求
来源:互联网 发布:军团战争5.15怪物数据 编辑:程序博客网 时间:2024/06/03 19:06
数据流格式发送请求:
HttpClient hc = new HttpClient();
int httpcode = 0;hc.setConnectionTimeout(10000);
hc.setTimeout(8000);
PostMethod pm = new PostMethod(supplierServerUrl);
String sign = util.MD5HEX(AgentID+Timestamp+AgentOrderID+GoodsTypeID+GoodsID+PayNumber+Amount+key);
String source="{\"header\": {\"AgentID\":\""+AgentID+"\",\"Timestamp\":\""+Timestamp+"\",\"sign\":\""+sign+"\"},\"body\": {\"AgentOrderID\": \""+AgentOrderID+"\",\"GoodsTypeID\": \""+GoodsTypeID+"\",\"GoodsID\": \""+GoodsID+"\",\"PayNumber\": \""+PayNumber+"\",\"Amount\": \""+Amount+"\"}}";
System.out.println(source);
RequestEntity se = new StringRequestEntity(source,
"application/x-www-form-urlencoded","utf-8");
pm.setRequestEntity(se);
httpcode = hc.executeMethod(pm);
responseStr=pm.getResponseBodyAsString();
pm.releaseConnection();
解析流格式:
int httpcode = 0;
String resposeStr = "";
HttpClient hc = new HttpClient();
hc.setConnectionTimeout(15000);
hc.setTimeout(15000);
PostMethod pm = new PostMethod(supplierServerUrl);
pm.setRequestBody(nvp);
httpcode = hc.executeMethod(pm);
InputStream is = pm.getResponseBodyAsStream();
BufferedReader br=new BufferedReader(new InputStreamReader(is,"utf-8"));
String line=null;
char[] c=new char[1024];
int len=0;
while(-1 != (len = br.read(c))){
line=new String(c, 0, len);
}
responseStr=line;
pm.releaseConnection();
is.close();
br.close();
- 接口中数据流的格式发送请求和解析流请求
- 请求第三方接口返回json格式数据的解析
- 利用HTTPClient模块中HttpGet和HttpPost 发送接口请求
- live555学习二:数据流的发送(PLAY请求的处理)
- VPOS MAS-CNP接口——建立https连接发送请求并接收返回的XML数据流
- 发送请求读取接口
- RestTemplate 发送json格式的http请求
- postman发送json格式的post请求
- java解析json格式请求的url中参数
- java以json格式向后台服务器接口发送请求
- HTTP请求和响应格式详细解析
- HTTP请求和响应格式详细解析
- HTTP请求和响应格式详细解析
- HTTP请求和响应格式详细解析
- c# 发送post请求到服务器,并解析得到的xml格式的字符串
- sqlserver异常:传入的表格格式数据流 (TDS)远程过程调用(RPC)协议流不正确。此 RPC 请求中提供了过多的参数。最多应为 2100
- 问题:传入的表格格式数据流(TDS)远程过程调用(RPC)协议流不正确。此 RPC 请求中提供了过多的参数。最多应为 2100
- socket发送请求包格式
- react native ScrollView 使用详解
- Json序列化框架之Gson Api详解
- Codeforces Round #409 (Div. 2) ABCDE
- ViewPager 中设置图片大小不起作用
- Flask-WTF 示例
- 接口中数据流的格式发送请求和解析流请求
- 史上最全的maven的pom.xml文件详解
- 10个大坑,当你产品上架AppStore会遇到
- Add Two Numbers II
- zookeeper技术浅析
- ZZULIOJ 2126
- 动态规划练习02:最大子矩阵
- SICP 1.6
- redis启动命令