0

I have migrated an existing Java SOAP Web Service application to Spring Boot. I referred this link to do so: https://spring.io/guides/gs/producing-web-service/

The endpoints work fine and I am able to map the requests from SOAP UI to their respective Endpoints.

Next task is to get Authentication credentials from the SOAP Request Header. Prior to this migration, the Authentication Credentials were being fetched from WebServiceContext.

However, I am unable to do so because WebServiceContext is always null in the application migrated to Spring Boot.

I am using @Resource annotation to get WebServiceContext. Please note that I have also tried setter injection.

Below is the sample code:

@Endpoint
public class TestEndpoint{
    
   @Resource
   WebServiceContext context; // Always null

}

Can we not use WebServiceContext in Spring Boot Application?

Is there any other way to get the credentials from Security header of SOAP request?

sid_bond
  • 135
  • 3
  • 11
  • Can you try using @Webservice instead of endpoint with setter injection of WebserviceContext like https://stackoverflow.com/questions/5820969/how-to-use-resource-webservicecontext-injection-with-springs-transactional? – Sup19 Apr 08 '22 at 03:47
  • Without @Endpoint annotation Spring Boot doesn't map the incoming SOAP requests to the methods. – sid_bond Apr 08 '22 at 04:05
  • I am stuck with the same problem. Did you find any solution for this? Any help and ideas would be highly appreciated. – Matze Jul 05 '22 at 07:20
  • Hi @Matze, unfortunately this is not possible as we cannot have WebService context in Spring Boot application. However, I needed this to extract user credentials from the soap header, so as a workaround I parsed the Soap Header to fetch the details. Try fetching soap request from Spring framework's Message context and see if this information can fit your needs. – sid_bond Jul 06 '22 at 12:30
  • Thanks a lot @SidharthaShankar, I know use an EndpointInterceptorAdapter implementation and put my required Inforamtion into a ThreadLocal. The WebService implementing class can get the desired header information out of it and removes the thread local. Kind of dirty but it works. – Matze Jul 07 '22 at 07:46

0 Answers0