如何仅为特定端点添加Apache cxf wsrm

时间:2015-12-15 13:49:11

标签: java web-services soap cxf ws-reliablemessaging

我想仅为特定端点添加Apache CXF wsrm,而不是在总线级别

我尝试了以下代码,但它提供了异常:

<jaxws:endpoint id="testService" implementor="#testService" address="/testService" publishedEndpointUrl="${tomcat.url}/${context.name}/testService" >
    <jaxws:features>
        <wsp:Policy>
            <wsrm:RMAssertion xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy">
                <wsrm:AcknowledgementInterval Milliseconds="2000" />
            </wsrm:RMAssertion>
            <wsam:Addressing xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata">
                <wsp:Policy>
                    <wsam:NonAnonymousResponses/>
                </wsp:Policy>
            </wsam:Addressing>
        </wsp:Policy>
    </jaxws:features>
</jaxws:endpoint>

但我得到了以下异常

Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.ArrayList' to required type 'java.util.List' for property 'features'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.apache.cxf.ws.policy.PolicyBean] to required type [org.apache.cxf.feature.AbstractFeature] for property 'features[0]': no matching editors or conversion strategy found
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:455)
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:491)
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:485)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1476)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1216)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
    ... 24 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.apache.cxf.ws.policy.PolicyBean] to required type [org.apache.cxf.feature.AbstractFeature] for property 'features[0]': no matching editors or conversion strategy found
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:287)
    at org.springframework.beans.TypeConverterDelegate.convertToTypedCollection(TypeConverterDelegate.java:557)
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:216)
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:440)
    ... 30 more

1 个答案:

答案 0 :(得分:1)

我用以下代码完成了这个:

    <wsp:Policy wsu:Id="RM" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <wsrm:RMAssertion xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy">
        <wsrm:AcknowledgementInterval Milliseconds="2000" />
    </wsrm:RMAssertion>
    <wsam:Addressing xmlns:wsam="http://www.w3.org/2007/02/addressing/metadata">
        <wsam:NonAnonymousResponses />
    </wsam:Addressing>
</wsp:Policy>


<jaxws:endpoint id="Service" implementor="#Serv" address="/Webservice" publishedEndpointUrl="${tomcat.url}/${context.name}/Webservice">
    <jaxws:features>
        <cxf:logging/>
        <p:policies>
            <wsp:PolicyReference URI="#RM" />
        </p:policies>
    </jaxws:features>
</jaxws:endpoint>