This example demonstrates how you can use Apache CXF with Spring Boot based on a fabric8 Java base image.
The quickstart uses Spring Boot to configure a little application that includes a CXF JAXWS endpoint.
Important
|
This quickstart can run in 2 modes: standalone on your machine and on Kubernetes / OpenShift Cluster. Quickstart requires Java 8 or Java 11 (fuse-java-openshift-jdk11-rhel8 image is used to build in Java 11).
|
You can run this quickstart in the following modes:
-
Kubernetes / Single-node OpenShift cluster
-
Standalone on your machine
The most effective way to run this quickstart is to deploy and run the project on OpenShift.
For more details about running this quickstart on a single-node OpenShift cluster, CI/CD deployments, as well as the rest of the runtime, see the Spring Boot Runtime Guide.
Important
|
You need to run this example on Container Development Kit 3.3 or OpenShift 3.7. Both of these products have suitable Fuse images pre-installed. If you run it in an environment where those images are not preinstalled follow the steps described in Running the Quickstart on a single-node Kubernetes/OpenShift cluster without preinstalled images. |
A single-node Kubernetes/OpenShift cluster provides you with access to a cloud environment that is similar to a production environment.
If you have a single-node Kubernetes/OpenShift cluster, such as Minishift or the Red Hat Container Development Kit, installed and running, you can deploy your quickstart there.
-
Log in to your OpenShift cluster:
$ oc login -u developer -p developer
-
Create a new OpenShift project for the quickstart:
$ oc new-project MY_PROJECT_NAME
-
Change the directory to the folder that contains the extracted quickstart application (for example,
my_openshift/spring-boot-cxf-jaxws
) :or
$ cd my_openshift/spring-boot-cxf-jaxws
-
Build and deploy the project to the OpenShift cluster:
$ mvn clean -DskipTests oc:deploy -Popenshift
-
In your browser, navigate to the
MY_PROJECT_NAME
project in the OpenShift console. Wait until you can see that the pod for thespring-boot-cxf-jaxws
has started up.
A single-node Kubernetes/OpenShift cluster provides you with access to a cloud environment that is similar to a production environment.
If you have a single-node Kubernetes/OpenShift cluster, such as Minishift or the Red Hat Container Development Kit, installed and running, you can deploy your quickstart there.
-
Log in to your OpenShift cluster:
$ oc login -u developer -p developer
-
Create a new OpenShift project for the quickstart:
$ oc new-project MY_PROJECT_NAME
-
Configure Red Hat Container Registry authentication (if it is not configured). Follow documentation.
-
Import base images in your newly created project (MY_PROJECT_NAME):
$ oc import-image fuse-java-openshift:1.13 --from=registry.redhat.io/fuse7/fuse-java-openshift:1.13 --confirm
-
Change the directory to the folder that contains the extracted quickstart application (for example,
my_openshift/spring-boot-cxf-jaxws
) :or
$ cd my_openshift/spring-boot-cxf-jaxws
-
Build and deploy the project to the OpenShift cluster:
$ mvn clean -DskipTests oc:deploy -Popenshift -Djkube.generator.fromMode=istag -Djkube.generator.from=MY_PROJECT_NAME/fuse-java-openshift:1.13
-
In your browser, navigate to the
MY_PROJECT_NAME
project in the OpenShift console. Wait until you can see that the pod for thespring-boot-cxf-jaxws
has started up.
When the example is running, a CXF JAXRS endpoint is available.
If you run the example on a single-node OpenShift cluster, then the REST service is exposed at 'http://spring-boot-cxf-jaxws-MY_PROJECT_NAME.OPENSHIFT_IP_ADDR.nip.io/service/`.
Notice: As it depends on your OpenShift setup, the hostname (route) might vary. Verify with oc get routes
which hostname is valid for you.
-
http://spring-boot-cxf-jaxws-MY_PROJECT_NAME.OPENSHIFT_IP_ADDR.nip.io/service/hello?wsdl will display the generated WSDL.
The example includes a Kubernetes Integration Test. Once the container image has been built and deployed in Kubernetes, the integration test can be run with:
mvn test -Dtest=*KT
The test is disabled by default and has to be enabled using -Dtest
.
To run this quickstart as a standalone project on your local machine:
-
Download the project and extract the archive on your local filesystem.
-
Build the project:
$ cd PROJECT_DIR $ mvn clean package
-
Run the service:
$ mvn spring-boot:run
You can then access the CXF JAXRS endpoint directly from your Web browser, e.g.:
-
http://localhost:8080/service/hello?wsdl will display the generated WSDL.