基于Spring IoC容器发布Web服务,能够大大降低WebService实现过程,也能够更好的与企业级应用进行整合,
本文將和大家介绍如何基于Spring和JAX-WS发布WebService。
1.新建Web服务接口和实现类
@WebService
public interface IUserWebService {
public User queryUserById(@WebParam(name = "userId") Integer userId);
public User addUser(User user);
}
@Component
@WebService(serviceName = "UserWebService", endpointInterface = "cn.webservice.IUserWebService")
public class UserWebServiceImpl implements IUserWebService {
public User queryUserById(Integer userId) {
User user=new User();
user.setUserId(userId);
user.setName("张三");
return user;
}
public User addUser(User user) {
user.setUserId(200);
return user;
}
}
2.在web.xml文件中添加spring的监听器配置
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/application*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
3.发布
<?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:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<context:component-scan base-package="cn"></context:component-scan>
<bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
<property name="baseAddress" value="http://localhost:8080/services/"/>
</bean>
</beans>
分享到:
相关推荐
jax-ws与spring整合时需要添加两个jar包,即jaxws-spring-1.8.jar和xbean-spring-3.6.jar
JAX-WS + Spring 实现webService示例.docxJAX-WS + Spring 实现webService示例.docx
JAX-WS + Spring 实现webService示例
webservice jax-ws-spring 视频
这是我学习Spring3.2.8 JAX-WS时候做的基于注解的一个联系程序,使用Tomcat6测试通过了,用SOAPUI做的访问测试,希望可以帮助初次学习者部分的朋友理清思路。
使用jax-ws和jax-rs ,maven、java、spring 分别创建soap类型的webservice和restful类型的webservice,文档附有代码
jax-ws 与 spring 整合的简单例子:详情请查看http://poshidi.com/jax-ws-spring
自己写的spring+jax-ws+手写的连接池,然后webService接口传参传入有复杂的List传参(非JSON)
春天 使用 Apache CXF 和 Spring Framework 的 WebService(JAX-WS 和 JAX-RS) Apache CXF: : Spring 框架: : 我想分享有关使用 Spring Framework 的 Web 服务的更多信息。
webservice详细例子,详细请看: jax-ws 与 spring的整合(下) http://poshidi.com/jax-ws-spring2
不用说了,自己整理的。绝对实用,错过了是你的错
是一个开源的一个webservice,可以与spring无缝集成。支持soap1.1、1.2、RESTtful或者CORBA。 ##使用CXF实现jax-ws规范的webservice 服务端: 1、创建java工程,把cxf的jar包导入工程中 2、编写SEI,在SEI上添加@...
这个小实例有server和client的代码,server直接用myeclipse导入,然后添加spring2.0 aop和core,xfire1.2即可.client也是直接导入项目,然后导入jax-ws2.1api和jax-ws2.1 runtime libraries即可.这些包通过点击项目...
有大量简单的 API 用来快速地构建代码优先的 Services,各种 Maven 的插件也使集成更加容易,支持 JAX-WS API ,支持 Spring 2.0 更加简化的 XML 配置方式,等等。 4. 支持二进制和遗留协议:CXF 的设计是一种可插...
ssh rest ws jax-rs jersey 做的小网站后台及web service接口用到了kindeditor编辑器 goouploader控件 代码完整,有sql代码。
这个教程将了如何使用CXF开发WebService,包括JAX-WS、JAX-RS规范、数字证书、MTOM附件传输、异步调用、异常处理、使用Axis+Spring解决RPC/Encode的问题向旧规范JAX-RPC的兼容,第三版版教程在最一开始分别介绍了...
JAVA EE 和 JAX-WS 将是一个不错的选择,但我决定坚持使用 Spring WS 和 Spring Boot 作为超级胶水。 作业涵盖了以下主题: 创建两个端点,根据简单过滤返回查询结果列表 使用 WS-Security 进行基本身份验证 按照...
最近研究了一下spring webservice整合,由于第一次做这个,整合期间遇到了不少问题,在网上查找了好久也没找到完整实现的server和client的demo,有的问题折腾了我好几天,看到spring的官网里面有人提相同的问题,...
从流行的汲取灵感,继承了一个完全更改的示例WebService-Definition作为WSDL 展示如何在构建时使用JAX-WS Commons Maven插件从WSDL生成JAXB类-只需运行 mvn clean generate-sources 首先使用SpringBoot,CXF和...
最近研究了一下spring webservice整合,由于第一次做这个,整合期间遇到了不少问题,在网上查找了好久也没找到完整实现的server和client的demo,有的问题折腾了我好几天,看到spring的官网里面有人提相同的问题,...