Skip to main content

Posts

Showing posts from July, 2020

Working with SOAP service headers

How to modify headers in the SOAP response. Below snippet will do the trick. In a nutshell, you need to: Add @SoapHeader annotation in the service method. Use Unmarshaller to map header xml elements to java object. Make necessary changes to this java object. Finally, use Marshaller to map java object back to xml, and set in response. // Service class code private static final String NAMESPACE_URI = "http://domain.com/context/../DummyRequest.xsd"; @PayloadRoot(namespace = NAMESPACE_URI, localPart = "RequestPartInXml") @ResponsePayload public JAXBElement<ResponsePOJO> returnApiResponse( @RequestPayload JAXBElement<RequestPojo> request, @SoapHeader(value = "{http://domain.com/context/../DummyRequest.xsd}MessageHeader") SoapHeaderElement soapHeaders, MessageContext messageContext) { // handleSoap Headers handleSoapHeaders(messageContext, soapHeaders); ... ... } // handling of headers pub

Run Spring Boot application in Standalone Tomcat Server

How to run Spring Boot application on Tomcat To deploy a Spring Boot application on existing Tomcat Server, or to bundle it as war file and deploy on Tomcat, following changes are required: Change to war packaging in pom.xml: <packaging>war Application Main class to extend  SpringBootServletInitializer. Override configure method in this class.                protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {                        return application.sources(Application.class);                } Add Tomcat-starter dependency in pom.xml. <dependency>     <groupId>org.springframework.boot</groupId>     <artifactId>spring-boot-starter-tomcat</artifactId>     <scope>provided</scope> </dependency> Run maven install, war will generate in target folder. Deploy on standalone Tomcat Server. Don't forget to add context root to access the services. I will be