简体   繁体   中英

How to add Apache cxf wsrm for particular endpoint only

I want to add Apache CXF wsrm for particular endpoint only,not at bus level :

I have tried below code but it gives exception :

<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>

but i got below exception

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

I have done this with below code :

    <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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM