HTTP/3 for SOAP services
|
Serving SOAP services over HTTP/3 is experimental.
It relies on the |
Quarkus CXF service endpoints are served by the Quarkus HTTP server. Once the Quarkus HTTP server accepts HTTP/3, your SOAP services can be called over HTTP/3, in addition to HTTP/1.x and HTTP/2. There are no Quarkus CXF options related to HTTP/3 on the service side.
Both JVM and native mode are supported.
|
Refer to Quarkus HTTP/3 reference for more details.
See the documentation of
|
|
The sample code snippets used in this section come from the HTTP/3 integration test in the source tree of Quarkus CXF |
Enable HTTP/3
-
Add the
io.quarkus:quarkus-http3extension to your application:pom.xml<dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-http3</artifactId> </dependency> -
Configure TLS for the HTTP server. HTTP/3 does not work without it. The service itself is exposed in the same way as without HTTP/3.
application.properties# A named TLS configuration holding the key store of the server quarkus.tls.localhost.key-store.p12.path = target/classes/localhost-keystore.p12 quarkus.tls.localhost.key-store.p12.password = secret # Make the HTTP server use it quarkus.http.tls-configuration-name = localhost # A SOAP service quarkus.cxf.endpoint."/hello".implementor = io.quarkiverse.cxf.it.http3.HelloServiceImplSee SSL, TLS and HTTPS for more information about the TLS configuration.
|
With Quarkus 4.0.1, you also need to add |
With the above in place, the service is available under https://localhost:8443/services/hello
-
over HTTP/1.1 and HTTP/2 on the TCP port
8443and -
over HTTP/3 on the UDP port
8443.
The port number is the one set via quarkus.http.ssl-port.
Verify
A curl binary built with HTTP/3 support can be used to check that the service is available over HTTP/3.
--http3-only makes curl fail, rather than fall back to an older HTTP version:
$ curl --http3-only -k -s -o /dev/null -w '%{http_code} HTTP/%{http_version}\n' 'https://localhost:8443/services/hello?wsdl'
200 HTTP/3
The service implementation can find out the HTTP version of the current request
via jakarta.servlet.http.HttpServletRequest.getProtocol().
It returns HTTP/1.1, HTTP/2.0 or HTTP/3.0.
HelloServiceImpl.java
import jakarta.annotation.Resource;
import jakarta.jws.WebService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.xml.ws.WebServiceContext;
import jakarta.xml.ws.handler.MessageContext;
/**
* A {@link HelloService} telling the caller through which HTTP version the request came.
*
* @since 4.0.0
*/
@WebService(serviceName = "HelloService", targetNamespace = "urn:hello")
public class HelloServiceImpl implements HelloService {
/* Injected by the JAX-WS runtime, hence non-final */
@Resource
WebServiceContext wsContext;
/**
* {@inheritDoc}
*
* @since 4.0.0
*/
@Override
public String hello(String person) {
final HttpServletRequest request = (HttpServletRequest) wsContext.getMessageContext()
.get(MessageContext.SERVLET_REQUEST);
/* getProtocol() returns HTTP/1.1, HTTP/2.0 or HTTP/3.0 */
return "Hello " + person + " over " + request.getProtocol();
}
}
How clients switch to HTTP/3
A client can use HTTP/3 in two ways:
-
It knows upfront that the service supports HTTP/3 and it connects over QUIC straight away.
-
It contacts the service over TCP first and it switches to HTTP/3 after the service has advertised it.
quarkus-http3advertises HTTP/3 through theAlt-Svcresponse header, for exampleAlt-Svc: h3=":8443"; ma=86400. The header is added to the responses of Quarkus CXF services as well.
For SOAP clients based on Quarkus CXF, the two ways correspond to the values 3 and 3,1.1 of
quarkus.cxf.client."client-name".vertx.http-versions
respectively.
Things to consider
-
HTTP/3 uses QUIC, a transport protocol based on UDP. The UDP port of the service has to be reachable for the clients. Check your firewalls, container port mappings, Kubernetes services and load balancers, which often let through only TCP traffic by default. Reverse proxies terminating TLS typically speak HTTP/1.1 or HTTP/2 to the applications behind them.
-
quarkus-http3selects the native QUIC library for the platform it is built on using Maven profiles. If you use Gradle or if you build on a different platform than you run on, you need to add theio.netty:netty-codec-native-quicdependency with the classifier matching your target platform(s), such aslinux-x86_64. -
In dev and test mode, if no TLS configuration is detected,
quarkus-http3generates a TLS certificate and it makes the HTTP server redirect plain HTTP requests to HTTPS. SOAP clients and tests calling your services viahttp:URLs are impacted by that. Either configure TLS as shown above, or addquarkus.http.insecure-requests = enabledtoapplication.properties. See Auto-TLS in dev and test mode in Quarkus HTTP/3 reference. -
If you have added
quarkus-http3only for the sake of SOAP clients and you do not want the HTTP server of the application to serve HTTP/3, addquarkus.http3.enabled = falsetoapplication.properties. This is a build time option that does not impact the SOAP clients.
Known limitations
The following limitations are not specific to Quarkus CXF. They come from the underlying projects and they will go away once they are solved there.
-
With Quarkus 4.0.1,
quarkus-http3breaks the responses sent over HTTP/2. It sends the response head while advertising HTTP/3, before the application can set the status and headers. Clients calling your SOAP services over HTTP/2 thus receive an empty response body or the HTTP status500, andIllegalStateException: Response head already sentis logged by the application. Other parts of the application served over HTTP/2, such as REST endpoints, are affected as well. Requests sent over HTTP/1.x and HTTP/3 work properly. As a workaround, addquarkus.http3.alt-svc = falsetoapplication.properties. With this build time option,quarkus-http3does not advertise HTTP/3 at all. Clients can then use HTTP/3 only if they connect over HTTP/3 straight away, such as SOAP clients havingquarkus.cxf.client."client-name".vertx.http-versionsset to3. See #2476. -
A request whose body exceeds
quarkus.http.limits.max-body-sizeis rejected with HTTP status413and the whole HTTP/3 connection is closed afterwards. The same happens if the client stops sending the request body for more than 10 seconds. Other requests that the client is sending through the same connection at that time may thus fail. This applies to HTTP/2 too. See #2461. -
If the application depends on
quarkus-micrometer, aNullPointerExceptionthrown fromVertxHttpServerMetrics.requestReset()is logged whenever a request sent over HTTP/2 or HTTP/3 is terminated before it is completed. See #2463. -
If the HTTP server listens on all network interfaces, which is the default in production mode,
jakarta.servlet.http.HttpServletRequest.getLocalAddr()andgetLocalName()return the wildcard address0:0:0:0:0:0:0:0for requests received over HTTP/3, instead of the address to which the client has sent the request.getLocalPort()returns the right port. Setquarkus.http.hostto a specific address, if you need the methods to work properly. See #2464.