This document explains how the axis2_json_rpc_msg_recv messageReceiver defined in services.xml gets automatically invoked at runtime when HTTP/2 requests with Content-Type: application/json are received by Axis2/C services.
Unlike the axis2.xml file (which requires no changes for HTTP/2), the services.xml file defines the specific messageReceiver that handles JSON requests for each operation. The runtime system automatically invokes the correct messageReceiver based on the HTTP headers and request characteristics.
From ./samples/user_guide/camera-control-service/services.xml:
<operation name="startRecording"> <description> Start camera recording with specified parameters. Accepts clip_name, quality, duration, and format parameters. </description> <messageReceiver class="axis2_json_rpc_msg_recv"/> <!-- REST-style HTTP mapping --> <parameter name="httpMethod">POST</parameter> <parameter name="httpPath">/startRecording</parameter> <parameter name="contentType">application/json</parameter> <parameter name="responseType">application/json</parameter> </operation>
When a client sends an HTTP/2 JSON request:
curl -k --http2 -H "Content-Type: application/json" \ -X POST -d '{"startRecording":[{"clip_name":"meeting_001","quality":"1080p"}]}' \ https://localhost:8443/axis2/services/CameraControlService
The Apache2 request processor factory (axis2_apache2_request_processor_factory.c:66-135) analyzes:
request->protocolThe HTTP transport layer:
/axis2/services/CameraControlService)"startRecording")<operation name="startRecording"> in services.xmlIn engine.c:311, the engine calls:
receiver = axis2_op_get_msg_recv(op, env);
This retrieves the messageReceiver configured in services.xml:
<messageReceiver class="axis2_json_rpc_msg_recv"/>
In engine.c:318-319, the engine invokes:
status = axis2_msg_recv_receive(receiver, env, msg_ctx, axis2_msg_recv_get_derived(receiver, env));
The axis2_json_rpc_msg_recv receiver (src/core/receivers/axis2_json_rpc_msg_recv.c):
axutil_class_loader_create_dll() via the ServiceClass parameterdlsym(RTLD_DEFAULT, "<serviceclass>_invoke_json") to find the service's JSON handler in the already-loaded .soaxis2_char_t* <serviceclass>_invoke_json( axis2_svc_t *svc, const axutil_env_t *env, const axis2_char_t *json_request, axis2_msg_ctx_t *msg_ctx);
Android path: On Android (__ANDROID__), services are statically linked and use a 2-param signature via the static service registry instead of dlsym. See docs/HTTP2_ANDROID.md.
Each operation explicitly defines its message receiver:
<operation name="startRecording"> <messageReceiver class="axis2_json_rpc_msg_recv"/> </operation> <operation name="stopRecording"> <messageReceiver class="axis2_json_rpc_msg_recv"/> </operation> <operation name="getStatus"> <messageReceiver class="axis2_json_rpc_msg_recv"/> </operation>
Service-level HTTP/2 optimization parameters:
<parameter name="transport.h2"> <parameter name="enableHTTP2">true</parameter> <parameter name="enableStreaming">true</parameter> <parameter name="enableMemoryOptimization">true</parameter> <parameter name="maxFrameSize">16384</parameter> <parameter name="maxConcurrentStreams">50</parameter> </parameter>
Pure JSON processing without SOAP/XML dependencies:
<parameter name="maxJSONPayloadSize">1048576</parameter> <parameter name="jsonProcessingMode">pure-jsonc</parameter>
Each operation can define HTTP-specific parameters:
<parameter name="httpMethod">POST</parameter> <parameter name="httpPath">/startRecording</parameter> <parameter name="contentType">application/json</parameter> <parameter name="responseType">application/json</parameter>
The system automatically selects the appropriate processing path:
| HTTP Protocol | Content-Type | Request Processor | Message Receiver Used |
|---|---|---|---|
| HTTP/2.0 | application/json | JSON Processor | axis2_json_rpc_msg_recv |
| HTTP/2.0 | text/xml | JSON Processor* | axis2_json_rpc_msg_recv |
| HTTP/1.1 | application/json | SOAP Processor | axis2_raw_xml_in_out_msg_recv** |
| HTTP/1.1 | text/xml | SOAP Processor | axis2_raw_xml_in_out_msg_recv |
* HTTP/2 assumes modern client capabilities ** Falls back to traditional processing for safety
Services can define different message receivers for different operations:
<service name="HybridService"> <!-- JSON operation for modern HTTP/2 clients --> <operation name="processJson"> <messageReceiver class="axis2_json_rpc_msg_recv"/> <parameter name="contentType">application/json</parameter> </operation> <!-- SOAP operation for legacy HTTP/1.1 clients --> <operation name="processSoap"> <messageReceiver class="axis2_raw_xml_in_out_msg_recv"/> <parameter name="contentType">text/xml</parameter> </operation> </service>
From src/core/receivers/axis2_json_rpc_msg_recv.c:19-30:
/** * @file axis2_json_rpc_msg_recv.c * @brief Revolutionary JsonRpcMessageReceiver - AXIOM-FREE Core Framework Component * * This is the Axis2/C equivalent of Axis2/Java's JsonRpcMessageReceiver. * Revolutionary: Completely bypasses AXIOM/SOAP - pure JSON processing only. * * Key Revolutionary Features: * - Zero AXIOM dependencies (no XML processing at all) * - Direct JSON-to-service-function invocation * - Framework-level component (not service-specific) * - HTTP/2 streaming optimized */
axis2_json_rpc_msg_recv for all JSON operationsapplication/json content types<operation name="operationName"> <description>Clear description of operation functionality</description> <messageReceiver class="axis2_json_rpc_msg_recv"/> <parameter name="httpMethod">POST</parameter> <parameter name="httpPath">/operationName</parameter> <parameter name="contentType">application/json</parameter> <parameter name="responseType">application/json</parameter> </operation>
{ "operationName": [{ "arg0": { "parameter1": "value1", "parameter2": "value2" } }] }
application/json headerCheck engine logs for message receiver selection:
🏭 REQUEST PROCESSOR FACTORY: Creating JSON HTTP/2 processor for thread-safe processing 🚀 JSON Message Receiver: Processing HTTP/2 JSON request for operation 'startRecording'
The services.xml messageReceiver configuration provides fine-grained control over how individual operations process requests. By configuring axis2_json_rpc_msg_recv for operations, services get:
This design enables seamless hybrid services that support both modern HTTP/2 JSON clients and legacy SOAP clients with a single service configuration.