REST to HTTP/2 agents migration

REST to HTTP/2 agents migration

REST Client and Server agents are deprecated and will be removed in future MediationZone releases. It is recommended to migrate workflows using REST agents to HTTP/2 agents. This page highlights key considerations for the migration process.

REST Server

REST Server Profile No Longer Supported

The HTTP/2 Server does not support the REST Server Profile for defining endpoint URIs. Instead, we recommend implementing endpoint URI filtering rules directly in APL code. The table below illustrates a REST Server Profile migration example.

REST Server

HTTP/2 Server

REST Server

HTTP/2 Server

The REST Server profile example below configures an endpoint URL path as /api.

image-20241127-080939.png

 

For the equivalent functionality in the HTTP/2 Server, use an Analysis agent to define APL code that handles endpoint paths. Below is an example:

consume { Response response = udrCreate(Response); bytearray body; if (input.path == "/api") { response.statusCode = 200; strToBA(body, "Hello from server!"); ..... } else { response.statusCode = 404; strToBA(body, "Page not found!"); } response.body = body; input.response = response; udrRoute(input); }

OAuth 2.0 Authentication Changes

For OAuth 2.0 token authentication:

  • REST Server: Requires a JKS truststore.

  • HTTP/2 Server: Requires a public key in PEM format.

Steps to extract the public key from the JKS file:

  1. Convert JKS to PKCS12 format.

keytool -importkeystore \ -srckeystore <KEYSTORE_NAME>.jks \ -destkeystore <KEYSTORE_NAME>.p12 \ -srcalias <ALIAS> \ -srcstoretype jks \ -deststoretype pkcs12
  1. Export the certificate from PKCS12 key.

openssl pkcs12 -in <KEYSTORE_NAME>.p12 -nokeys -out cert.pem
  1. Extract the public key from the certificate.

openssl x509 -pubkey -noout -in cert.pem -out public_key.pem

Once you have the public key, paste its content into the HTTP/2 Server agent configuration as shown below.

image-20241127-124652.png

REST Client

Multi-Host Support in HTTP/2 Client

Differences in Target Server Configuration

Feature

REST Client

HTTP/2 Client

Feature

REST Client

HTTP/2 Client

Host Support

Only supports a single destination host configured in the agent.

image-20241202-120431.png

Supports multiple destination hosts, configured dynamically in APL code.

Example of configuring a Destination Host in HTTP/2 Client

import ultra.http; consume { RequestCycle rc = udrCreate(RequestCycle); rc.host = "server"; rc.port = "8080"; rc.method = "GET"; rc.path = "/"; rc.secure = true; rc.httpVersion = "HTTP/1"; udrRoute(rc); }

TLS and HTTP Protocol Version

TLS Configuration

Feature

REST Client

HTTP/2 Client

Feature

REST Client

HTTP/2 Client

TLS Connection

Requires specifying https:// in the connection string.

image-20241202-120431.png

Configured programmatically using APL code.

Example of enabling TLS in HTTP/2 Client

import ultra.http; consume { RequestCycle rc = udrCreate(RequestCycle); rc.host = "server"; rc.port = "8080"; rc.method = "GET"; rc.path = "/"; rc.secure = true; // Enables TLS rc.httpVersion = "HTTP/1"; udrRoute(rc); }

HTTP Protocol Version Support

Feature

REST Client

HTTP/2 Client

Feature

REST Client

HTTP/2 Client

Protocol Version

Only supports HTTP/1.1

Supports both HTTP/1.1 and HTTP/2 protocols. By default, the agent uses HTTP/2 if the version is not explicitly specified.

Note!

For more details on supported settings in the HTTP/2 UDR, refer to HTTP/2 UDRs.