服务器端代码:
- rundata.getModuleInfo().setLayoutTemplate(null);
- HttpServletRequest request = rundata.getRequest();
- HttpServletResponse response = rundata.getResponse();
- PrintWriter printWriter = null;
- ServletInputStream sis = null;
- String xmlData = null;
- try {
- printWriter = response.getWriter();
- // 取HTTP请求流
- sis = request.getInputStream();
- // 取HTTP请求流长度
- int size = request.getContentLength();
- // 用于缓存每次读取的数据
- byte[] buffer = new byte[size];
- // 用于存放结果的数组
- byte[] xmldataByte = new byte[size];
- int count = 0;
- int rbyte = 0;
- // 循环读取
- while (count < size) {
- // 每次实际读取长度存于rbyte中
- rbyte = sis.read(buffer);
- for(int i=0;i<rbyte;i++) {
- xmldataByte[count + i] = buffer[i];
- }
- count += rbyte;
- }
- xmlData = new String(xmldataByte, "UTF-8");
客户端代码:
- HttpClient httpClient = new HttpClient();
- String xmlData = getInput();
- int xmlDataLength = xmlData.getBytes("UTF-8").length;
- PostMethod method = new PostMethod(url);
- method.setRequestBody(xmlData);
- method.setRequestHeader("Content-type", "text/xml; charset=UTF-8");
- if (xmlDataLength < Integer.MAX_VALUE) {
- method.setRequestContentLength(xmlDataLength);
- } else {
- method.setRequestContentLength(EntityEnclosingMethod.CONTENT_LENGTH_CHUNKED);
- }
- try {
- int statusCode = httpClient.executeMethod(method);
- System.out.println("返回码: " + statusCode);
- if(statusCode != HttpStatus.SC_OK) {
- return;
- }
- System.out.println("输出:");
- System.out.println(method.getResponseBodyAsString());
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- method.releaseConnection();
- }
相关推荐
任何一个dwr.xml的文件都需要包含DWR DOCTYPE的声明行,格式如下: <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN" "http://www.getahead.ltd.uk/dwr/dwr10.dtd"> 整个配置文件的...
9.4 设计C/S通信数据格式 392 9.4.1 对象序列化 396 9.4.2 使用XML传输对象 401 9.5 小结 409 第10章 高级通信技术 410 10.1 电话 410 10.1.1 电话呼叫 410 10.1.2 监听电话状态 412 10.1.3 查询电话属性 416 10.1.4...
forward是服务器请求资源,服务器直接访问目标地址的URL,把那个URL的响应内容读取过来,然后把这些内容再发给浏览器,浏览器根本不知道服务器发送的内容是从哪儿来的,所以它的地址栏中还是原来的地址。 redirect...
The file struts-config.xml instructs ActionServlet on how to use the extended classes. There are several advantages to this approach: • The entire logical flow of the application is in a ...
forward是服务器请求资源,服务器直接访问目标地址的URL,把那个URL的响应内容读取过来,然后把这些内容再发给浏览器,浏览器根本不知道服务器发送的内容是从哪儿来的,所以它的地址栏中还是原来的地址。...
17、Java怎么读取文件和写入文件 65 18、java怎么复制文件 68 19、用JDBC如何调用存储过程 69 20、JDBC中的PreparedStatement相比Statement的好处 71 21、写一个用jdbc连接实例。 71 22、ArrayList和Vector的区别? ...
memberReaderClass 设定一个成员读取器,默认情况下 Hierarchy 都是从关系型数据库里读取的,如果你的数据不在 RDBMS 里面的话,你可以通过自定义一个 member reader 来表现一个 Hierarchy 。 3.5. Level 级别 , ...
3.2.2 使用json向服务器发送数据 64 3.3 小结 70 第4章 实现基本ajax技术 71 4.1 完成验证 71 4.2 读取响应首部 75 4.3 动态加载列表框 79 4.4 创建自动刷新页面 85 4.5 显示进度条 90 4.6 创建工具提示 95 ...
[阿里云OSS](project-bootstrap/aliyun-oss-post-callback.png) > zheng-api 服务网关,对外暴露统一规范的接口和包装响应结果,包括各个子系统的交互接口、对外开放接口、开发加密接口、接口文档等服务,可在该...
{1.4}数据类型}{23}{section.1.4} {1.4.1}整数与浮点数}{23}{subsection.1.4.1} {1.4.1.1}浮点数原理}{24}{subsubsection.1.4.1.1} {1.4.2}格式化输出浮点数}{24}{subsection.1.4.2} {1.4.3}\texttt {char}}{24...
Web Service存取服务:内嵌网页浏览器、Ajax网页特效、手机气象局、网络播放mp3、网络安装apk程序、远程下载手机铃声、XML-RPC移动博客发布器、手机RSS阅读器、地震速报、网页快照等。 完备的Google网络服务:Google...
Web Service存取服务:内嵌网页浏览器、Ajax网页特效、手机气象局、网络播放mp3、网络安装apk程序、远程下载手机铃声、XML-RPC移动博客发布器、手机RSS阅读器、地震速报、网页快照等。 完备的Google网络服务:Google...
Web Service存取服务:内嵌网页浏览器、Ajax网页特效、手机气象局、网络播放mp3、网络安装apk程序、远程下载手机铃声、XML-RPC移动博客发布器、手机RSS阅读器、地震速报、网页快照等。 完备的Google网络服务:Google...
Web Service存取服务:内嵌网页浏览器、Ajax网页特效、手机气象局、网络播放mp3、网络安装apk程序、远程下载手机铃声、XML-RPC移动博客发布器、手机RSS阅读器、地震速报、网页快照等。 完备的Google网络服务:Google...
2.2.1. 配置web.xml 2.2.2. 最小 <http> 配置 2.2.2.1. auto-config 包含了什么? 2.2.2.2. 表单和基本登录选项 2.2.3. 使用其他认证提供器 2.2.3.1. 添加一个密码编码器 2.3. 高级web特性 2.3.1. ...
2.2.1. 配置web.xml 2.2.2. 最小 配置 2.2.2.1. auto-config包含了什么? 2.2.2.2. 表单和基本登录选项 2.2.3. 使用其他认证提供器 2.2.3.1. 添加一个密码编码器 2.3. 高级web特性 2.3.1. Remember-Me认证 ...
2.2.1. 配置web.xml 2.2.2. 最小<http> 配置 2.2.2.1. auto-config 包含了什么? 2.2.2.2. 表单和基本登录选项 2.2.3. 使用其他认证提供器 2.2.3.1. 添加一个密码编码器 2.3. 高级web 特性 2.3.1. ...