惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
酷 壳 – CoolShell
酷 壳 – CoolShell
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
爱范儿
爱范儿
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
S
SegmentFault 最新的问题
博客园 - Franky
博客园_首页
T
Tailwind CSS Blog
雷峰网
雷峰网
罗磊的独立博客

博客园 - blueKnight

Java根据WSDL生成request的SOAP报文模板 【转】HttpClient使用Post和Get提交参数 Java解析Soap XML 【转】C++标准库和标准模板库 dotNetFrameWork 3.5SP1离线安装 笔记本电脑win7创建WIFI热点 【转】Oracle免客户端For .Net(增加分析Devart和DataDirect) 【转】ORA-00257 archiver error. 错误的处理方法 数学表达式与二叉树 FIREFOX不支持font-family: webdings;怎么办? "5","6"排序上下箭头问题 【转】Eclipse插件开发之基础篇(1) 插件开发的基础知识 http MIME大全 在iframe里的页面编写js,实现在父窗口上创建动画效果展开和收缩的div(不变动iframe父窗口代码) FreeMarker示例 转:用XML编写EXCEL文件 【网摘】BI系统(Business Intelligence) js获取周.html 关于j2ee工程发布到was上后,部分更新,例修改web.xml配置文件不起作用的原因解析 SSI(Struts2+Spring2+IBatis)代码生成器(纯Java版)
HttpClient示例
blueKnight · 2014-02-13 · via 博客园 - blueKnight
 1 <%@page import="com.sun.xml.ws.client.BindingProviderProperties"%>
 2 <%@page contentType="text/html;charset=UTF-8" language="java" %>
 3 <%@page import="java.util.*"%>
 4 <%@page import="java.io.*"%>
 5 <%@page import="org.apache.commons.httpclient.*"%>
 6 <%@page import="org.apache.commons.httpclient.methods.*"%>
 7 <%
 8 request.setCharacterEncoding("UTF-8");
 9 String url = request.getParameter("url")==null?"":request.getParameter("url");
10 String message = request.getParameter("message")==null?"":request.getParameter("message");
11 String result = "";
12 
13 try {
14     //call service
15     if(url!=null && !"".equals(url)) {
16         PostMethod postMethod = new PostMethod(url);
17           byte[] bytes = message.getBytes("UTF-8");
18           InputStream inputStream = new ByteArrayInputStream(bytes, 0,
19                   bytes.length);
20           RequestEntity requestEntity = new InputStreamRequestEntity(inputStream,
21                   bytes.length, "application/soap+xml; charset=utf-8");
22           postMethod.setRequestEntity(requestEntity);
23           //设置header
24             postMethod.setRequestHeader("OperationCode","com.mss.jt.cf.interfaces.SI_CF_YCHD_BALANCE_OUT_SynService");
25             postMethod.setRequestHeader("ClientId","com.mss.js.cf");
26             postMethod.setRequestHeader("TransactionId","B6B7B99D928B8581F92C4CBAEF3075F31508DB7F0BF856736A8AEBC25ADE69A0");
27             // 用户名密码:zpiappluser:zpiappl
28           postMethod.setRequestHeader("Authorization", " Basic "
29                 + (new sun.misc.BASE64Encoder()).encode("zpiappluser:zpiappl"
30                         .getBytes()));
31           HttpClient httpClient = new HttpClient();
32           
33           int statusCode = httpClient.executeMethod(postMethod);
34           bytes = postMethod.getResponseBody();
35           result = new String(bytes,"UTF-8");
36     }
37 }catch(Exception e) {
38     e.printStackTrace();
39     result= "异常:"+e.getMessage();
40 }
41 %>
42 <html>
43 <head>
44 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
45 <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
46 <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
47 <META HTTP-EQUIV="Expires" CONTENT="0">
48 </head>
49 <body>
50 <form id="form1" name="form1" method="POST" action="./test3.jsp">
51 url:<input type="text" name="url" style="width:600px" value="<%=(url!=null && !"".equals(url))?url:"http://132.228.26.15:29200/jt/wl/SDMS_ESB_INTEGRATION?wsdl"%>" ><p>
52 message:<textArea name="message"  cols="100" rows="5"><%=message%></textArea>
53 <p>
54 result:<textArea name="result" cols="100" rows="5"><%=result%></textArea>
55 <p>
56 <button type="button" onclick="javascript:return dosubmit();" >提交</button>
57 </form>
58 </body>
59 <script type="text/javascript">
60 <!--
61 function dosubmit() {
62     if(document.form1.url.value=="") {
63         alert("请输入url!");
64         document.form1.url.focus();
65         return;
66     }
67     document.form1.submit();
68 }
69 //-->
70 </script>
71 </html>

posted @ 2014-02-13 10:52  blueKnight  Views(8613)  Comments()    收藏  举报