1. 新建一个web工程,并导入相关的lib
依赖jar文件:
axiom-api-1.2.7.jar
axis2-kernel-1.4.1.jar
jboss-backport-concurrent.jar
commons-httpclient-3.1.jar
commons-codec-1.3.jar
axiom-impl-1.2.7.jar
2.新建两个类HelloService和HelloServiceImpl
package com.pwp.webservice.service; import javax.jws.WebMethod; import javax.jws.WebService; /** * * @author Administrator */ @WebService public interface HelloService { @WebMethod String sayHi(String name); }
package com.pwp.webservice.service.impl; import com.pwp.webservice.service.HelloService; import javax.jws.WebService; /** * * @author Administrator */ @WebService(endpointInterface = "com.pwp.webservice.service.HelloService") public class HelloServiceImpl implements HelloService{ public String sayHi(String name) { return name+" hello~!"; } }
3.在web-inf目录新赠一个bean.xml内容如下
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.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-extension-jaxrs-binding.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> <jaxws:endpoint id="helloWorld" implementor="com.pwp.webservice.service.impl.HelloServiceImpl" address="/HelloWorld" /> </beans>
4.配置web.xml
<context-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/beans.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>/ws/*</url-pattern> </servlet-mapping>
相关推荐
springboot+cxf实现webservice示例 <groupId>org.springframework.boot <artifactId>spring-boot-starter <groupId>org.springframework.boot <artifactId>spring-boot-starter-web <!-- CXF ...
cxf组件 webservice示例代码
JAVA CXF webservice的示例代码 Eclipse工程
借鉴网上例子,弄了一个SpringBoot开发WebService之CXF示例。
readme下为开发文档。 1.集成 spring 2.集成 WSS4J 3.mtom 功能示例 4.基本数据类型service接口 示例 5.复杂数据类型service接口 示例
1. 发布和调用WebService: 使用CXF2.4(http://cxf.apache.org)和spring 2. 调用安全性: 使用简单的USERNAME_TOKEN 3. 服务程序中取得调用者身份 ------------------------- 接口 ------------------------- intf....
CXF框架开发WebService示例及说明
现在主流的webService框架,一个是axis2,一个是cxf,本资源是基于cxf框架的简单例子
Webservice入门教程_用CXF编写基于Spring的WebService示例代码
CXF构建WebService示例,具有一定的参考价值,可供学习
CXF WebService整合Spring示例工程代码demo可以直接导入eclipse。参照网页http://www.cnblogs.com/hoojo/archive/2011/03/30/1999563.html 完成的webService服务提供。 大致步骤: 1.引入cxf和其他需要的jar包,(本...
本实例工程使用Apache CXF组件快速开发WebService。基于Spring框架,使用了Maven项目,但由于时间原因,只使用了Maven Project的框架,还是使用lib文件夹存放所需的cxf库,传入传出对象支持Json格式。
基于CXF的WebService服务端和客户端示例,CXF+Spring,希望能为WebService开发者提供帮助。WebService,CXF,Spring.
完整可用的spring整合CXF示例项目,包括服务发布端和调用端两个项目,包括CXF拦截器的实现的简单的授权校验
cxf开发webservice客户端和服务器端,详细的cxf使用指令,有用的示例代码及注释。
webservice示例(cxf开发的例子),简单的例子。可以学学。
使用cxf wsdl2java生成webservice客户端命令
spring整合cxf实现restful的webservice服务,代码分为服务端和客户端两个模块;服务端为接口,客户端为接口调用。
cxf简单示例.chm,学习cxf,webservice