Este contenido no está disponible en el idioma seleccionado.
Chapter 8. Running SOAP to REST bridge quickstart for Spring Boot 2 on Fuse on OpenShift
This quickstart demonstrates how to use Camel’s REST DSL to expose a backend SOAP API. A simple camel route can bridge REST invocation to legacy SOAP service. Security is involved for both REST endpoint and SOAP endpoint, both backed by RH SSO. Frontend REST API protected via OAuth and OpenID Connect, and the client will fetch JWT access token from RH SSO using Resource Owner Password Credentials OAuth2 mode and using this token to access the REST endpoint.
Prerequsites
- You have installed and configured OCP 4.1 or later version.
- You have installed RH SSO 7.4 or later version.
- You have installed 3Scale 2.8 or later version.
-
You have configured authentication to
registry.redhat.io. For more information see Configuring Red Hat Container Registry authentication.
Procedure
Following section explains how to run and deploy SOAP to REST bridge quickstart on Fuse on OpenShift.
- Start OpenShift server. Since we need to install RH SSO image (2 pods) and 3Scale image (15 pods) as prerequisites for this quickstart, we need to start the OpenShift server on a powerful machine, with options --memory 8GB --cpus 4. We also need to issue a security token with the expiration time, hence we need to add the timezone option as well. Ensure the Openshift cluster uses the same time zone as your local machine (by default it will use UTC timezone).
Add
cluster-adminrole to the userdeveloper.oc login -u system:admin oc adm policy add-cluster-role-to-user cluster-admin developer oc login -u developer oc project openshift
$ oc login -u system:admin $ oc adm policy add-cluster-role-to-user cluster-admin developer $ oc login -u developer $ oc project openshiftCopy to Clipboard Copied! Toggle word wrap Toggle overflow This quickstart is deployed in the
openshiftnamespace (this is the requirement of default configurations of the templates involved), as well as the RH SSO image, so we need to add thecluster-adminrole to userdeveloper.Create a secret and link it to the
serviceaccounts.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the RH SSO image stream and install RH SSO with template
sso74-x509-postgresql-persistent.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the RH SSO images are available from
openshiftnamespace, and then install RH SSO with templatesso74-x509-postgresql-persistent. This template can save the RH SSO configuration permenantly, so the configuration is retained after the Openshift server restart.Once the RH SSO image is installed successfully on the server, you can see the output on the console as follows.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note down the Username/Password which is used to access the RH SSO admin console. For example,
* RH-SSO Administrator Username=tprYtXP1 # generated * RH-SSO Administrator Password=nEjf7fojv11FmhJ5eaqadoh0SI2gvlls # generated
* RH-SSO Administrator Username=tprYtXP1 # generated * RH-SSO Administrator Password=nEjf7fojv11FmhJ5eaqadoh0SI2gvlls # generatedCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install 3scale template in the 3scale project.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 3scale installation on openshift will start 15 pods, so it is necessary to create a new specific project for 3scale. You also need a new
threescale-registry-auth(use this name to create the secret as it is written in 3scale templates) secret for 3scale. You can reuse the USERNAME/PASSWORD from camel-bridge secret. We intentionally useamp-eval-tech-preview.ymltemplate here because it doesn’t explicitly specify hardware resources so can be easily run on a local machine/laptop.After the 3scale template is installed successfully on the Openshift, you can see the output on the console as follows.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note down the Username/Password which can access the 3scale admin console.
* ADMIN_PASSWORD=b6t784nt # generated * ADMIN_USERNAME=admin* ADMIN_PASSWORD=b6t784nt # generated * ADMIN_USERNAME=adminCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure RH SSO.
-
Login to RH SSO Admin Console from
https://sso-openshift.OPENSHIFT_IP_ADDR.nip.io/authwith username/password displayed on console after the RH SSO installation. - Click the Add Realm button on the upper left corner of the page.
- On the Add Realm page, select Import Select file button.
-
Select
./src/main/resources/keycloak-config/realm-export-new.jsonfrom the directory which will import pre-defined necessaryrealm/client/user/rolefor this example.
-
Login to RH SSO Admin Console from
Configure 3Scale API Gateway.
-
Login to 3Scale Admin Console from
https://3scale-admin.OPENSHIFT_IP_ADDR.nip.io/p/admin/dashboardwith username/password displayed on console after the 3Scale installation. -
When creating a new product, select Define manually and use
camel-security-bridgefor both Name and System name. -
When creating a new backend, use
camel-security-bridgefor both Name and System name and the Private Base URL should behttp://spring-boot-camel-soap-rest-bridge-openshift.OPENSHIFT_IP_ADDR.nip.io/. - Add the newly created backend to the newly created product.
-
Add the Mapping Rule
Verb:POST Pattern:/. -
When creating application plans, use
camel-security-bridgefor both Name and System name. When creating applications, choose the new created
camel-security-bridgeapplication plan. After creating the application, note down the API Credentials. Use these credentials to access the 3scale gateway. For eample,User Key bdfb53fe9b426fbf21428fd116035798
User Key bdfb53fe9b426fbf21428fd116035798Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Edit the newly created
camel-security-bridgeproject and publish it fromcamel-security-bridgein the Dashboard. - Go to Integration > Settings. Select As HTTP Headers as the Credentials location.
-
From the
camel-security-bridgein the Dashboard, go to Integration > Configuration and promote both the Staging APIcast and Production APIcast.
-
Login to 3Scale Admin Console from
Navigate to the directory that contains the extracted quickstart application (for example, my_openshift/spring-boot-camel-soap-rest-bridge).
cd my_openshift/spring-boot-camel-soap-rest-bridge
$ cd my_openshift/spring-boot-camel-soap-rest-bridgeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Build and deploy the project to the OpenShift cluster.
mvn clean oc:deploy -Popenshift -DJAVA_OPTIONS="-Dsso.server=https://sso-openshift.OPENSHIFT_IP_ADDR.nip.io -Dweather.service.host=${your local ip}"$ mvn clean oc:deploy -Popenshift -DJAVA_OPTIONS="-Dsso.server=https://sso-openshift.OPENSHIFT_IP_ADDR.nip.io -Dweather.service.host=${your local ip}"Copy to Clipboard Copied! Toggle word wrap Toggle overflow We need to pass in two properties to
camel-soap-rest-bridgeimage on openshift. One is the RH SSO server address on openshift, and this is https://sso-openshift.OPENSHIFT_IP_ADDR.nip.io. Another one is the backend soap server. In this quickstart, we run the backend soap server on the local machine, so pass the local ip address of your machine as -Dweather.service.host. (This must be an ip address other than localhost or 127.0.0.1).-
In your browser, navigate to the
openshiftproject in the OpenShift console. Wait until you can see that the pod for thespring-boot-camel-soap-rest-bridgehas started up. -
On the project’s Overview page, navigate to the details page deployment of the
spring-boot-camel-soap-rest-bridgeapplication: https://OPENSHIFT_IP_ADDR:8443/console/project/openshift/browse/pods/spring-boot-camel-soap-rest-bridge-NUMBER_OF_DEPLOYMENT?tab=details. - Switch to Logs tab to view the log from Camel.
- Access OpenApi API.
This example provides API documentation of the service using openapi using the context-path camelcxf/openapi. You can access the API documentation from your Web browser at http://spring-boot-camel-soap-rest-bridge-openshift.OPENSHIFT_IP_ADDR.nip.io/camelcxf/openapi/openapi.jsonn.