Wednesday, March 23, 2022

Shutdown Spring Boot Command Line Application

You can use ConfigurableApplicationContext to shutdown/closes all resources used by application as follows.

 public static void main(String[] args) {

        ConfigurableApplicationContext ctx=SpringApplication.run(Application.class, args);

        ctx.close();

    } 

    @Bean

    public CommandLineRunner commandLineRunner(RestTemplate restTemplate) {

        return args -> {

}

    }


Monday, March 14, 2022

Remove the <return> tag from SOAP response in JAVA

 Following JAVA annotation can be used to avoid <return> tag from SOAP web service response.

@WebService(serviceName = "Operations")

public class Service {

    @WebMethod(operationName = "processUser")

    @SOAPBinding(parameterStyle=ParameterStyle.BARE)

    public Result processUser(@WebParam(name = "userName")String userName) {

        Result result = new Result();

        result.setResultCode("1");

        result.setResultDesc("success");

        return result;

    }

}

ParameterStyle.BARE will return SOAP response with your defined object attributes.