SSM框架整合webservice

最近本人再用公司的框架开发软件,不幸的是需要用到webservice。然后苦逼的搞了一天,写个笔记方便以后复习

首先查看我的pox文件的jar包的引入



	
		
		
			junit
			junit
			4.11
			test
		

		

		
			joda-time
			joda-time
			2.1
		

		
			org.slf4j
			slf4j-api
			${slf4j.version}
		
		
			ch.qos.logback
			logback-core
			${logback.version}
		
		
			ch.qos.logback
			logback-classic
			${logback.version}
		

		
			org.aspectj
			aspectjweaver
			1.6.12
		
		
			org.aspectj
			aspectjrt
			1.6.11
		
		
			cglib
			cglib-nodep
			3.1
		
		
			org.springframework
			spring-webmvc
			3.2.8.RELEASE
		
		
			org.springframework
			spring-jdbc
			3.2.8.RELEASE
		
		
			org.mybatis
			mybatis
			3.2.7
		
		
			org.mybatis
			mybatis-spring
			1.2.2
		

		
			commons-dbcp
			commons-dbcp
			1.4
		

		
		
			mysql
			mysql-connector-java
			5.1.36
		

		
			javax.servlet
			servlet-api
			2.4
			provided
		
		
			javax.servlet
			jsp-api
			2.0
			provided
		
		
			javax.servlet
			jstl
			1.2
		

		
			com.fasterxml.jackson.core
			jackson-databind
			2.2.4
		
		
			com.fasterxml.jackson.core
			jackson-core
			2.2.4
		
		
			com.fasterxml.jackson.core
			jackson-annotations
			2.2.4
		

		
			com.google.guava
			guava
			11.0.1
		

		
			org.apache.commons
			commons-lang3
			3.3.2
		
		
			commons-io
			commons-io
			2.4
		
		
			commons-fileupload
			commons-fileupload
			1.3
		
		
			commons-codec
			commons-codec
			1.8
		
		
			commons-beanutils
			commons-beanutils
			1.9.2
		

		
			com.alibaba
			fastjson
			1.1.42
		

		
			org.apache.shiro
			shiro-core
			${shiro.version}
		
		
			org.apache.shiro
			shiro-spring
			${shiro.version}
		
		
			org.apache.shiro
			shiro-ehcache
			${shiro.version}
		

		
		
			commons-httpclient
			commons-httpclient
			3.1
		

		 
		
		
			org.apache.cxf
			cxf-rt-frontend-jaxws
			3.1.6
		 
		
		
			org.apache.cxf
			cxf-core
			3.1.6
		
		 
		
			org.apache.cxf
			cxf-rt-transports-http
			3.1.6
		


	

需要注意的是cxf会和spring的版本ch an生冲突

 

 

 

然后是web文件的配置



		springmvc
		org.springframework.web.servlet.DispatcherServlet
		
			contextConfigLocation
			classpath:conf/spring-*.xml
		
		1
	







	
		CXFServlet
		org.apache.cxf.transport.servlet.CXFServlet
	
	
		CXFServlet
		/webservice/*
	

 配置完web.xml文件之后需要将cxf配置到spring的bean中新建spring-webservice.xml



	
	
	
	
	
	
		
	

然后创建对应的cxf包再新建HelloWorld、HelloWorldImpl

package cn.liyu.cxf;

import javax.jws.WebService;

@WebService
public interface HelloWorld {
	public String say(String str);
}

HelloWorld的接口实现类 HelloWorldImpl

package cn.liyu.cxf.impl;

import javax.jws.WebService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import cn.liyu.cxf.HelloWorld;
@Component("helloWorld")
@WebService
public class HelloWorldImpl implements HelloWorld{
	private static Logger log=LoggerFactory.getLogger(new HelloWorldImpl().getClass());

	@Override
	public String say(String str) {
		log.debug(str);
		return "HELLO"+str;
	}

}

配置结束之后然后就可以启动项目

SSM框架整合webservice_第1张图片

然后就可以通过SoapUI测试了。

你可能感兴趣的:(webservice)