【问题标题】:Spring does not autowire beans with JAX-WS webservice end pointsSpring 不使用 JAX-WS Web 服务端点自动装配 bean
【发布时间】:2012-04-11 17:18:07
【问题描述】:

我正在尝试使用我编写的 JAX-WS 网络服务。我总是得到nullPointerException 用于spring autowired 注释bean。然而,在 serverSide over web 中一切正常,但通过 JAX-WS webservice 访问 bean。

我已经尝试扩展SpringBeanAutowiringSupport,但仍然没有运气。我该怎么做。

问候,罗希特

【问题讨论】:

  • 在自动装配时,您的 webService 类中是否有空对象?或者您为 web 服务获取 null,在其他地方自动连接?

标签: spring jax-ws autowired


【解决方案1】:

我没有扩展 SpringBeanAutowiringSupport 的经验,但成功地使用了这种方法:

  1. 这样注释webService类:

    @Component("yourWebService")  
    @WebService(endpointInterface ="your.package.YourServicePort")
    
  2. 为 webService 创建新的 spring-context xml 并定义 JAX-WS 端点:

    <jaxws:endpoint
        id="yourServiceEndpoint"
        implementor="#yourWebService"
        address="${yourWebService.wsdl.url}"> //load url from properties file
    </jaxws:endpoint>       
    
  3. 我想你知道如何在 spring 中使用 props,但会解释一下以防万一。您还应该创建 yourWebService.properties 文件并在 spring 上下文中定义它以使用此构造 ${yourWebService.wsdl.url}

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
       <property name="locations">
          <list>
              <value>yourWebService.properties</value>
          </list>
       </property>
    

使用这种方法,我成功地将 JAX 与 Spring 结合使用

【讨论】:

  • 我面临同样的问题。我已经有 java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0"> 我给了@Component("TransactionImpl") @WebService public interface Transaction {
猜你喜欢
  • 1970-01-01
  • 2015-07-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-04-10
  • 1970-01-01
  • 2013-01-13
  • 1970-01-01
相关资源
最近更新 更多