[java]通过读文件内容发起http请求
来源:互联网 发布:js解析unicode 编辑:程序博客网 时间:2024/05/12 14:26
public static void main(String[] args) throws HttpException, IOException {
System.out.println("Response body: ");
//File input = new File("d://selectProtocol.xml");
File input = new File("d://insurance.xml");
PostMethod post = new PostMethod("http://localhost:7001/bib-pafa-esb/remoting/pafaESBRequest");
// 设置请求的内容直接从文件中读取
FileInputStream fi = new FileInputStream(input);
post.setRequestBody(new FileInputStream(input));
if (input.length() < Integer.MAX_VALUE)
post.setRequestContentLength(input.length());
else post.setRequestContentLength(EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED);
// 指定请求内容的类型
post.setRequestHeader("Content-type", "text/xml; charset=GBK");
HttpClient httpclient = new HttpClient();
int result = httpclient.executeMethod(post);
System.out.println("Response status code: " + result);
System.out.println("Response body: ");
System.out.println(post.getResponseBodyAsString());
post.releaseConnection();
}
- [java]通过读文件内容发起http请求
- java 发起HTTP请求
- Java发起Http请求
- Java发起http 请求
- java 发起http请求
- java发起http请求提交表单
- java 中使用POST发起http请求
- Java 发起http GET POST请求实例
- 使用http发起请求
- nginx发起http请求
- 发起Http请求
- java后台发起上传文件的post请求(http和https)
- java 发起http请求并获取结果(json)
- 如何在java中发起http和https请求
- 如何在java中发起http和https请求
- java发起http请求获取返回的Json对象
- JAVA发起Http和Https的POST/GET请求
- 如何在java中发起http和https请求
- 真情
- window.open与window.showModalDialog
- Google Map开发系列(一)——谷歌地图API密钥(API Key)的解读和使用技巧
- 邮箱自动登录批处理
- 过放电
- [java]通过读文件内容发起http请求
- 2010年十大移动互联网应用将火山爆发
- 牛刀:首次加息促使房价三个月内下降20%
- jQuery中文入门指南,翻译加实例,jQuery的起点教程
- 新的开始
- [JAVA]二进制,八进制,十六进制,十进制间进行相互转换
- Google Map开发系列(二)——使用谷歌地图API应该有所了解的一些技术外背景
- WCF中同步和异步通讯总结
- 使用DBMS存储过程 另外个版本