3

I Create Web service with spring-ws (Soap) and now, i want create encryption web service. my applicationContext.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web-services="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="webserviceTemplate"
      class="org.springframework.ws.client.core.WebServiceTemplate">
    <constructor-arg ref="messageFactory" />
    <property name="defaultUri" value="http://localhost:8081/surena/signauthenticateservice/"/>
    <property name="interceptors">
        <bean class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
            <property name="securementActions" value="Encrypt"/>
            <property name="securementEncryptionKeyIdentifier" value="EmbeddedKeyName"/>
            <property name="securementEncryptionUser" value="symmetric"/>
            <property name="securementEncryptionEmbeddedKeyName" value="symmetric"/>
            <property name="SecurementEncryptionSymAlgorithm" value="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>

            <property name="securementCallbackHandlers">
                <bean class="org.springframework.ws.soap.security.wss4j.callback.KeyStoreCallbackHandler">
                    <property name="symmetricKeyPassword" value="keyPassword"/>
                    <property name="keyStore">
                        <bean class="org.springframework.ws.soap.security.support.KeyStoreFactoryBean">
                            <property name="location" value="/symmetricStore.jks"/>
                            <property name="type" value="JCEKS"/>
                            <property name="password" value="symmetricPassword"/>
                        </bean>
                    </property>
                </bean>
            </property>
        </bean>
    </property>
</bean>
<bean id="log4jInitialization" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetClass" value="org.springframework.util.Log4jConfigurer" />
    <property name="targetMethod" value="initLogging" />
    <property name="arguments">
        <list>
            <value>src/test/resources/log4j.properties</value>
        </list>
    </property>
</bean>
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>

but, i has e this error:

Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'securementCallbackHandlers' of bean class [org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor]: Bean property 'securementCallbackHandlers' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1076)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:927)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1510)
... 50 more

I got help Spring Web Services 2 Cookbook. but this book use the spring web service 1.5, but i use spring web service 2.2.1, (i Create web service in spring boot web service 1.2.5 in the server side) Can help me?

emreh
  • 31
  • 1

1 Answers1

1

I ran into the same error. Essentially this property was removed sometime after 2.0.3 of Spring WS when they decided to upgrade to Apache WSS4J 1.6 and they couldn't figure out how to create a callback handler on Securement actions. So they basically just removed it with no warning or explanation and without updating their documentation.

Javadoc for Wss4JSecurityInterceptor

Typical move by the Spring folks. Here is an issue in their JIRA tracker where they are labeling this as a "Feature Improvement" slated for 2.3.

Luckily however somebody there posted a potential workaround until this happens. He is creating his own Securement Callback Handler class and his own custom Wss4JSecurityInterceptor class that adds this property. It is worth looking into.

maple_shaft
  • 10,435
  • 6
  • 46
  • 74