Simple Project: Spring Boot + Apache CXF (JAX-WS)

Let’s create a simple hello world with and Spring Boot + Apache CXF (JAX-WS) project. Is not so common to find and example on the web, so I’m going to provide it.

Firstly, we need to declare some dependencies on our pom.xml:

I’d like to highlight the dependency with artefactid cxf-spring-boot-starter-jaxws, which provides the Apache CXF for Spring Boot. As a pattern in Spring projects, we will create and WebServiceConfig.java and set the Endpoint and publish it as we usually do in JAX-WS projects.

As we can see, we will always do commons configurations of JAX-WS but following the Spring Boot patterns. So, if you’ve worked with Spring Boot and with JAX-WS, it will be simple.

____________________________________________________

OBS:

I can imagine that somebody would ask yourself about the org.apache.cxf.Bus. So, I’d like to break the tutorial just to bring a quote of what it is according to the Apache CXF documentation:

The bus, being CXF’s backbone, is a provider of shared resources to the CXF runtime. Examples for such shared resources include WSDL managers and binding factory managers. The bus can easily be extended to include your own custom resources or services, or you can replace default resources like the HTTP destination factory (based on Jetty) with your own (possibly based on another web container such as Apache Tomcat).

This extensibility is made possible by dependency injection; the default bus implementation is based on Spring Framework, which wires the runtime components together for you.

Apache CXF Documentation

____________________________________________________

No other configuration is necessary to our hello world, so, now we only need to create our class to receive the SOAP request.

 

I’ve used the same annotation the we use in any JAX-WS project. So, compile and be happy!

____________________________________________________

OBS:

We cannot use @Autowired to inject dependencies inside the HelloPort because it’s not managed as bean for Spring. I will post some workarounds to help with it!


skyscraper-3038229_640

from pixabay.com

Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logotipo do WordPress.com

Você está comentando utilizando sua conta WordPress.com. Sair /  Alterar )

Foto do Google+

Você está comentando utilizando sua conta Google+. Sair /  Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair /  Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair /  Alterar )

Conectando a %s