2 Integrating WebLogic Server REST Services with Helidon

The REST services integration with Helidon enables bidirectional REST calls between Helidon and Oracle WebLogic Server (WebLogic Server). RESTful integration between WebLogic Server and Helidon MP is easy to develop and maintain because both runtimes support JAX-RS for serving and calling the RESTful resources. With the Jakarta EE support, you can create the same RESTful resource or client, which will work in both environments.
The following graphic illustrates the bidirectional communication between REST services, Helidon, Kubernetes cluster, VCN, and load balancer:

Figure 2-1 REST Services Integration with Helidon



The main difference in the usage of JAX-RS between Helidon and WebLogic Server is the version of the supported Jakarta specification. While WebLogic Server supports Jakarta EE 8, Helidon supports JAX-RS or the new Jakarta RESTful Web Services from Jakarta EE 9.1. The most notable difference between these two versions of Jakarta EE is the change in the package name, where javax is replaced with jakarta.

While imports from the jakarta namespace needs to be used in Helidon 3.x, for WebLogic Server and Helidon 2.x, javax should be used for the same JAX-RS code.

Helidon JAX-RS Imports for 3.x
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
Helidon JAX-RS Imports for 2.x
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
WebLogic Server JAX-RS Imports
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

This chapter includes the following topics:

Prerequisites

To integrate WebLogic Server with Helidon for REST services, it is assumed that you have already deployed WebLogic Server and Helidon in a Kubernetes cluster with the WebLogic Kubernetes Operator (Operator). See Preparing the Kubernetes Cluster for WebLogic Server and Helidon Integration.

To deploy WebLogic Server, ensure that you have:

To download the WebLogic Server Java clients with Jakarta packages, see Downloading the WebLogic Server Java Clients with Jakarta Package Names.

Using the JAX-RS Server

The JAX-RS resource is a simple bean with annotated methods representing routes and HTTP methods under a specific path. Annotated methods are invoked when a particular REST endpoint is called. All the mapping and routing are done by the actual implementation of the JAX-RS standard according to the JAX-RS annotations.

JAX-RS Example Resource

@Path("/greet")                               (1)
public class GreetResource {

    @Path("/hello")
    @GET                                      (2)
    @Produces(MediaType.TEXT_PLAIN)           (3) 
    public Response getHello() {
        return Response.ok("Hello World!")    (4) 
                       .build();
    }
}

A brief description of the above example:

(1) Path of the resource.

(2) HTTP method.

(3) Expected response content type.

(4) Returns the text payload with status 200.

JAX-RS is a very powerful tool where you can register your message body writers, readers, filters, or exception mappers. In both Helidon and WebLogic Server, Eclipse Jersey is used as the JAX-RS implementation. See Jersey User Guide.

For information about creating and deploying the JAX-RS RESTful resources in Helidon, see JAX-RS applications.

For information about developing and deploying the JAX-RS resources on WebLogic Server, see Developing RESTful Web Services.

Using the JAX-RS Client

JAX-RS provides a convenient client API for calling the RESTful resources. The client enables you to prepare and execute the RESTful request call with a simple builder pattern API.

JAX-RS Client Example

Client client = ClientBuilder.newClient();
String res = client
    .target("http://localhost:8080")        (1) 
    .path("/greet")                         (2) 
    .request("text/plain")                  (3) 
    .get(String.class);                     (4) (5) 

A brief description of the above example:

(1) Creates a new WebTarget with the default root URL.

(2) Prepares the request to a particular context path.

(3) Sets the expected response content type.

(4) Executes the GET request and blocks until the response is received.

(5) Parameter sets the expected response payload type; available body readers are used for parsing to the correct response payload type.

You can also register your own message body writers, readers, filters, or exception mappers.

For information about creating JAX-RS clients in Helidon, see Jakarta REST (JAX-RS) Client.

For information about developing and deploying JAX-RS clients on WebLogic Server, see Developing RESTful Web Services.