文档章节

webservice 之 Java CXF实战效果 RS WS(一)

z201
 z201
发布于 2017/05/14 17:24
字数 2243
阅读 46
收藏 0
  1. 这里是列表文本直入正题:关于CXF自行百度。 这里是列表文本发布两种 WS 和 RS 实现效果如下:

输入图片说明

源码:https://git.oschina.net/Z201/SSJH/tree/master/ssh-webservice 里面有些其它项目 不用担心 直接构建就行了。

<properties>
		<!-- 项目框架组合版本号 -->
		<java-version>1.8</java-version>
		<javax.el-api.version>3.0.0</javax.el-api.version>
		<javax.servlet-api.version>3.0.1</javax.servlet-api.version>
		<spring.version>4.2.5.RELEASE</spring.version>
		<org.springframework.data.version>1.7.2.RELEASE</org.springframework.data.version>
		<!-- 页面模板引擎ibeetl -->
		<com.ibeetl.version>2.4.1</com.ibeetl.version>
		<!-- LOG框架 -->
		<org.log4j2.version>2.8.1</org.log4j2.version>
		<!-- jackson框架 组合-->
		<com.fasterxml.jackson.version>2.8.1</com.fasterxml.jackson.version>
		<net.sf.json-lib.version>2.4</net.sf.json-lib.version>
		<!-- MYSQL 数据库驱动 -->
		<mysql.driver.version>5.1.28</mysql.driver.version>
		<!-- springfox-swagger -->
		<springfox-swagger.version>2.2.2</springfox-swagger.version>
		<!-- 嵌入数据库 H2 -->
		<h2.database.version>1.4.182</h2.database.version>
		<!-- JBOSS ORM  组合套装 -->
		<org.hibernate.version>4.3.11.Final</org.hibernate.version>
		<hibernate-commons-annotation.version>5.0.1.Final</hibernate-commons-annotation.version>
		<hibernate-jpa-2.1-api.version>1.0.0.Final</hibernate-jpa-2.1-api.version>
		<hibernate.validator.version>5.2.1.Final</hibernate.validator.version>
		<!-- 阿里巴巴 Druid连接 -->
		<alibaba.druid.version>1.0.17</alibaba.druid.version>
		<!-- Quartz 任务调度 -->
		<org.quartz.version>2.2.2</org.quartz.version>
		<!-- AOP 组合-->
		<org.aspectj.version>1.8.8</org.aspectj.version>
		<cglib.nodep.version>3.1</cglib.nodep.version>
		<!-- 上传组件 -->
		<apache.commons.fileupload>1.3.1</apache.commons.fileupload>
		<!--  lang3-->
		<apache.commons.lang3>3.4</apache.commons.lang3>
		<!--  io-->
		<apache.commons.io>2.4</apache.commons.io>
		<!--  collections-->
		<apache.commons.collections>3.2.1</apache.commons.collections>
		<!-- lombok 语法糖 -->
		<projectlombok.version>1.16.8</projectlombok.version>
		<!-- shiro 权限 -->
		<shiro.version>1.2.4</shiro.version>
		<!-- 单元测试 -->
		<junit.version>4.10</junit.version>
		<!-- Apache CXF RS WS 实现 -->
        <cxf.version>3.1.7</cxf.version>
        <!-- ActiveMQ MOM中间件-->
		<activemq.version>5.13.3</activemq.version>
		<!-- 指定Maven编译项目编译格式 -->
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

里面的东西比较多 个人测试的时候其它的子项目也需要管理版本。

<properties>
        <oauth2.version>1.0.0</oauth2.version>
		<!-- 指定Maven编译项目编译格式 -->
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.cn.z201.core</groupId>
			<artifactId>ssh-core</artifactId>
			<version>${project.version}</version>
		</dependency>
		<!-- Spring 4.* -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${spring.version}</version>
			<exclusions>
				<!-- 排除通用日志 改支持SLF4j -->
				<exclusion>
					<groupId>commons-logging</groupId>
					<artifactId>commons-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${spring.version}</version>
			<exclusions>
				<!-- 排除通用日志 改支持SLF4j -->
				<exclusion>
					<groupId>commons-logging</groupId>
					<artifactId>commons-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-test</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-websocket</artifactId> 
				<version>${spring.version}</version>
		</dependency>
		<dependency>
			    <groupId>org.springframework</groupId> 
				<artifactId>spring-web</artifactId>
				<version>${spring.version}</version>
		</dependency>
		<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-webmvc</artifactId>
				<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context-support</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aop</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<!-- spring data jpa -->
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-jpa</artifactId>
			<version>${org.springframework.data.version}</version>
		</dependency>
		<!-- hibernate 4.* -->
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-osgi</artifactId>
			<version>${org.hibernate.version}</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-envers</artifactId>
			<version>${org.hibernate.version}</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-infinispan</artifactId>
			<version>${org.hibernate.version}</version>
			<exclusions>
				<exclusion>
					<artifactId>jboss-transaction-api_1.1_spec</artifactId>
					<groupId>org.jboss.spec.javax.transaction</groupId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.hibernate.common</groupId>
			<artifactId>hibernate-commons-annotations</artifactId>
			<version>${hibernate-commons-annotation.version}</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate.javax.persistence</groupId>
			<artifactId>hibernate-jpa-2.1-api</artifactId>
			<version>${hibernate-jpa-2.1-api.version}</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-validator</artifactId>
			<version>${hibernate.validator.version}</version>
		</dependency>
		<!-- hibernate 依赖包 end -->
		<!-- 增强 AOP -->
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjweaver</artifactId>
			<version>${org.aspectj.version}</version>
		</dependency>
		<dependency>
			<groupId>org.aspectj</groupId>
			<artifactId>aspectjrt</artifactId>
			<version>${org.aspectj.version}</version>
		</dependency>
		<!-- AOP end-->
		<!-- 代理 -->
		<dependency>
			<groupId>cglib</groupId>
			<artifactId>cglib-nodep</artifactId>
			<version>${cglib.nodep.version}</version>
		</dependency>
		<!-- Druid -->
		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>druid</artifactId>
			<version>${alibaba.druid.version}</version>
		</dependency>
		<!-- mysql driver -->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>${mysql.driver.version}</version>
		</dependency>
		<!-- 这才是主角 -->
		<dependency>
		   <groupId>javax.ws.rs</groupId>
		   <artifactId>jsr311-api</artifactId>
		   <version>1.1.1</version>
	    </dependency>
	 	 <!-- CXF RS 核心包 -->
	    <dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-jaxrs</artifactId>
			<version>${cxf.version}</version>
	    </dependency>
	    <!-- cxf rs 扩展 -->
	    <dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-rs-extension-providers</artifactId>
			<version>${cxf.version}</version>
	    </dependency>
	    <!-- rs cors认证 -->
	    <dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-rs-security-cors</artifactId>
			<version>${cxf.version}</version>
	    </dependency>
	    <!-- swagger API文档生成 -->
	    <dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-rs-service-description-swagger</artifactId>
			<version>${cxf.version}</version>
	    </dependency>
	    <!-- RESTful WADL生成 -->
	    <dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-rs-service-description</artifactId>
			<version>${cxf.version}</version>
	    </dependency>
	    <!-- CXF WS 核心包 -->
	    <dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-jaxws</artifactId>
			<version>${cxf.version}</version>
	    </dependency>
	    <!-- CXF WS 安全管理 -->
	    <dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-ws-security </artifactId>
			<version>${cxf.version}</version>
	    </dependency>
	    <!-- CXF HTTP传输 -->
	    <dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-transports-http</artifactId>
			<version>${cxf.version}</version>
	    </dependency>
	    <!-- cxf HTTP传输 jetty支持 -->
	    <dependency>
		   <groupId>org.apache.cxf</groupId>
		   <artifactId>cxf-rt-transports-http-jetty</artifactId>
		   <version>${cxf.version}</version>
	    </dependency>
	    <!-- cxf 依赖包 end -->
	    <!-- oltu 依赖包 begin -->
		<dependency>
			<groupId>org.apache.oltu.oauth2</groupId>
			<artifactId>org.apache.oltu.oauth2.client</artifactId>
			<version>${oauth2.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.oltu.oauth2</groupId>
			<artifactId>org.apache.oltu.oauth2.common</artifactId>
			<version>${oauth2.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.oltu.oauth2</groupId>
			<artifactId>org.apache.oltu.oauth2.authzserver</artifactId>
			<version>${oauth2.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.oltu.oauth2</groupId>
			<artifactId>org.apache.oltu.oauth2.resourceserver</artifactId>
			<version>${oauth2.version}</version>
		</dependency>
		<!-- oltu 依赖包 end -->
	</dependencies>

上面是依赖

applicationContext.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> 
 
	<description>Spring Configuration</description>
	<!--  
	<aop:aspectj-autoproxy proxy-target-class="true" />
	 -->
	<!-- 如果配置了
		<context:component-scan>那么<context:annotation-config/>标签就可以不用再xml中配置了,因为前者包含了后者
	-->
	<context:component-scan base-package="cn.z201" />
	<!-- 配置  cxf配置文件 -->
	<import resource="classpath*:/apache-cxf/cxf-config.xml" />
	<import resource="classpath*:/apache-cxf/cxf-restful.xml" />
	<import resource="classpath*:/apache-cxf/cxf-soap.xml" />
	<!-- 配置数据源基础信息 -->
	<context:property-placeholder location="classpath*:/db.properties" />
	
	<!-- 生产数据源 mysql 
	<import resource="classpath*:/dataSource/dataSource-mysql.xml" />
	 -->
	<!-- 测试数据源 h2  -->
	<import resource="classpath*:/dataSource/dataSource-h2.xml" />
	
</beans>

dataSource-h2.xml 测试数据源:

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jpa="http://www.springframework.org/schema/data/jpa"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:jdbc="http://www.springframework.org/schema/jdbc"
	xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
      
     <!-- for tests is used memory database (H2) -->
	<jdbc:embedded-database id="datasource" type="H2" />
	<!-- 配置EntityManagerFactory -->
	<bean id="entityManagerFactory"
		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="persistenceUnitName" value="core" />
		<property name="dataSource" ref="datasource" />
		<!-- persistence管理实体
			 <property name="persistenceUnitName" value="ZENG"></property> 
			 <property name="persistenceXmlLocation" value="META-INF/persistence.xml"></property> -->
		<!-- 配置JPA提供商的适配器 ,可以通过内部bean的方式来配置 -->
		<property name="jpaVendorAdapter">
			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"></bean>
		</property>
		<property name="packagesToScan" value="cn.z201.entities" />
		<!-- 配置JPA的基本属性,例如JPA 实现产品的属性 -->
		<property name="jpaProperties">
			<props>
				<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
				<!-- 在控制台显示SQL语句 -->
				<prop key="hibernate.show_sql">true</prop>
				<!-- 格式化SQL语句显示 -->
				<prop key="hibernate.format_sql">true</prop>
				<!-- 全部使用注解,所以禁止Hibernate HBM 此时只搜索class文件 -->
				<prop key="hibernate.archive.autodetection">class</prop>
				<!-- 方言 -->
				<prop key="hibernate.dialect">${hibernate.h2.dialect}</prop> 
				<prop key="hibernate.jdbc.fetch_size">50</prop>
				<prop key="hibernate.jdbc.batch_size">25</prop>
				<!-- 指定事务隔离级别 2.读以提交数据 -->
				<prop key="connection.isolation">2</prop>
				<!-- 避免createClob() method threw error -->
				<prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
				<prop key="hibernate.current_session_context_class">thread</prop>
			</props>
		</property>
	</bean> 

	<!-- 配置Spring Data JPA扫描目录 -->
	<jpa:repositories base-package="cn.z201.entities"
		entity-manager-factory-ref="entityManagerFactory"
		transaction-manager-ref="transactionManager">
	</jpa:repositories>

	<!-- 配置事务管理器 -->
	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
		<property name="entityManagerFactory" ref="entityManagerFactory" />
	</bean>

	<!-- 启用 annotation事务 -->
	<tx:annotation-driven transaction-manager="transactionManager"
		proxy-target-class="false" />
      
      
</beans>

cxf 的配置文件 cxf-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:soap="http://cxf.apache.org/bindings/soap"
	xmlns:core="http://cxf.apache.org/core"
	xmlns:jaxrs="http://cxf.apache.org/jaxrs"
	xmlns:jaxws="http://cxf.apache.org/jaxws"
	xsi:schemaLocation="http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
		http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
		http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
		http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd">

	<import resource="classpath:META-INF/cxf/cxf.xml" />

	<bean id="inMessageInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor" />
	<bean id="outMessageInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
	<bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor" />
	<bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
	
	<!-- 亦可在 jaxrs:server 内配置jaxrs:inInterceptors 拦截器,如下边注释掉的 -->
	<bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus">
		<property name="inInterceptors">
			<list>
				<ref bean="logInbound" />
			</list>
		</property>
		<property name="outInterceptors">
			<list>
				<ref bean="logOutbound" />
			</list>
		</property>
		<property name="outFaultInterceptors">
			<list>
				<ref bean="logOutbound" />
			</list>
		</property>
		<property name="inFaultInterceptors">
			<list>
				<ref bean="logInbound" />
			</list>
		</property>
	</bean>
	
	<!--  CORS认证
	<bean id="corsFilter" class="org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter">
        <property name="allowOrigins" value="http://localhost"/>
    </bean>
	 -->
	 
</beans>

cxf-restful.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:core="http://cxf.apache.org/core"
	xmlns:jaxrs="http://cxf.apache.org/jaxrs"
	xsi:schemaLocation="http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
		http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
	
	<jaxrs:server  address="/restful/v1/userInfo" serviceName="userInfoRestful"  >
		<jaxrs:serviceBeans>
			<ref bean="userInfoRestfulImpl"  />
		</jaxrs:serviceBeans>
		<jaxrs:providers>
			<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" />
			<!-- 认证拦截器 
			<ref bean="authFilter"/>
			-->
		</jaxrs:providers>
		<jaxrs:extensionMappings>  
            <entry key="json" value="application/json" />  
            <entry key="xml" value="application/xml" />  
        </jaxrs:extensionMappings> 
		<jaxrs:languageMappings>
			<entry key="en" value="en-gb" />
		</jaxrs:languageMappings>
	</jaxrs:server>
	
	<jaxrs:server  address="/restful/v1/example" serviceName="exampleRestful"  >
		<jaxrs:serviceBeans>
			<ref bean="exampleRestfulImpl"  />
		</jaxrs:serviceBeans>
		<jaxrs:providers>
			<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" />
		</jaxrs:providers>
		<jaxrs:extensionMappings>  
            <entry key="json" value="application/json" />  
            <entry key="xml" value="application/xml" />  
        </jaxrs:extensionMappings> 
		<jaxrs:languageMappings>
			<entry key="en" value="en-gb" />
		</jaxrs:languageMappings>
	</jaxrs:server>
	
	 
</beans>

cxf-soap.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:core="http://cxf.apache.org/core"
	xmlns:soap="http://cxf.apache.org/bindings/soap"
	xmlns:jaxws="http://cxf.apache.org/jaxws"
	xsi:schemaLocation="http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
		http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
		http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd">
	
	<!-- 这里如果不指定serviceClass 将看不到返回xml信息 -->
	<jaxws:server address="/soap/v1" serviceClass="cn.z201.soap.UserInfoSoap">
		<jaxws:serviceBean>	
			<ref bean="userInfoSoapImpl"/>
		</jaxws:serviceBean>
	</jaxws:server>
	 
</beans>

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_3_0.xsd"
	version="3.0">
	<display-name>Archetype Created Web Application</display-name>
	<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>webapp.root</param-value>
	</context-param>
		<!-- 自定义拦截器,用户静态文件缓存以及调试信息显示。 -->
	<filter>
		<filter-name>filter</filter-name>
		<filter-class>cn.z201.filter.HttpFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>filter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<!-- 字符集处理 -->
	<filter>
		<filter-name>CharacterEncodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>utf-8</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>CharacterEncodingFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<!--添加监听 --> 
	<listener>
		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
	</listener>
	<!-- spring 配置 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:/applicationContext.xml
        </param-value>
	</context-param>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<!-- 配置缓存清除监听器,负责处理由 JavaBean Introspector 功能而引起的缓存泄露 -->
	<listener>
		<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
	</listener>
	
	<!-- CXF begin -->
    <servlet>
        <servlet-name>CXFServlet</servlet-name>
        <servlet-class>
              org.apache.cxf.transport.servlet.CXFServlet
        </servlet-class>
        <!-- 开启异步请求 -->
		<async-supported>true</async-supported>
    </servlet>
    <servlet-mapping>
        <servlet-name>CXFServlet</servlet-name>
        <url-pattern>/api/*</url-pattern>
    </servlet-mapping>
	<!-- CXF end -->
	
	<!-- 启用Web监控统计功能 通过 http://ip:port/druid/ 地址访问即可-->
	 <servlet>
     	 <servlet-name>DruidStatView</servlet-name>
     	 <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
     	 <init-param>
			<!-- 只允许本地ip访问。 -->
			<param-name>allow</param-name>
			<param-value>127.0.0.1</param-value>
		</init-param>
  	</servlet>
	<servlet-mapping>
	      <servlet-name>DruidStatView</servlet-name>
	      <url-pattern>/druid/*</url-pattern>
	</servlet-mapping>
	
	<!-- session timeout -->
	<session-config>
		<!-- 分钟 -->
		<session-timeout>0</session-timeout>
	</session-config>
	
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
	</welcome-file-list> 
</web-app>

© 著作权归作者所有

z201
粉丝 13
博文 36
码字总数 27735
作品 0
杭州
后端工程师
私信 提问
使用cxf发布webservice总结

一、概念 1、什么是webservice Web service是一个平台独立的,低耦合的,自包含的、基于可编程的web的应用程序,可使用开放的XML标准来描述、发布、发现、协调和配置这些应用程序,用于开发分...

漂泊者及其影子
2014/08/21
0
0
Apache CXF 和 Spring 开发 Web Service 1

正文 为什么使用CXF 本文段摘录自 http://www.ibm.com/developerworks/cn/webservices/ws-pojo-springcxf/index.html Apache CXF 是一个开放源代码框架,提供了用于方便地构建和开发 Web 服务...

洋葱94
2015/12/04
0
0
与Java Web Service相关的若干概念(JAX-WS,JAX-RS)

l JWS: 是指与webservice相关的J2EE(其实现在应该叫做Java EE吧)技术叫做 JWS(全称就是 java webservice)。没错,jws指的就是 javawebservice l Jws含有的技术 1. JAX-WS 2. JAX-RS 3. JAX...

豆豆4997
2014/04/09
0
0
SpringBoot | 第三十四章:CXF构建WebService服务

前言 上一章节,讲解了如何使用构建服务。其实,创建的方式有很多的,今天来看看如何使用来构建及调用服务。 一点知识 何为Apache-CXF 是一个开源的框架,帮助您利用编程 API 来构建和开发S...

oKong
2018/11/12
0
0
Joffice2中WebService的使用(CXF)

WebService基本概念 WSDL: http://www.w3cschool.cn/index-20.html SOAP: http://www.w3school.com.cn/soap/index.asp 2. 引入CXF依赖库 下载:http://cxf.apache.org/,解压至目录 加上依赖......

宏天_明汉
2012/08/06
0
0

没有更多内容

加载失败,请刷新页面

加载更多

佳博标签打印问题-

由于网页打印不行,要么sdk 写成activex,这样浏览器支持又有局限。 因此,采用客户端编写打印服务启动,定时轮询服务端打印队列,从服务的获取打印队列进行打印。 服务端web 点击打印,讲打...

mellen
20分钟前
2
0
Jmeter利用JMXMon插件监控服务器JVM情况

1、Jmeter下载JMXMon插件 2、Jmeter 添加 JMXMon请求 远程监控JVM状态需要在JVM启动时候加上一段参数才行,在tomcat bin目录下找到catalina.sh 在# OS specific support. $var _must_ be set...

覃光林
21分钟前
3
0
Qt编写安防视频监控系统(界面很漂亮)

一、前言 视频监控系统在整个安防领域,已经做到了烂大街的程序,全国起码几百家公司做过类似的系统,当然这一方面的需求量也是非常旺盛的,各种定制化的需求越来越多,尤其是这几年借着人脸...

飞扬青云
26分钟前
3
0
Python的requests库中的Put方式使用

1.后端接口 @PutMapping public ResponseEntity<MyObject> putMyObject( @RequestBody MyObject myObject) { ... } Put请求参数在请求体里面。 1.前端请求 import requestsimpo......

亚林瓜子
27分钟前
1
0
全站加速(DCDN)- IP应用加速产品解读

5月22日下午15点,阿里云全站加速(DCDN)-IP应用加速如期发布。IP应用加速是阿里云自主研发的一款更高效、更安全、更便捷的动态加速产品,结合阿里云CDN本身的资源优势,利用就近接入、智能...

迷你芊宝宝
31分钟前
3
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部