把cxf所有的包引进来就可以了。不需要另外引用spring的jar包。
用myeclipse 建立web project.这里贴SERVER端的实现代码
首先定义SEI:
package demo.sayhi.server;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
@WebService
public interface ISayHi {
@WebMethod
String HI(@WebParam(name="username") String text);
}
实现:
package demo.sayhi.server;
import javax.jws.WebService;
import javax.jws.WebMethod;
@WebService
public class SayHiImpl implements ISayHi{
@WebMethod
public String HI(String name)
{
return "HI,"+name;
}
WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.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>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
src/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:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean id="hi" class="demo.sayhi.server.SayHiImpl"></bean>
<jaxws:endpoint id="sayhi" implementor="#hi" address="/hi" >
<jaxws:inInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
</jaxws:outInterceptors>
<jaxws:inFaultInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
</jaxws:inFaultInterceptors>
<jaxws:outFaultInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
</jaxws:outFaultInterceptors>
</jaxws:endpoint>
</beans>
分享到:
相关推荐
spring+cxf_demo
基于maven的cxf+spring简单demo,spring版本为4.1.6,cxf版本为3.0.8
spring+cxf 入门demo 包括spring配置,web配置,代码实现,简单易懂
通过spring整合cxf2.7.7 的demo spring版本为3.1
NULL 博文链接:https://ynp.iteye.com/blog/888547
cxf spring maven 实例 webservice
SPRING-MVC-MQ-CXF-REST_Demo
cxf+spring3.1整合demo 能用
cxf spring server client demo.rar soap webservice
这个是cxf 集成spring 的webservice的例子 供大家参考
webserivce.、cxf整合spring,用的是spring3和cxf3。欢迎大家下载尝试
CXF WebService整合Spring示例工程代码demo可以直接导入eclipse。参照网页http://www.cnblogs.com/hoojo/archive/2011/03/30/1999563.html 完成的webService服务提供。 大致步骤: 1.引入cxf和其他需要的jar包,(本...
CXF Spring Web Service 程序,希望对大家有用!!
cxf+spring实现webservice
这是一个基于maven构建的java项目,整合了Apache CXF框架,实现restful风格的service
CXF2.5.0+Spring2.5 集成DEMO
webservice cxf spring整合返回list,bean,string,json,xml项目完整实例
spring4+cxf3,因为自己项目要用到接口开发,所以综合现有网上所有教程,终于成功写出能自动注入的demo
cxf+spring整合,只要把项目导入到myeclipse中,就可以运行。