No axis2.xml changes are required for HTTP/2 and JSON support in Axis2/C. This document explains why Axis2/C differs from Axis2/Java in this regard and provides a comprehensive comparison of the architectural approaches.
Unlike Axis2/Java, Axis2/C automatically detects and handles HTTP/2 with JSON content without requiring any axis2.xml configuration changes. The request processing is determined at runtime through intelligent header analysis rather than static configuration.
Axis2/C uses the axis2_apache2_request_processor_is_json_http2_request() function in /home/robert/repos/axis-axis2-c-core/src/core/transport/http/server/apache2/axis2_apache2_request_processor_factory.c:253-283 to automatically detect:
request->protocol for “HTTP/2” or “HTTP/2.0” stringsapplication/jsontext/jsonapplication/hal+jsonapplication/vnd.api+jsonAXIS2_EXTERN axis2_bool_t AXIS2_CALL axis2_apache2_request_processor_is_json_http2_request(request_rec* request) { const axis2_char_t* content_type = NULL; const axis2_char_t* protocol = NULL; if (!request) return AXIS2_FALSE; /* Check protocol version */ protocol = request->protocol; if (!protocol || (!strstr(protocol, "HTTP/2") && !strstr(protocol, "HTTP/2.0"))) { return AXIS2_FALSE; } /* Check content type */ content_type = apr_table_get(request->headers_in, "Content-Type"); if (!content_type) { content_type = apr_table_get(request->headers_in, "content-type"); } if (!content_type) return AXIS2_FALSE; /* JSON content type detection */ return (strstr(content_type, "application/json") != NULL || strstr(content_type, "text/json") != NULL || strstr(content_type, "application/hal+json") != NULL || strstr(content_type, "application/vnd.api+json") != NULL) ? AXIS2_TRUE : AXIS2_FALSE; }
The factory method at axis2_apache2_request_processor_factory.c:66-135 implements a decision matrix:
Simply send an HTTP/2 request with the appropriate Content-Type header:
curl -k --http2 -H "Content-Type: application/json" \ -X POST -d '{"getCameraStatus":[]}' \ https://localhost:8443/axis2/services/CameraControlService
No axis2.xml configuration is needed - the system automatically routes to the appropriate processor.
Based on the Spring Boot user guide (/home/robert/repos/axis-axis2-java-core/src/site/xdoc/docs/json-springboot-userguide.xml), Axis2/Java requires explicit axis2.xml configuration because it uses a static configuration model where message processors are pre-configured rather than dynamically selected.
<message name="requestMessage"> <messageFormatter contentType="application/json" class="org.apache.axis2.json.moshi.JsonFormatter"/> </message>
Required classes mentioned in the Java documentation:
JsonRpcMessageReceiverJsonInOnlyRPCMessageReceiverJsonBuilderJSONBasedDefaultDispatcherJSONMessageHandler<transportSender name="h2" class="org.apache.axis2.transport.h2.impl.httpclient5.H2TransportSender"> <parameter name="PROTOCOL">HTTP/2.0</parameter> <parameter name="maxConcurrentStreams">100</parameter> <parameter name="initialWindowSize">65536</parameter> <parameter name="serverPushEnabled">false</parameter> <parameter name="connectionTimeout">30000</parameter> <parameter name="responseTimeout">300000</parameter> <parameter name="streamingBufferSize">65536</parameter> <parameter name="memoryPressureThreshold">0.8</parameter> <!-- Enterprise Big Data Configuration --> <parameter name="enableStreamingOptimization">true</parameter> <parameter name="enableMemoryOptimization">true</parameter> <parameter name="largePayloadThreshold">52428800</parameter> <!-- 50MB --> </transportSender>
Note on Buffer Sizes: The 64KB values shown above (initialWindowSize, streamingBufferSize) are Axis2/Java defaults. Axis2/C uses an incremental buffer growth approach:
maxJSONPayloadSize in services.xml (default 10MB)malloc/realloc since AXIS2_REALLOC is unreliableMemory Efficiency Comparison:
| Payload | Axis2/C (incremental) | Static 10MB | Savings |
|---|---|---|---|
| IoT/Camera (~24B) | 64KB | 10MB | 160x |
| Medium JSON (~50KB) | 64KB | 10MB | 160x |
| Large portfolio (~235KB) | 256KB | 10MB | 40x |
Content-Type: application/jsonThe fundamental difference between Axis2/C and Axis2/Java lies in their architectural philosophy:
This makes Axis2/C significantly easier to deploy for HTTP/2 and JSON scenarios while maintaining full backward compatibility with existing SOAP services. The intelligent request processor factory ensures that each request type gets appropriate handling without any manual configuration.
For HTTP/2 and JSON support, developers can focus on service implementation rather than configuration management, as the framework handles protocol and content-type detection transparently.