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

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Hacker News: Front Page
S
Security Affairs
Google Online Security Blog
Google Online Security Blog
Attack and Defense Labs
Attack and Defense Labs
H
Heimdal Security Blog
S
Securelist
S
Secure Thoughts
N
News and Events Feed by Topic
T
The Exploit Database - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Last Week in AI
Last Week in AI
The Last Watchdog
The Last Watchdog
N
News | PayPal Newsroom
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
宝玉的分享
宝玉的分享
有赞技术团队
有赞技术团队
O
OpenAI News
V
Vulnerabilities – Threatpost
S
Schneier on Security
Cyberwarzone
Cyberwarzone
雷峰网
雷峰网
罗磊的独立博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
J
Java Code Geeks
Google DeepMind News
Google DeepMind News
The Cloudflare Blog
美团技术团队
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
T
Tor Project blog
P
Privacy International News Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
S
Security @ Cisco Blogs
Project Zero
Project Zero
Security Archives - TechRepublic
Security Archives - TechRepublic
Schneier on Security
Schneier on Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
K
Kaspersky official blog
P
Privacy & Cybersecurity Law Blog
aimingoo的专栏
aimingoo的专栏
L
LINUX DO - 热门话题
V
V2EX
Blog — PlanetScale
Blog — PlanetScale
www.infosecurity-magazine.com
www.infosecurity-magazine.com
U
Unit 42

博客园 - 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()    收藏  举报