HTTP Async Transport
🧪Experimental • Since 1.1.0
Implement async SOAP Clients using Apache HttpComponents HttpClient 5.
| This extension is experimental, because there are no tests covering it. Contributions are welcome! |
Maven coordinates
Create a new project using quarkus-cxf-rt-transports-http-hc5 on code.quarkus.io
or add these coordinates to your existing project:
<dependency>
<groupId>io.quarkiverse.cxf</groupId>
<artifactId>quarkus-cxf-rt-transports-http-hc5</artifactId>
</dependency>
| Check the User guide and especially its Dependency management section for more information about writing applications with CXF Extensions for Quarkus. |
Usage
Once the quarkus-cxf-rt-transports-http-hc5 dependency is available in the classpath,
CXF will use HttpAsyncClient for asynchronous calls and will continue using HttpURLConnection for synchronous calls.
| You can see more details about the CXF asynchronous client and how to tune it further in CXF documentation. |
Asynchronous Clients and Mutiny
Asynchronous client invocations require some additional methods in the service endpoint interface. That code is not generated by default.
To enable it, you need to create a JAX-WS binding file with enableAsyncMapping set to true:
<bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
wsdlLocation="AffectedWSDL"
xmlns="http://java.sun.com/xml/ns/jaxws">
<bindings node="AffectedNode">
<enableAsyncMapping>true</enableAsyncMapping>
</bindings>
</bindings>
This file should then be passed to wsdl2java through its additional-params property:
quarkus.cxf.java2ws.includes = HelloService.wsdl
quarkus.cxf.java2ws.foo-params.additional-params = -b,src/main/resources/binding.xml
Once the asynchronous stubs are available, it is possible to wrap a client call in io.smallrye.mutiny.Uni as shown below:
import jakarta.inject.Inject;
import io.smallrye.mutiny.Uni;
import io.quarkiverse.cxf.annotation.CXFClient;
class Client {
@Inject @CXFClient
CalculatorService calculator;
public Uni add(int a, int b) {
return Uni.createFrom().future(() ->
(Future)calculatorSoap.addAsync(a, b, res -> {}));
}
}
| A sample application demonstrating this flow is available here. |