简体   繁体   中英

Using a SOAPHandler with spring-boot SOAP web service

I have created an application by following the guide on http://spring.io/guides/gs/producing-web-service/

Executing the webservice 'getCountry' works fine but now I need to intercept the SOAP message somehow before getCountry is executed.

I created a class that implements 'SOAPHandler' but somehow I have to tell spring-boot to use this handler before passing the request to getCountry.

Any idea how to do that?

you need to implement an interceptor like:

public class YourClientInterceptor implements ClientInterceptor{

@Override
public boolean handleRequest(MessageContext messageContext)
{

    //here you get your request before it is sending
    messageContext.getRequest() 

 ...

    return true;
}

}

and when you create your WebServiceTemplate you do:

ClientInterceptor[] interceptors = {new YourClientInterceptor ()};
yourWebServiceTemplate.setInterceptors(interceptors);

They work similar with handler.

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