`
wangchengyong
  • 浏览: 24143 次
  • 性别: Icon_minigender_1
  • 来自: 安徽
文章分类
社区版块
存档分类
最新评论

CXF 客户端与服务器

阅读更多
apache-cxf-2.2.8 客户端与服务器

web容器为tomcat或jetty7

SessionCount.java
package com.mms.webservice.session;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class SessionCount implements HttpSessionListener {
	private static int count = 0;

	public void sessionCreated(HttpSessionEvent se) {
		count++;
		System.out.println("session创建:" + getCount() + new java.util.Date());
	}

	public void sessionDestroyed(HttpSessionEvent se) {
		count--;
		System.out.println("session销毁:" + getCount() + new java.util.Date());
	}

	public static int getCount() {
		return (count);
	}
}


web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:**/spring.xml</param-value>
	</context-param>

	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<servlet>
		<servlet-name>CXFServlet</servlet-name>
		<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
	</servlet>

	<servlet-mapping>
		<servlet-name>CXFServlet</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping>

	<listener>
		<listener-class>com.mms.webservice.test.SessionCount</listener-class>
	</listener>
	
</web-app>



HelloWorld源码在附件中,源码包含的东西为网上信息整理而来:
1.整合Spring的cxf配置
2.CXF密码验证_服务端和客户端配置
3.soap头信息添加和读取

源码引用的lib包需要下载apache-cxf-2.2.8.zip ,引用里面的lib
地址:http://cxf.apache.org/download.html

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics