Skip to content

Latest commit

 

History

History
44 lines (34 loc) · 1.45 KB

webserviceconfig-changes.md

File metadata and controls

44 lines (34 loc) · 1.45 KB

Text Lecture at Section 7: SOAP Web Services with Spring and Spring Boot prior to Step 78

Note

Problem: XwsSecurityInterceptor has been deprecated from Spring Boot Version >= 3.0.x

How to Solve it

The following are the guidelines/steps for resolving the issue from Spring Boot 3.x.x

Step 1: Add the following dependency

<dependency>
    <groupId>wsdl4j</groupId>
    <artifactId>wsdl4j</artifactId>
</dependency>

Step 2: Add the Wss4jSecurityInterceptor bean instead of XwsSecurityInterceptor

import org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor; // import this 

@Bean
public Wss4jSecurityInterceptor securityInterceptor() {
    Wss4jSecurityInterceptor securityInterceptor = new Wss4jSecurityInterceptor();
    securityInterceptor.setSecurementActions("UsernameToken");
    securityInterceptor.setValidationCallbackHandler(callbackHandler());

    return securityInterceptor;
}

Step 3: Modify SimplePasswordValidationCallbackHandler package namespace(xwss -> wss4j2) and add the following bean

import org.springframework.ws.soap.security.wss4j2.callback.SimplePasswordValidationCallbackHandler;
@Bean
public SimplePasswordValidationCallbackHandler callbackHandler() {
    SimplePasswordValidationCallbackHandler handler = new SimplePasswordValidationCallbackHandler();
    handler.setUsersMap(Collections.singletonMap("user", "password"));
    return handler;
}

Happy Learning @in28minutes