一. spring 与web service annotation 整合
先看一段代码
@WebService public class LoginDelegateWebService { @WebMethod public Technician login(String id,String pwd) throws Exception { return null; } }
spring 要与这个类整合起来,首先要在spring中注册这个LoginDelegateWebService类,暂时起名叫LoginDelegate, 接着就要新建另一个Web Service代理类来作为对外接口.
@WebService public class LoginWebService extends SpringBeanAutowiringSupport { public static String BEAN_ID = "LoginDelegate"; @Autowired @Qualifier("LoginDelegate") private ILoginDelegate springServ; @Resource private WebServiceContext wsContext; private void getSpringService() throws Exception { if(springServ ==null ) { //@Autowired does not work in JAX-WS web services on WebLogic server 10.3 //fall back to get the spring bean from WebApplicationContext ServletContext servletContext= (ServletContext)wsContext.getMessageContext().get(MessageContext.SERVLET_CONTEXT); WebApplicationContext webContext = WebApplicationContextUtils.getWebApplicationContext( servletContext ); springServ = (ILoginDelegate)webContext.getBean(BEAN_ID); if( springServ == null ) throw new Exception("Spring service not available: " + BEAN_ID); } } @WebMethod public Technician login(String id,String pwd) throws Exception { getSpringService(); return springServ.login( id,pwd ); } }
原先的LoginDelegateWebService 中的annotation要全部删除掉.至此,配置完成.
原理就是 这个LoginWebService是一个代理类,它接管了对外的接口,面LoginDelegatWebService这个类才是真正的业务处理类.所以之后我们可以对LoginDelegatWebService加一些AOP的操作,例如日志打印,程序监控,事务处理等等.
二.spring 与axis2整合
笔者使用的是AXIS2 1.6.2. 其实这个版本已经默认支持与SPRING整合.
只要我们在services.xml中作一下更改就好了.
<service name="tms/order" > <Description> Please Type your service description here </Description> <messageReceivers> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" /> <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/> </messageReceivers> <!-- <parameter name="ServiceClass" locked="false">com.test.TmsOrderServiceImpl</parameter> --> <!-- 把这里的定义改成spring 定义的名字 就可以了--> <parameter name= "SpringBeanName">test</parameter> </service>
test是com.test.TmsOrderServiceImpl这个类在spring中注册的名字
相关推荐
CXF WebService整合Spring示例工程代码demo可以直接导入eclipse。参照网页http://www.cnblogs.com/hoojo/archive/2011/03/30/1999563.html 完成的webService服务提供。 大致步骤: 1.引入cxf和其他需要的jar包,(本...
CXF WebService整合Spring 原项目,可运行
CXF_WebService整合Spring
Apache Cxf WebService整合Spring 处理Map、非javabean式的复合类等CXF无法自动转化的类型 CXF为服务器端和客户端添加自定义拦截器进行权限检查验证并且控制台打印日志
现在回想起以前webservice整合spring的时候,由于漏了不少jar 导致调用失败
CXF WebService整合Spring代码(包含服务,客户端两个工程 和 文档) 需要视频的话,留邮箱
webservice整合spring的使用,服务器端和客户端均有,jar包都在客户端,服务端自行添加,同时 还有AJAX请求webservcie的demo,包括在CXF上的账户密码拦截器的使用
webservice客户端,框架为CXF,整合spring
NULL 博文链接:https://angrycoder.iteye.com/blog/1433965
网上资料大多是只有spring+xfire 含有Hibernate的少 3.配置时候还遇到spring实现 客户端调用服务器端时候 注入失败 4.在服务器端向客户端做映射的时候失败 5.在服务器端获取非基本类转化问题
WebService的CXF整合Spring有源码和jar包
WebService小白学习 之 Spring整合CXF,添加拦截器。 博客学习地址:https://blog.csdn.net/qq_37902949/article/details/81262826
webservice xfire整合spring(webservice配置采用注解),demo包含xfire 与spring整合的配置,客户端和服务端的代码,及jar包
在网上找了很久的资料,接口已经跟客户对接,特编写了代码文档和附带jar包,并含其他网站的参考地址,注意jdk环境要1.6或以上版本
spring.net整合webservice
webservice cxf spring整合返回list,bean,string,json,xml项目完整实例
Axis2WebService与Spring的整合
WebService客户端如何整合Spring
自己写给同事培训的xfire整合spring的小项目 步骤清晰 简单易懂 适合刚刚接触xfire的同事们
cxf开发webservice与spring整合所需jar包