我正在使用 JAX-WS 的 Spring 扩展,并且在我的 Spring 配置中使用列表时遇到问题:
这是工作配置:
<wss:binding url="/services/demo">
<wss:service>
<ws:service bean="#demoEndpoint">
<ws:handlers>
<ref bean="handler1"/>
<ref bean="handler2"/>
</ws:handlers>
</ws:service>
</wss:service>
</wss:binding>
由于我有更多端点,应该使用相同的处理程序集,我想在单个配置中定义处理程序列表。
但是这个配置不起作用:
<util:list id="myHandlers">
<ref bean="handler1"/>
<ref bean="handler2"/>
</util:list>
<wss:binding url="/services/demo">
<wss:service>
<ws:service bean="#demoEndpoint">
<ws:handlers>
<ref bean="myHandlers"/>
</ws:handlers>
</ws:service>
</wss:service>
</wss:binding>
我得到以下异常:
Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.util.ArrayList] to required type [javax.xml.ws.handler.Handler] for property 'handlers[0]': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:264)
at org.springframework.beans.TypeConverterDelegate.convertToTypedCollection(TypeConverterDelegate.java:559)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:199)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:448)
... 66 more
这是 org.jvnet.jax_ws_commons.spring.SpringService 中对应的 setter:
public void setHandlers(List<Handler> handlers) {
this.handlers = handlers;
}