Skip to end of metadata
Go to start of metadata

Spring Boot CXF JAX-WS Starter

Features

Registers CXFServlet with a  "/services/*" URL pattern for serving CXF JAX-WS endpoints.

Setup

JAX-WS Starter

Additional Configuration

Use "cxf.path" property to customize a CXFServlet URL pattern

Use "cxf.servlet.init" map property to customize CXFServlet properties such as "services-list-path" (available by default at  "/services"), etc.

If needed, one can use Spring ImportResource annotation to import the existing JAX-WS contexts available on the classpath.

API Documentation

JAX-WS endpoints support WSDL.

Service Registry Publication

Publication of JAX-WS endpoints into well-known service registries such as Netflix Eureka Registry can be achieved similarly to the way JAX-RS endpoints are registered and is shown in a JAX-RS Spring Boot Scan demo.

Examples

Consider the following Configuration instance:

JAX-WS Configuration

 

Having a CXF JAX-WS starter alongside this Configuration is sufficient for enabling a CXF JAX-WS endpoint which will respond to SOAP request URI such as

"http://localhost:8080/services/Hello".

Please also see a JAX-WS Spring Boot demo.

Spring Boot CXF JAX-RS Starter

Features

Registers CXF Servlet with a  "/services/*" URL pattern for serving CXF JAX-RS endpoints.

Optionally auto-discovers JAX-RS root resources and providers and creates a JAX-RS endpoint.

Note the use of CXF JAX-RS Clients in SpringBoot Application is covered in this section.

Setup

JAX-RS Starter

Additional Configuration

Use "cxf.path" property to customize a CXFServlet URL pattern.

Use "cxf.servlet.init" map property to customize CXFServlet properties such as "services-list-path" (available by default at  "/services"), etc.

Use "cxf.jaxrs.server.path" property to customize a JAX-RS server endpoint address (default is "/").

JAX-RS root resources and providers annotated with JAX-RS @Path and @Provider and native CXF Providers annotated with CXF @Provider can be auto-discovered.

Use "cxf.jaxrs.component-scan" property to create a JAX-RS endpoint from the auto-discovered JAX-RS root resources and providers which are marked as Spring Components (annotated with Spring @Component or created and returned from @Bean methods).

Use "cxf.jaxrs.component-scan-packages" property to restrict which of the auto-discovered Spring components are accepted as JAX-RS resource or provider classes. It sets a comma-separated list of the packages that a given bean instance's class must be in. Note, this property, if set, is only effective if a given bean is a singleton. It can be used alongside or as an alternative to the "cxf.jaxrs.component-scan-beans" property. This property is available starting from CXF 3.1.11.

Use "cxf.jaxrs.component-scan-beans" property to restrict which of the auto-discovered Spring components are accepted as JAX-RS resource or provider classes. It sets a comma-separated list of the accepted bean names - the auto-discovered component will only be accepted if its bean name is in this list. It can be used alongside or as an alternative to the "cxf.jaxrs.component-scan-packages" property. This property is available starting from CXF 3.1.11.

Use "cxf.jaxrs.classes-scan" property to create a JAX-RS endpoint from the auto-discovered JAX-RS root resources and provider classes. Such classes do not have to be annotated with Spring @Component. This property needs to be accompanied by a "cxf.jaxrs.classes-scan-packages" property which sets a comma-separated list of the packages to scan.

Note that while "cxf.jaxrs.component-scan" and "cxf.jaxrs.classes-scan" are mutually exclusive, "cxf.jaxrs.component-scan" can be used alongside the "cxf.jaxrs.classes-scan-packages" property to enable the auto-discovery of the JAX-RS resources and providers which may or may not be marked as Spring Components.

If needed, instead of having the resources auto-discovered,  one can use Spring ImportResource annotation to import the existing JAX-RS contexts available on the classpath.

API Documentation

Swagger

See CXF Swagger2Feature documentation on how to enable Swagger2Feature in SpringBoot and how to auto-activate Swagger UI.

WADL

CXF automatically loads a WADL provider if a cxf-rt-rs-service-description module is available on the runtime classpath.

Service Registry Publication

Publication of JAX-RS endpoints into well-known service registries such as Netflix Eureka Registry is shown in a JAX-RS Spring Boot Scan demo.

Examples

Manual Configuration

Consider the following Configuration instance:

JAX-RS Configuration

 

Having a CXF JAX-RS starter alongside this Configuration is sufficient for enabling a CXF JAX-RS endpoint which will respond to HTTP request URI such as

"http://localhost:8080/services/sayHello/ApacheCxfUser". The above code also makes Swagger docs available at "http://localhost:8080/services/swagger.json".

Please also see a JAX-RS Spring Boot demo.

 

Auto Configuration

Spring Boot Application example shown in the Manual Configuration section can be simplified if the auto-discovery is enabled.

For example, given the following application.yml properties:

Application Properties

 

the application becomes simply:

 

JAX-RS Auto Configuration

 

This application will enable a CXF JAX-RS endpoint which will respond to HTTP request URI such as

"http://localhost:8080/services/sayHello/ApacheCxfUser". The above code also makes Swagger docs available at "http://localhost:8080/services/swagger.json".

Please also see a JAX-RS Spring Boot Scan demo.

 

  • No labels

0 Comments