Spring ServletEndpointSupport整合Axis

本文探讨了如何在Spring框架下集成WebService,并重点介绍了如何在ServiceImpl中注入Spring Bean的问题。通过分析发现,要实现这一目标,客户端和服务端需要运行在同一Web应用上下文中。文章还讨论了解决方案,以确保从客户端调用WebService时能成功获取到Spring容器中的Bean。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用Spring开发Axis web service服务器端

(那一套都是自动生成的,Locator,Service,ServiceImpl,Stub,Skeleton等等)

现需要在ServiceImpl中添加自己的逻辑,并且需要Spring中的Bean

我是使Skeleton继承了ServletEndpointSupport去获得Bean,在客户端调用(另一项目组)时发现获取不到Bean

但是如果自己使用Spring的ApplicationContext能够加载到(自己写了个main方法进行模拟客户端测试就能够获取)

Spring-references.pdf中有文字如下:

Our AccountServletEndpoint needs to run in the same web application as the Spring context to allow for
access to Spring's facilities. In case of Axis, copy the AxisServlet definition into your 'web.xml', and set up
the endpoint in 'server-config.wsdd' (or use the deploy tool). See the sample application JPetStore where the
OrderService is exposed as a web service using Axis.

我得理解是:只有调用该服务的客户端跟服务器端是跑在同一个上下文中才能使用Spring那一套东西。

真实情况是这样么?如果是那是不是有点太悲剧了,大部分客户端和服务器端还是不在同一个context中的吧?

怎样保证由客户端发起的web service调用能够获取到Spring容器中的Bean呢?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值