- 浏览: 2262021 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (423)
- FileNet相关 (3)
- 应用服务器相关 (22)
- Java综合 (77)
- 持久层 (24)
- struts (11)
- webservice (8)
- 虚拟机 (2)
- 光盘刻录 (0)
- AD及AD集群 (1)
- JS (33)
- F5 (0)
- loadrunner8.1 (0)
- Java 反编译工具 (2)
- DataBase (62)
- ant (1)
- 操作系统 (29)
- 我的任务 (3)
- 平台架构 (16)
- 业务规则引擎 (2)
- 模板 (1)
- EJB (5)
- spring (24)
- CMMI (1)
- 项目管理 (20)
- LDAP (13)
- JMS (10)
- JSP (19)
- JBPM (2)
- web MVC框架设计思想 (2)
- 第三方支付平台 (2)
- BUG管理工具 (1)
- 垃圾站 (2)
- php (1)
- swing (1)
- 书籍 (1)
- QQ qq (2)
- 移动互联网 (26)
- 爱听的歌曲 (0)
- hadoop (4)
- 数据库 (9)
- 设计模式 (1)
- 面试经验只谈 (1)
- 大数据 (9)
- sp (1)
- 缓存数据库 (8)
- storm (2)
- taobao (2)
- 分布式,高并发,大型互联网,负载均衡 (6)
- Apache Ignite (0)
- Docker & K8S (0)
最新评论
-
wangyudong:
新版本 Wisdom RESTClienthttps://gi ...
spring rest mvc使用RestTemplate调用 -
wangyudong:
很多API doc生成工具生成API文档需要引入第三方依赖,重 ...
spring rest mvc使用RestTemplate调用 -
zhaoshijie:
cfying 写道大侠,还是加载了两次,怎么解决啊?求。QQ: ...
spring容器加载完毕做一件事情(利用ContextRefreshedEvent事件) -
xinglianxlxl:
对我有用,非常感谢
spring容器加载完毕做一件事情(利用ContextRefreshedEvent事件) -
k_caesar:
多谢,学习了
利用maven的resources、filter和profile实现不同环境使用不同配置文件
package bpmlog;
import java.io.BufferedInputStream;
下面是一个完整的 servlet,直接复制它既可以使用,只需要修改红色部分路径即可,
本例使用方法:在浏览器直接键入URL:即可展现日志,如下:http://localhost:8888/BPMDemo/BPMClientLogService?point=p1
代码:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class BPMClientLogService extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Constructor of the object.
*/
public BPMClientLogService() {
super();
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String point = request.getParameter("point");
String fileName = "\\bpm.log";
String filePath = "C:\\BPM_Logs\\"+point+fileName; if(point.equals("")){
errorHttpContent(response);
}else{
showLogContent(response,filePath);
}
}
private void errorHttpContent(HttpServletResponse response) throws IOException{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>BPMClientLogService</TITLE></HEAD>");
out.println(" <BODY>");
out.println(createTitle());
out.println(createBar());
out.println("Reason: did not find the relevant connection point!!!");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
private void showLogContent(HttpServletResponse response,String filePath) throws IOException{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>BPMClientLogService</TITLE></HEAD>");
out.println(" <BODY>");
//----------------------------------------------------------------------------------
out.println(createTitle());
out.println(createBar());
String httpContent = createHttpContent(filePath);
if(!httpContent.equals("")){
out.println(createHttpContent(filePath));
}else{
out.println("Reason: did not find the relevant connection point!!!");
}
//----------------------------------------------------------------------------------
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
private String createHttpContent(String filePathAndName) {
String httpContent = "";
InputStreamReader inr = null;
BufferedReader reader = null;
try {
File f = new File(filePathAndName);
if (f.isFile() && f.exists()) {
inr = new InputStreamReader(new FileInputStream(f), get_charset(f));
reader = new BufferedReader(inr);
String line;
while ((line = reader.readLine()) != null) {
if (line.startsWith("20")) {
httpContent += createLine();
httpContent += createLine(line);
} else {
httpContent += createLine(line);
}
}
}
} catch (Exception e) {
System.out.println("读取文件内容操作出错");
e.printStackTrace();
} finally {
close(reader, inr);
}
return httpContent;
}
private void close(BufferedReader reader, InputStreamReader inr) {
try {
if (reader != null)
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
if (inr != null)
inr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private String createLine(String content){
System.out.println("<h4>"+content+"</h4>");
return "<h4>"+content+"</h4>";
}
private String createLine(){
return "<br/><br/>";
}
private String createBar(){
return "<hr width='60%' size='10' align='center' color='#9900ff'/>";
}
private String createTitle() {
return "<h2 style='color: #9900ff;font-weight: 400;' align='center'>BPMPlatform client-side logging service ! ! !</h2>";
}
private String get_charset(File file) {
String charset = "GBK";
byte[] first3Bytes = new byte[3];
try {
boolean checked = false;
BufferedInputStream bis = new BufferedInputStream(
new FileInputStream(file));
bis.mark(0);
int read = bis.read(first3Bytes, 0, 3);
if (read == -1)
return charset;
if (first3Bytes[0] == (byte) 0xFF && first3Bytes[1] == (byte) 0xFE) {
charset = "UTF-16LE";
checked = true;
} else if (first3Bytes[0] == (byte) 0xFE
&& first3Bytes[1] == (byte) 0xFF) {
charset = "UTF-16BE";
checked = true;
} else if (first3Bytes[0] == (byte) 0xEF
&& first3Bytes[1] == (byte) 0xBB
&& first3Bytes[2] == (byte) 0xBF) {
charset = "UTF-8";
checked = true;
}
bis.reset();
if (!checked) {
int len = 0;
int loc = 0;
while ((read = bis.read()) != -1) {
loc++;
if (read >= 0xF0)
break;
if (0x80 <= read && read <= 0xBF) // 单独出现BF以下的,也算是GBK
break;
if (0xC0 <= read && read <= 0xDF) {
read = bis.read();
if (0x80 <= read && read <= 0xBF)// 双字节 (0xC0 - 0xDF)
// (0x80 -
// 0xBF),也可能在GB编码内
continue;
else
break;
} else if (0xE0 <= read && read <= 0xEF) {// 也有可能出错,但是几率较小
read = bis.read();
if (0x80 <= read && read <= 0xBF) {
read = bis.read();
if (0x80 <= read && read <= 0xBF) {
charset = "UTF-8";
break;
} else
break;
} else
break;
}
}
System.out.println(loc + " " + Integer.toHexString(read));
}
bis.close();
} catch (Exception e) {
e.printStackTrace();
}
return charset;
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
}
import java.io.BufferedInputStream;
下面是一个完整的 servlet,直接复制它既可以使用,只需要修改红色部分路径即可,
本例使用方法:在浏览器直接键入URL:即可展现日志,如下:http://localhost:8888/BPMDemo/BPMClientLogService?point=p1
代码:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class BPMClientLogService extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Constructor of the object.
*/
public BPMClientLogService() {
super();
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String point = request.getParameter("point");
String fileName = "\\bpm.log";
String filePath = "C:\\BPM_Logs\\"+point+fileName; if(point.equals("")){
errorHttpContent(response);
}else{
showLogContent(response,filePath);
}
}
private void errorHttpContent(HttpServletResponse response) throws IOException{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>BPMClientLogService</TITLE></HEAD>");
out.println(" <BODY>");
out.println(createTitle());
out.println(createBar());
out.println("Reason: did not find the relevant connection point!!!");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
private void showLogContent(HttpServletResponse response,String filePath) throws IOException{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>BPMClientLogService</TITLE></HEAD>");
out.println(" <BODY>");
//----------------------------------------------------------------------------------
out.println(createTitle());
out.println(createBar());
String httpContent = createHttpContent(filePath);
if(!httpContent.equals("")){
out.println(createHttpContent(filePath));
}else{
out.println("Reason: did not find the relevant connection point!!!");
}
//----------------------------------------------------------------------------------
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
private String createHttpContent(String filePathAndName) {
String httpContent = "";
InputStreamReader inr = null;
BufferedReader reader = null;
try {
File f = new File(filePathAndName);
if (f.isFile() && f.exists()) {
inr = new InputStreamReader(new FileInputStream(f), get_charset(f));
reader = new BufferedReader(inr);
String line;
while ((line = reader.readLine()) != null) {
if (line.startsWith("20")) {
httpContent += createLine();
httpContent += createLine(line);
} else {
httpContent += createLine(line);
}
}
}
} catch (Exception e) {
System.out.println("读取文件内容操作出错");
e.printStackTrace();
} finally {
close(reader, inr);
}
return httpContent;
}
private void close(BufferedReader reader, InputStreamReader inr) {
try {
if (reader != null)
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
if (inr != null)
inr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private String createLine(String content){
System.out.println("<h4>"+content+"</h4>");
return "<h4>"+content+"</h4>";
}
private String createLine(){
return "<br/><br/>";
}
private String createBar(){
return "<hr width='60%' size='10' align='center' color='#9900ff'/>";
}
private String createTitle() {
return "<h2 style='color: #9900ff;font-weight: 400;' align='center'>BPMPlatform client-side logging service ! ! !</h2>";
}
private String get_charset(File file) {
String charset = "GBK";
byte[] first3Bytes = new byte[3];
try {
boolean checked = false;
BufferedInputStream bis = new BufferedInputStream(
new FileInputStream(file));
bis.mark(0);
int read = bis.read(first3Bytes, 0, 3);
if (read == -1)
return charset;
if (first3Bytes[0] == (byte) 0xFF && first3Bytes[1] == (byte) 0xFE) {
charset = "UTF-16LE";
checked = true;
} else if (first3Bytes[0] == (byte) 0xFE
&& first3Bytes[1] == (byte) 0xFF) {
charset = "UTF-16BE";
checked = true;
} else if (first3Bytes[0] == (byte) 0xEF
&& first3Bytes[1] == (byte) 0xBB
&& first3Bytes[2] == (byte) 0xBF) {
charset = "UTF-8";
checked = true;
}
bis.reset();
if (!checked) {
int len = 0;
int loc = 0;
while ((read = bis.read()) != -1) {
loc++;
if (read >= 0xF0)
break;
if (0x80 <= read && read <= 0xBF) // 单独出现BF以下的,也算是GBK
break;
if (0xC0 <= read && read <= 0xDF) {
read = bis.read();
if (0x80 <= read && read <= 0xBF)// 双字节 (0xC0 - 0xDF)
// (0x80 -
// 0xBF),也可能在GB编码内
continue;
else
break;
} else if (0xE0 <= read && read <= 0xEF) {// 也有可能出错,但是几率较小
read = bis.read();
if (0x80 <= read && read <= 0xBF) {
read = bis.read();
if (0x80 <= read && read <= 0xBF) {
charset = "UTF-8";
break;
} else
break;
} else
break;
}
}
System.out.println(loc + " " + Integer.toHexString(read));
}
bis.close();
} catch (Exception e) {
e.printStackTrace();
}
return charset;
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
}
发表评论
-
各大巨头电商提供的IP库API接口-新浪、搜狐、阿里...
2015-04-22 13:18 15910关键字:各大巨头电商提供的IP库API接口-新浪、搜狐、阿里. ... -
用Java来获取访问者真实的IP地址-超准确
2015-04-22 12:55 6258关键字:用Java来获取访问者真实的IP地址-超准确 下面分享 ... -
Shiro集成OAuth2
2015-04-21 10:31 12445关键字:Shiro集成OAuth2 参考:http://jin ... -
淘宝网架构分享总结 - 架构,分布式,淘宝,虚拟化,水平伸缩
2015-04-19 00:25 7635推荐综合架构交流群:JAVA开发高级群 点击入群!!! 关键 ... -
Zookeeper 和 SASL
2015-04-16 09:29 13636关键字:Zookeeper 和 SASL 介绍 这是一个描述Z ... -
非对称加密(RSA)加密解密实现通信JAVA端工具类(教程)
2015-04-15 17:27 1184关键字:非对称加密(RSA)加密解密实现通信JAVA端工具类( ... -
对称加密(AES)加密实现工具类(教程)
2015-04-15 17:11 2146关键字:对称加密(AES)加密实现工具类(教程) Java加 ... -
Curator-Framework开源Zookeeper快速开发框架介绍
2015-04-14 18:41 703关键字:Curator-Framework开源Zookeepe ... -
IM消息推送之Openfire
2015-04-13 13:40 2213关键字:IM消息推送之Openfire Openfire 采用 ... -
Nio框架之Mina的demo
2015-04-12 13:38 644关键字:Nio框架之Mina的demo 官网:http://m ... -
AMQP中文版协议规范
2015-01-23 17:12 2989关键字:AMQP中文版协议规范 AMQP中文版协议规范:ht ... -
数据库连接池选型
2014-12-04 18:32 1171关键字:数据库连接池选型 proxool(与spring不太 ... -
spring中的数据源配置信息加密方案
2014-10-22 10:36 1077关键字:spring中的数据源配置信息加密方案 附件是完整的 ... -
OAuth2.0的Java实现 Apache Amber
2014-10-09 23:20 795关键字:OAuth2.0的Java实现 Apache Ambe ... -
企业信息管理系统基础框架jeesite
2014-05-06 22:21 2586jeesite项目地址(使用说明,):http://jeesi ... -
java中文分词组件-word分词
2014-05-06 21:33 21987关键字:java中文分词组 ... -
java制作可执行文件EXE文件
2014-05-05 18:58 1603关键字:java制作可执行文件EXE文件 参考:http: ... -
Quartz任务调度器详解
2014-04-25 22:46 19001关键字: 参考文章:ht ... -
各种hash算法-hashcodeUtil
2014-04-24 15:36 4247关键字:各种hash算法-hashcodeUtil -
性能监控工具类(StopWatchUtil)
2014-03-21 15:12 5748关键字:性能监控工具类(StopWatchUtil) 附 ...
相关推荐
WebService客户端调用WebService服务示例代码,java代码,纯手工,包括直接httpClient直接发送Saop报文调用和利用wsimport -keep 生成客户端代码后调用两种方式的示例。因涉及商务账户密码隐私,因此代码中的有些账号...
本教程将详细讲解如何构建一个简单的WebServie,包括加减乘除的基础运算,以及服务端、客户端的部署。 1. **WebServie概念与架构** - WebServie是一种服务导向架构,提供了一种标准化的方式,使得不同的系统能够...
服务器端实现处理来自客户端的请求,而客户端代理类则负责调用远程服务。 4. 开发Web服务客户端: - 创建服务代理:首先,我们需要获取服务的WSDL(Web Service Description Language)文件,该文件描述了服务的...
在这个例子中,文件`Eclipese中手动建立WebServie客户端.txt`可能包含了这些步骤的详细说明。 2. **导入生成的客户端类**:将生成的客户端代码添加到项目中,通常包括一个服务接口和一个实现类。 3. **调用Web服务**...
2. **创建WebServiceClient实例**:在Java项目中,可以通过创建`WebServiceClient`对象来实现与WebService服务器之间的通信。 - 示例代码: ```java WebServiceClient client = new WebServiceClient(); ``` 3....
2. **生成客户端代理**:大多数开发环境提供了工具自动生成客户端代理类,这些类封装了与服务交互的所有细节。例如,Java的wsimport命令,C#的Add Service Reference功能。 3. **编写调用代码**:通过客户端代理类...
2. 工作流程通常为:客户端发送一个SOAP请求到WebService服务器,服务器解析请求,执行相应的业务逻辑,然后返回一个SOAP响应给客户端。 二、主要技术组件 1. SOAP:作为数据交换的协议,SOAP定义了消息结构,使得...
增加下列类路径(以“;”间隔符)。 D:\axis\WEB-INF\lib\activation.jar; D:\axis\WEB-INF\lib\axis.jar; D:\axis\WEB-INF\lib\axis-ant.jar; D:\axis\WEB-INF\lib\axis-schema.jar; D:\axis\WEB-INF\lib\commons...
- 使用SOAP消息:客户端根据WSDL生成SOAP请求,发送给服务端,服务端解析请求,执行相应操作,然后返回SOAP响应。 - 使用RESTful风格:虽然不是传统的Web服务模型,但REST(Representational State Transfer)风格...
完成这些设置后,部署项目到Tomcat服务器,启动服务器,Web Service就会准备就绪。 接下来,我们要创建Web Service的客户端。这通常是一个独立的Java项目,可以是一个普通的Java应用程序。在客户端项目中,我们需要...
工作中应用的webservice服务,一直以来做webservie的客户端比较多,这次领导让做webservice的服务端,网上找了很多的方案,如axis,jws和cxf,比较了一下,觉得cxf的webservice的服务是最好的,所以搞了个demo,以供...
CXF支持JAX-RS,并提供了丰富的功能,如拦截器、提供者、客户端API等,使RESTful服务开发更加灵活和高效。 然后,**JAXB** 是一个核心的Java技术,用于将XML文档和Java对象之间的映射自动化。它允许我们通过注解...
4. **部署服务**:将服务部署到应用服务器,如Tomcat或Jetty,使其可以接收和响应来自客户端的请求。 5. **客户端调用**:客户端通过解析WSDL文件获取服务接口和调用方法,然后使用SOAP请求与服务端通信。 在提供...
SpringBoot内置了Tomcat服务器,并自动配置了许多Spring组件,减少了大量配置工作。 CXF是Apache项目中的一个开源服务框架,它支持多种Web服务标准,包括SOAP和RESTful API。CXF使得在SpringBoot应用中实现和调用...
在IT行业中,集成不同的系统和服务是一项常见的任务,而MAXIMO6作为一款资产管理和工作流程的软件,有时需要与...在实际开发中,还需注意错误处理、安全性以及性能优化等方面的问题,以确保服务调用的稳定性和高效性。
使用webservie所用到的jar包,方便使用webservice类
webservie发布所需要的包 @WebService public class JwsServiceHello { public String greeting(String name){ return "Welcome " + name; }
资源名称:WebServices基础培训视频与源码资源目录:【】1....使用xfire开发webServie操作不同的数据类型【】13.使用xfire与Spring整合开发webServie.part 资源太大,传百度网盘了,链接在附件中,有需要的同学自取。
winfrom 程序调用 webServie 中方法,有两种方法 WebServCaller.cs /* *调用示例: * Hashtable ht = new Hashtable(); * ht.Add("str", "test"); * ht.Add("b", "true"); * XmlDocument xx = WebSvcCaller....