2015-07-28 22 views
3

我使用spring-ws(Soap) 創建Web服務,現在我想創建加密Web服務。 我的applicationContext.xml是:spring-ws中無效屬性'securementCallbackHandlers'2.2.1

<?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"/> 

,但是,我有E本錯誤:

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 

我有幫助的Spring Web服務2食譜。 但本書使用spring web service 1.5,但我使用spring web service 2.2.1,(我在服務器端的spring boot web service 1.2.5中創建web服務) 可以幫我嗎?

回答

1

我遇到了同樣的錯誤。基本上這個屬性在Spring WS 2.0.3之後的某個時候被刪除,當他們決定升級到Apache WSS4J 1.6時,他們無法弄清楚如何爲Securement動作創建一個回調處理程序。所以他們基本上只是刪除它,沒有任何警告或解釋,也沒有更新他們的文檔。由Spring鄉親

Javadoc for Wss4JSecurityInterceptor

典型的舉動。 Here is an issue in their JIRA tracker他們在這裏標記爲「2.3特性改進」。

幸運的是,有人發佈了一個潛在的解決方法,直到發生這種情況。他正在創建自己的Securement Callback Handler類和他自己定製的添加此屬性的Wss4JSecurityInterceptor類。這是值得研究的。