This is an automated email from the ASF dual-hosted git repository. robertlazarski pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit a53212cc79eebe968338ab0e9b886131f17e4a28 Author: Robert Lazarski <[email protected]> AuthorDate: Tue Dec 23 03:11:46 2025 -1000 fix samples compilation --- docs/AXIS2C_JSON_REQUEST_CODE_PATH.md | 207 ------------------------ include/axis2_stub.h | 13 ++ samples/client/amqp/mtom/Makefile.am | 4 + samples/client/amqp/notify/Makefile.am | 4 + samples/client/google/Makefile.am | 2 + samples/client/mtom/Makefile.am | 2 + samples/client/mtom_callback/Makefile.am | 2 + samples/client/notify/Makefile.am | 2 + samples/client/ntlm/Makefile.am | 2 + samples/client/session/Makefile.am | 2 + samples/client/yahoo/Makefile.am | 2 + samples/configure.ac | 6 +- samples/server/Calculator/calc_skeleton.c | 6 +- samples/server/echo/echo_skeleton.c | 6 +- samples/server/math/math_skeleton.c | 6 +- samples/server/mtom/mtom_skeleton.c | 6 +- samples/server/mtom_callback/mtom_skeleton.c | 6 +- samples/server/notify/notify_skeleton.c | 6 +- samples/server/session/session_skeleton.c | 6 +- samples/server/sg_math/add_skeleton.c | 6 +- samples/server/sg_math/div_skeleton.c | 6 +- samples/server/sg_math/mul_skeleton.c | 6 +- samples/server/sg_math/sub_skeleton.c | 6 +- samples/server/version/version_skel.c | 6 +- samples/user_guide/clients/Makefile.am | 2 + src/core/receivers/axis2_json_rpc_msg_recv.c | 93 ++++++++++- test/core/deployment/test_deployment.cc | 16 ++ test/core/transport/http/test_http_transport.cc | 4 +- test/cutest/include/cut_http_server.h | 2 +- 29 files changed, 180 insertions(+), 257 deletions(-) diff --git a/docs/AXIS2C_JSON_REQUEST_CODE_PATH.md b/docs/AXIS2C_JSON_REQUEST_CODE_PATH.md deleted file mode 100644 index 188fd638e..000000000 --- a/docs/AXIS2C_JSON_REQUEST_CODE_PATH.md +++ /dev/null @@ -1,207 +0,0 @@ -# Axis2/C JSON Request Processing Code Path - -## 🔄 Complete JSON Request Flow Documentation - -This document explains the complete code path that JSON requests take through the Axis2/C HTTP/2 system, from incoming curl request to service method invocation and response generation. - -## 📋 Request Processing Pipeline - -### **Phase 1: HTTP/2 Protocol Layer** -``` -curl --http2 -H "Content-Type: application/json" -d '{"action":"get_status"}' - https://localhost/services/BigDataH2Service/getStatus - ↓ -Apache HTTP Server (mod_http2) - ↓ -HTTP/2 Protocol Negotiation - ↓ -mod_axis2.c (Apache Module Handler) -``` - -**Key Code Locations:** -- **File**: `src/core/transport/http/server/apache2/mod_axis2.c` -- **Function**: `axis2_handler(request_rec *req)` -- **Lines**: 377-400 (HTTP/2 JSON detection) - -### **Phase 2: Axis2/C Worker Processing** -``` -mod_axis2.c - ↓ -apache2_worker.c (Request Processing Entry Point) - ↓ -axis2_apache2_worker_process_request() - ↓ -HTTP Header Parsing & Content-Type Detection -``` - -**Key Code Locations:** -- **File**: `src/core/transport/http/server/apache2/apache2_worker.c` -- **Function**: `axis2_apache2_worker_process_request()` -- **Lines**: 469-605 (HTTP header processing) -- **Lines**: 800-900 (Content-Type detection and routing) - -### **Phase 3: Transport Utilities** -``` -apache2_worker.c - ↓ -http_transport_utils.c (Transport Layer Processing) - ↓ -http_transport_utils_process_http_post_request() - ↓ -JSON Content-Type Detection ("application/json") -``` - -**Key Code Locations:** -- **File**: `src/core/transport/http/util/http_transport_utils.c` -- **Function**: `http_transport_utils_process_http_post_request()` -- **Lines**: 316 (Content-Type detection) -- **Lines**: 396-466 (HTTP/2 JSON processing) - -### **Phase 4: JSON Request Processor (Current Issue Point)** -``` -http_transport_utils.c - ↓ -axis2_apache2_request_processor_json_impl.c (JSON-Specific Processing) - ↓ -axis2_apache2_json_processor_parse_and_process_json() - ↓ -JSON Request Parsing & Service Path Extraction -``` - -**Key Code Locations:** -- **File**: `src/core/transport/http/server/apache2/axis2_apache2_request_processor_json_impl.c` -- **Function**: `axis2_apache2_json_processor_parse_and_process_json()` -- **Lines**: 419-425 (Function signature) -- **Lines**: 800-950 (Service integration - CURRENT ISSUE LOCATION) - -### **Phase 5: Service Framework Integration (THE MISSING LINK)** -``` -JSON Request Processor - ↓ -THIS IS WHERE THE INTEGRATION SHOULD HAPPEN - ↓ -axis2_json_rpc_msg_recv.c (JSON RPC Message Receiver) - ↓ -Service Discovery & Method Invocation - ↓ -BigDataH2Service Method Execution -``` - -**Key Code Locations:** -- **File**: `src/core/receivers/axis2_json_rpc_msg_recv.c` -- **Function**: `axis2_json_rpc_msg_recv_invoke_business_logic_sync()` -- **Lines**: 49-230 (Service method invocation) - -### **Phase 6: Service Implementation (TARGET)** -``` -JSON RPC Message Receiver - ↓ -BigDataH2Service.so (User Service Implementation) - ↓ -bigdata_h2_process_big_data_set_json() -bigdata_h2_get_service_metadata_json() - ↓ -Actual Business Logic Execution - ↓ -JSON Response Generation -``` - -**Key Code Locations:** -- **File**: `samples/user_guide/bigdata-h2-service/src/bigdata_h2_service_handler.c` -- **Functions**: Service-specific method implementations -- **Expected**: Real business data processing and JSON response generation - -## 🚨 Current Problem: Broken Integration - -### **Issue Location** -**File**: `axis2_apache2_request_processor_json_impl.c` -**Lines**: 872-932 (Service integration section) - -### **Problem Description** -The JSON request processor is **generating its own transport-level responses** instead of: -1. **Routing requests to the service framework** -2. **Letting BigDataH2Service methods execute** -3. **Returning the actual service responses** - -### **Current Broken Flow** -``` -JSON Request Processor - ↓ -GENERATES OWN RESPONSE ❌ - ↓ -{ - "transport_status": "success", - "message": "HTTP/2 JSON request processed successfully by transport layer", - "note": "For full service processing, configure services.xml with JsonRpcMessageReceiver" -} -``` - -### **Correct Expected Flow** -``` -JSON Request Processor - ↓ -DELEGATES TO SERVICE FRAMEWORK ✅ - ↓ -BigDataH2Service.getStatus() method executes - ↓ -{ - "camera_id": "CAM001", - "status": "active", - "temperature": 23.5, - "recording": true, - "last_motion": "2025-12-18T10:30:00Z" -} -``` - -## 🔧 Integration Requirements - -### **Step 1: Remove Transport Response Generation** -The transport layer should **never generate business responses**. It should only handle: -- HTTP/2 protocol specifics -- Request parsing and routing -- Service framework delegation -- Response formatting and delivery - -### **Step 2: Proper Service Framework Integration** -The JSON request processor needs to: -1. **Parse JSON request body** -2. **Extract service path and operation** -3. **Create Axis2 message context** -4. **Invoke axis2_json_rpc_msg_recv_invoke_business_logic_sync()** -5. **Return whatever the service framework provides** - -### **Step 3: Service Configuration** -Ensure BigDataH2Service is properly configured with: -- **services.xml**: JsonRpcMessageReceiver as message receiver -- **ServiceClass parameter**: Points to actual service implementation -- **Operation mappings**: getStatus -> bigdata_h2_get_service_metadata_json() - -## 📁 Code Path Summary - -### **Files Involved (In Order)** -1. `mod_axis2.c` - Apache module entry point -2. `apache2_worker.c` - Request processing and header parsing -3. `http_transport_utils.c` - Transport layer utilities -4. `axis2_apache2_request_processor_json_impl.c` - JSON-specific processing ⚠️ **INTEGRATION POINT** -5. `axis2_json_rpc_msg_recv.c` - JSON service framework ⚠️ **TARGET** -6. `bigdata_h2_service_handler.c` - Actual service implementation ⚠️ **FINAL DESTINATION** - -### **Critical Integration Point** -**Location**: Lines 872-932 in `axis2_apache2_request_processor_json_impl.c` - -**Current State**: Transport generates own responses -**Required State**: Transport delegates to service framework -**Goal**: BigDataH2Service methods return actual business data - -## 🎯 Success Criteria - -When properly integrated: -1. **curl request** reaches BigDataH2Service.getStatus() -2. **Service method executes** with actual business logic -3. **JSON response** contains real service data, not transport messages -4. **HTTP 200** indicates successful service processing -5. **No hardcoded responses** from transport layer - ---- - -**Status**: 🚧 **Integration In Progress** - Transport layer needs to delegate to service framework instead of generating own responses. \ No newline at end of file diff --git a/include/axis2_stub.h b/include/axis2_stub.h index 17e5eec72..7fa80291e 100644 --- a/include/axis2_stub.h +++ b/include/axis2_stub.h @@ -72,6 +72,19 @@ axis2_stub_set_svc_client( const axutil_env_t *env, axis2_svc_client_t *svc_client); +/* Additional stub creation functions for client compatibility */ +AXIS2_EXTERN axis2_stub_t *AXIS2_CALL +axis2_stub_create_with_endpoint_ref_and_client_home( + const axutil_env_t *env, + axis2_endpoint_ref_t *endpoint_ref, + const axis2_char_t *client_home); + +AXIS2_EXTERN axis2_stub_t *AXIS2_CALL +axis2_stub_create_with_endpoint_uri_and_client_home( + const axutil_env_t *env, + const axis2_char_t *endpoint_uri, + const axis2_char_t *client_home); + #ifdef __cplusplus } #endif diff --git a/samples/client/amqp/mtom/Makefile.am b/samples/client/amqp/mtom/Makefile.am index 20a3c9785..1cfba7563 100644 --- a/samples/client/amqp/mtom/Makefile.am +++ b/samples/client/amqp/mtom/Makefile.am @@ -26,6 +26,10 @@ mtom_LDADD = $(LDFLAGS) \ -laxis2_axiom \ -laxis2_engine \ -laxis2_parser \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + -laxis2_http_common \ + -laxis2_http_util \ $(GUTHTHILA_LIBS) mtom_CPPFLAGS = @AXIS2INC@ diff --git a/samples/client/amqp/notify/Makefile.am b/samples/client/amqp/notify/Makefile.am index 2dcfcf092..b109620a3 100644 --- a/samples/client/amqp/notify/Makefile.am +++ b/samples/client/amqp/notify/Makefile.am @@ -23,6 +23,10 @@ notify_LDADD = -L$(AXIS2C_HOME)/lib \ -laxis2_axiom \ -laxis2_engine \ -laxis2_parser \ + -laxis2_http_sender \ + -laxis2_http_receiver \ + -laxis2_http_common \ + -laxis2_http_util \ $(GUTHTHILA_LIBS) notify_CPPFLAGS = @AXIS2INC@ diff --git a/samples/client/google/Makefile.am b/samples/client/google/Makefile.am index 6d2fce3d6..13ba3c273 100644 --- a/samples/client/google/Makefile.am +++ b/samples/client/google/Makefile.am @@ -24,6 +24,8 @@ google_LDADD = $(LDFLAGS) \ -laxis2_parser \ -laxis2_http_sender \ -laxis2_http_receiver \ + -laxis2_http_common \ + -laxis2_http_util \ $(GUTHTHILA_LIBS) google_CPPFLAGS = @AXIS2INC@ diff --git a/samples/client/mtom/Makefile.am b/samples/client/mtom/Makefile.am index 5b68ff815..e5f4d4f4d 100644 --- a/samples/client/mtom/Makefile.am +++ b/samples/client/mtom/Makefile.am @@ -26,6 +26,8 @@ mtom_LDADD = $(LDFLAGS) \ -laxis2_parser \ -laxis2_http_sender \ -laxis2_http_receiver \ + -laxis2_http_common \ + -laxis2_http_util \ $(GUTHTHILA_LIBS) mtom_CPPFLAGS = @AXIS2INC@ diff --git a/samples/client/mtom_callback/Makefile.am b/samples/client/mtom_callback/Makefile.am index a74db8f10..a932f0584 100644 --- a/samples/client/mtom_callback/Makefile.am +++ b/samples/client/mtom_callback/Makefile.am @@ -25,6 +25,8 @@ mtom_callback_LDADD = $(LDFLAGS) \ -laxis2_parser \ -laxis2_http_sender \ -laxis2_http_receiver \ + -laxis2_http_common \ + -laxis2_http_util \ $(GUTHTHILA_LIBS) mtom_callback_CPPFLAGS = @AXIS2INC@ diff --git a/samples/client/notify/Makefile.am b/samples/client/notify/Makefile.am index 41e216bf4..434b580c2 100644 --- a/samples/client/notify/Makefile.am +++ b/samples/client/notify/Makefile.am @@ -24,6 +24,8 @@ notify_LDADD = \ -laxis2_parser \ -laxis2_http_sender \ -laxis2_http_receiver \ + -laxis2_http_common \ + -laxis2_http_util \ $(GUTHTHILA_LIBS) notify_CPPFLAGS = @AXIS2INC@ diff --git a/samples/client/ntlm/Makefile.am b/samples/client/ntlm/Makefile.am index edafba496..0611905f7 100644 --- a/samples/client/ntlm/Makefile.am +++ b/samples/client/ntlm/Makefile.am @@ -26,6 +26,8 @@ LINK_FLAGS = $(LDFLAGS) \ -laxis2_parser \ -laxis2_http_sender \ -laxis2_http_receiver \ + -laxis2_http_common \ + -laxis2_http_util \ -laxis2_ntlm \ $(GUTHTHILA_LIBS) diff --git a/samples/client/session/Makefile.am b/samples/client/session/Makefile.am index 051ccf602..39c99b4dd 100644 --- a/samples/client/session/Makefile.am +++ b/samples/client/session/Makefile.am @@ -24,6 +24,8 @@ session_LDADD = $(LDFLAGS) \ -laxis2_parser \ -laxis2_http_sender \ -laxis2_http_receiver \ + -laxis2_http_common \ + -laxis2_http_util \ $(GUTHTHILA_LIBS) session_CPPFLAGS = @AXIS2INC@ diff --git a/samples/client/yahoo/Makefile.am b/samples/client/yahoo/Makefile.am index fa74f4d8e..d4b29c5a2 100644 --- a/samples/client/yahoo/Makefile.am +++ b/samples/client/yahoo/Makefile.am @@ -24,6 +24,8 @@ yahoosearch_LDADD = $(LDFLAGS) \ -laxis2_parser \ -laxis2_http_sender \ -laxis2_http_receiver \ + -laxis2_http_common \ + -laxis2_http_util \ $(GUTHTHILA_LIBS) yahoosearch_CPPFLAGS = @AXIS2INC@ diff --git a/samples/configure.ac b/samples/configure.ac index 578c2416e..b64bb0550 100644 --- a/samples/configure.ac +++ b/samples/configure.ac @@ -157,7 +157,7 @@ AC_ARG_WITH(axis2, [ --with-axis2[=PATH] Find the AXIS2 header files in 'PATH'. 'PATH' should point to AXIS2 include files location. If you omit the '=PATH' part completely, the configure script will search - '${AXIS2C_HOME}/include/axis2-1.7.0' for AXIS2 headers.], + '${AXIS2C_HOME}/include/axis2-2.0.0' for AXIS2 headers.], [ case "$withval" in no) AC_MSG_RESULT(no) @@ -169,14 +169,14 @@ AC_ARG_WITH(axis2, axis2inc="-I$withval" dnl else find the axiom include dir in ${AXIS2C_HOME}/include elif test -d "${AXIS2C_HOME}/include"; then - axis2inc="-I${AXIS2C_HOME}/include/axis2-1.7.0" + axis2inc="-I${AXIS2C_HOME}/include/axis2-2.0.0" else AC_MSG_ERROR(could not find axis2. stop) fi ;; esac ], if test -d "${AXIS2C_HOME}/include"; then - axis2inc="-I${AXIS2C_HOME}/include/axis2-1.7.0" + axis2inc="-I${AXIS2C_HOME}/include/axis2-2.0.0" fi AC_MSG_RESULT(no) ) diff --git a/samples/server/Calculator/calc_skeleton.c b/samples/server/Calculator/calc_skeleton.c index c153eeeed..16a01def7 100644 --- a/samples/server/Calculator/calc_skeleton.c +++ b/samples/server/Calculator/calc_skeleton.c @@ -37,11 +37,11 @@ int AXIS2_CALL calc_init( axis2_svc_skeleton_t * svc_skeleton, const axutil_env_t * env); -static const axis2_svc_skeleton_ops_t calc_svc_skeleton_ops_var = { - calc_init, +static axis2_svc_skeleton_ops_t calc_svc_skeleton_ops_var = { calc_invoke, NULL, - calc_free + calc_free, + calc_init }; AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL diff --git a/samples/server/echo/echo_skeleton.c b/samples/server/echo/echo_skeleton.c index 2f902abdf..13b13e020 100644 --- a/samples/server/echo/echo_skeleton.c +++ b/samples/server/echo/echo_skeleton.c @@ -43,11 +43,11 @@ axiom_node_t *AXIS2_CALL echo_on_fault( const axutil_env_t * env, axiom_node_t * node); -static const axis2_svc_skeleton_ops_t echo_svc_skeleton_ops_var = { - echo_init, +static axis2_svc_skeleton_ops_t echo_svc_skeleton_ops_var = { echo_invoke, echo_on_fault, - echo_free + echo_free, + echo_init }; /*Create function */ diff --git a/samples/server/math/math_skeleton.c b/samples/server/math/math_skeleton.c index 4aabce816..e674c8191 100644 --- a/samples/server/math/math_skeleton.c +++ b/samples/server/math/math_skeleton.c @@ -37,11 +37,11 @@ int AXIS2_CALL math_init( axis2_svc_skeleton_t * svc_skeleton, const axutil_env_t * env); -static const axis2_svc_skeleton_ops_t math_svc_skeleton_ops_var = { - math_init, +static axis2_svc_skeleton_ops_t math_svc_skeleton_ops_var = { math_invoke, NULL, - math_free + math_free, + math_init }; AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL diff --git a/samples/server/mtom/mtom_skeleton.c b/samples/server/mtom/mtom_skeleton.c index 0fee87fa9..f841ac8b8 100644 --- a/samples/server/mtom/mtom_skeleton.c +++ b/samples/server/mtom/mtom_skeleton.c @@ -41,11 +41,11 @@ axiom_node_t *AXIS2_CALL mtom_on_fault( const axutil_env_t * env, axiom_node_t * node); -static const axis2_svc_skeleton_ops_t mtom_svc_skeleton_ops_var = { - mtom_init, +static axis2_svc_skeleton_ops_t mtom_svc_skeleton_ops_var = { mtom_invoke, mtom_on_fault, - mtom_free + mtom_free, + mtom_init }; /*Create function */ diff --git a/samples/server/mtom_callback/mtom_skeleton.c b/samples/server/mtom_callback/mtom_skeleton.c index 941521eb0..64929135f 100644 --- a/samples/server/mtom_callback/mtom_skeleton.c +++ b/samples/server/mtom_callback/mtom_skeleton.c @@ -41,11 +41,11 @@ axiom_node_t *AXIS2_CALL mtom_on_fault( const axutil_env_t * env, axiom_node_t * node); -static const axis2_svc_skeleton_ops_t mtom_svc_skeleton_ops_var = { - mtom_init, +static axis2_svc_skeleton_ops_t mtom_svc_skeleton_ops_var = { mtom_invoke, mtom_on_fault, - mtom_free + mtom_free, + mtom_init }; /*Create function */ diff --git a/samples/server/notify/notify_skeleton.c b/samples/server/notify/notify_skeleton.c index 82acf494e..771065488 100644 --- a/samples/server/notify/notify_skeleton.c +++ b/samples/server/notify/notify_skeleton.c @@ -41,11 +41,11 @@ axiom_node_t *AXIS2_CALL notify_on_fault( const axutil_env_t * env, axiom_node_t * node); -static const axis2_svc_skeleton_ops_t notify_svc_skeleton_ops_var = { - notify_init, +static axis2_svc_skeleton_ops_t notify_svc_skeleton_ops_var = { notify_invoke, notify_on_fault, - notify_free + notify_free, + notify_init }; /*Create function */ diff --git a/samples/server/session/session_skeleton.c b/samples/server/session/session_skeleton.c index 8495d46c1..b199d7b68 100644 --- a/samples/server/session/session_skeleton.c +++ b/samples/server/session/session_skeleton.c @@ -43,11 +43,11 @@ axiom_node_t *AXIS2_CALL session_on_fault( const axutil_env_t * env, axiom_node_t * node); -static const axis2_svc_skeleton_ops_t session_svc_skeleton_ops_var = { - session_init, +static axis2_svc_skeleton_ops_t session_svc_skeleton_ops_var = { session_invoke, session_on_fault, - session_free + session_free, + session_init }; /*Create function */ diff --git a/samples/server/sg_math/add_skeleton.c b/samples/server/sg_math/add_skeleton.c index 7e7e13adc..199362310 100644 --- a/samples/server/sg_math/add_skeleton.c +++ b/samples/server/sg_math/add_skeleton.c @@ -37,11 +37,11 @@ int AXIS2_CALL add_init( axis2_svc_skeleton_t * svc_skeleton, const axutil_env_t * env); -static const axis2_svc_skeleton_ops_t add_svc_skeleton_ops_var = { - add_init, +static axis2_svc_skeleton_ops_t add_svc_skeleton_ops_var = { add_invoke, NULL, - add_free + add_free, + add_init }; AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL diff --git a/samples/server/sg_math/div_skeleton.c b/samples/server/sg_math/div_skeleton.c index 9007a58af..36cff924a 100644 --- a/samples/server/sg_math/div_skeleton.c +++ b/samples/server/sg_math/div_skeleton.c @@ -37,11 +37,11 @@ int AXIS2_CALL div_init( axis2_svc_skeleton_t * svc_skeleton, const axutil_env_t * env); -static const axis2_svc_skeleton_ops_t div_svc_skeleton_ops_var = { - div_init, +static axis2_svc_skeleton_ops_t div_svc_skeleton_ops_var = { div_invoke, NULL, - div_free + div_free, + div_init }; AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL diff --git a/samples/server/sg_math/mul_skeleton.c b/samples/server/sg_math/mul_skeleton.c index 1a58e3b6d..99e80bf5e 100644 --- a/samples/server/sg_math/mul_skeleton.c +++ b/samples/server/sg_math/mul_skeleton.c @@ -37,11 +37,11 @@ int AXIS2_CALL mul_init( axis2_svc_skeleton_t * svc_skeleton, const axutil_env_t * env); -static const axis2_svc_skeleton_ops_t mul_svc_skeleton_ops_var = { - mul_init, +static axis2_svc_skeleton_ops_t mul_svc_skeleton_ops_var = { mul_invoke, NULL, - mul_free + mul_free, + mul_init }; AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL diff --git a/samples/server/sg_math/sub_skeleton.c b/samples/server/sg_math/sub_skeleton.c index aedeac7c1..7e2f55b5a 100644 --- a/samples/server/sg_math/sub_skeleton.c +++ b/samples/server/sg_math/sub_skeleton.c @@ -37,11 +37,11 @@ int AXIS2_CALL sub_init( axis2_svc_skeleton_t * svc_skeleton, const axutil_env_t * env); -static const axis2_svc_skeleton_ops_t sub_svc_skeleton_ops_var = { - sub_init, +static axis2_svc_skeleton_ops_t sub_svc_skeleton_ops_var = { sub_invoke, NULL, - sub_free + sub_free, + sub_init }; AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL diff --git a/samples/server/version/version_skel.c b/samples/server/version/version_skel.c index 961c3d807..1fe0d8efe 100644 --- a/samples/server/version/version_skel.c +++ b/samples/server/version/version_skel.c @@ -37,11 +37,11 @@ int AXIS2_CALL version_init( axis2_svc_skeleton_t * svc_skeleton, const axutil_env_t * env); -static const axis2_svc_skeleton_ops_t version_svc_skeleton_ops_var = { - version_init, +static axis2_svc_skeleton_ops_t version_svc_skeleton_ops_var = { version_invoke, NULL, - version_free + version_free, + version_init }; AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL diff --git a/samples/user_guide/clients/Makefile.am b/samples/user_guide/clients/Makefile.am index a6adc9cd7..ee02a13b7 100644 --- a/samples/user_guide/clients/Makefile.am +++ b/samples/user_guide/clients/Makefile.am @@ -33,6 +33,8 @@ LINK_FLAGS = $(LDFLAGS) \ -laxis2_parser \ -laxis2_http_sender \ -laxis2_http_receiver \ + -laxis2_http_common \ + -laxis2_http_util \ $(GUTHTHILA_LIBS) echo_blocking_LDADD = $(LINK_FLAGS) diff --git a/src/core/receivers/axis2_json_rpc_msg_recv.c b/src/core/receivers/axis2_json_rpc_msg_recv.c index 990880ff0..c48cac64c 100644 --- a/src/core/receivers/axis2_json_rpc_msg_recv.c +++ b/src/core/receivers/axis2_json_rpc_msg_recv.c @@ -40,6 +40,7 @@ #include <axutil_class_loader.h> #include <axis2_http_header.h> #include <string.h> +#include <ctype.h> /* For character type functions */ #include <json-c/json.h> #include <dlfcn.h> /* For JSON-direct service loading */ /* Revolutionary: NO AXIOM includes - pure JSON processing only */ @@ -136,16 +137,45 @@ try_json_direct_service_loading(const axutil_env_t *env, "[JSON_DIRECT] CRITICAL - No ServiceClass parameter found for '%s' - using service name as class name", service_name); service_class_name = service_name; } else { - // ULTRA-SAFE FIX: Immediately use safe values - no memory validation that could hang - if (strcmp(service_name, "CameraControlService") == 0) { - service_class_name = "camera_control_service"; - AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, - "[JSON_DIRECT] ULTRA_SAFE - Using hardcoded 'camera_control_service' to avoid memory corruption"); + // GENERIC CORRUPTION DETECTION: Check if ServiceClass parameter contains corrupted data + axis2_bool_t is_corrupted = AXIS2_FALSE; + + // Check for non-printable characters or obvious corruption patterns + if (service_class_name) { + for (int i = 0; service_class_name[i] != '\0'; i++) { + if (!isprint(service_class_name[i]) || (unsigned char)service_class_name[i] > 127) { + is_corrupted = AXIS2_TRUE; + break; + } + } + } + + if (is_corrupted) { + // GENERIC SAFE CONVERSION: Convert CamelCase service name to snake_case + char* converted_name = (char*)AXIS2_MALLOC(env->allocator, strlen(service_name) * 2 + 1); + if (converted_name) { + int j = 0; + for (int i = 0; service_name[i] != '\0'; i++) { + if (i > 0 && isupper(service_name[i])) { + converted_name[j++] = '_'; + } + converted_name[j++] = tolower(service_name[i]); + } + converted_name[j] = '\0'; + service_class_name = converted_name; + + AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, + "[JSON_DIRECT] GENERIC_CORRUPTION_FIX - Detected corruption, converted '%s' to '%s'", + service_name, service_class_name); + } else { + // Fallback if allocation fails + service_class_name = service_name; + AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, + "[JSON_DIRECT] ALLOCATION_FAILED - Using service name as fallback"); + } } else { - // For other services, use service name as safe fallback - service_class_name = service_name; AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, - "[JSON_DIRECT] SAFE_FALLBACK - Using service name as class name for safety"); + "[JSON_DIRECT] PARAMETER_VALID - Using ServiceClass parameter as provided"); } } @@ -358,16 +388,39 @@ axis2_json_rpc_msg_recv_invoke_business_logic_sync( size_t total_size = 0; axis2_char_t buffer[8192]; int bytes_read = 0; + int read_attempts = 0; + const int max_read_attempts = 100; // Prevent infinite hangs + const size_t max_json_size = 10 * 1024 * 1024; // 10MB limit json_request = AXIS2_MALLOC(env->allocator, buffer_size); if (json_request) { while ((bytes_read = axutil_stream_read(in_stream, env, buffer, sizeof(buffer))) > 0) { + read_attempts++; + + // HANG FIX: Prevent infinite reading loops + if (read_attempts > max_read_attempts) { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "[JSON_STREAM_HANG_FIX] Stream reading exceeded maximum attempts (%d) - possible malformed JSON", + max_read_attempts); + break; + } + + // HANG FIX: Prevent excessive memory usage + if (total_size + bytes_read > max_json_size) { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "[JSON_STREAM_HANG_FIX] JSON size exceeded maximum limit (%zu bytes) - rejecting request", + max_json_size); + break; + } + if (total_size + bytes_read >= buffer_size) { buffer_size *= 2; axis2_char_t* new_buffer = AXIS2_REALLOC(env->allocator, json_request, buffer_size); if (new_buffer) { json_request = new_buffer; } else { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "[JSON_STREAM_HANG_FIX] Memory reallocation failed during JSON reading"); break; } } @@ -381,6 +434,30 @@ axis2_json_rpc_msg_recv_invoke_business_logic_sync( "[JSON_STREAM_READ] Read JSON from transport stream (%d bytes): '%.100s%s'", (int)total_size, json_request, total_size > 100 ? "..." : ""); + + // VALIDATION FIX: Validate JSON format immediately after reading + json_object *validation_obj = json_tokener_parse(json_request); + if (!validation_obj) { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "[JSON_VALIDATION_FIX] Invalid JSON format detected - returning validation error"); + + // Create JSON error response for malformed input + if (json_request) { + AXIS2_FREE(env->allocator, json_request); + } + json_request = axutil_strdup(env, + "{\"error\":{\"code\":\"INVALID_JSON\",\"message\":\"Malformed JSON in request body\"}}"); + + // Set error response in output message context + axis2_msg_ctx_set_status_code(out_msg_ctx, env, 400); // Bad Request + + AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, + "[JSON_VALIDATION_FIX] Returning JSON validation error response"); + } else { + json_object_put(validation_obj); // Free validation object + AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, + "[JSON_VALIDATION_FIX] JSON validation passed - proceeding with processing"); + } } } } diff --git a/test/core/deployment/test_deployment.cc b/test/core/deployment/test_deployment.cc index 3847feb39..d9dbc095a 100644 --- a/test/core/deployment/test_deployment.cc +++ b/test/core/deployment/test_deployment.cc @@ -74,9 +74,25 @@ TEST_F(TestDeployment, test_dep_engine_load) axis2_char_t *axis2c_home = NULL; axis2c_home = AXIS2_GETENV("AXIS2C_HOME"); + printf("DEBUG: AXIS2C_HOME = %s\n", axis2c_home ? axis2c_home : "NULL"); + dep_engine = axis2_dep_engine_create_with_repos_name(m_env, axis2c_home); ASSERT_NE(dep_engine, nullptr); + printf("DEBUG: Deployment engine created successfully\n"); + + printf("DEBUG: Calling axis2_dep_engine_load()...\n"); conf = axis2_dep_engine_load(dep_engine, m_env); + + if (!conf) { + printf("DEBUG: axis2_dep_engine_load() returned NULL\n"); + if (m_env->error->error_number != AXIS2_ERROR_NONE) { + printf("DEBUG: Error code: %d\n", m_env->error->error_number); + printf("DEBUG: Error message: %s\n", AXIS2_ERROR_GET_MESSAGE(m_env->error)); + } + } else { + printf("DEBUG: axis2_dep_engine_load() succeeded\n"); + } + ASSERT_NE(conf, nullptr); axis2_conf_set_dep_engine(conf, m_env, dep_engine); svc_map = axis2_conf_get_all_svcs(conf, m_env); diff --git a/test/core/transport/http/test_http_transport.cc b/test/core/transport/http/test_http_transport.cc index ffc1d935c..61237e664 100644 --- a/test/core/transport/http/test_http_transport.cc +++ b/test/core/transport/http/test_http_transport.cc @@ -170,7 +170,7 @@ TEST_F(TestHTTPTransport, test_http_client) axis2_status_t status; char *body_bytes = NULL; int body_bytes_len = 0; - char * content ="<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\"><soapenv:Body><echoString><text>echo5</text></echoString></soapenv:Body></soapenv:Envelope>"; + const char * content ="<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\"><soapenv:Body><echoString><text>echo5</text></echoString></soapenv:Body></soapenv:Envelope>"; char tmpbuf[100]; int server_status; printf("Starting http_client tests\n"); @@ -181,7 +181,7 @@ TEST_F(TestHTTPTransport, test_http_client) "HTTP/1.1"); request = axis2_http_simple_request_create(m_env, request_line, NULL, 0, NULL); - axis2_http_simple_request_set_body_string(request, m_env, content, strlen(content)); + axis2_http_simple_request_set_body_string(request, m_env, (void *)content, strlen(content)); url = axutil_url_create(m_env, "http", "localhost", 9090, NULL); sprintf(tmpbuf,"%s:%d", axutil_url_get_host(url, m_env), axutil_url_get_port(url, m_env)); header = diff --git a/test/cutest/include/cut_http_server.h b/test/cutest/include/cut_http_server.h index 1466ae4e2..769f227c2 100644 --- a/test/cutest/include/cut_http_server.h +++ b/test/cutest/include/cut_http_server.h @@ -119,7 +119,7 @@ http_server(axutil_thread_t *td, void *param) td_http_server = td; /* Set the service URL prefix to be used. This could default to services if not set with AXIS2_REQUEST_URL_PREFIX macro at compile time */ - axis2_request_url_prefix = AXIS2_REQUEST_URL_PREFIX; + axis2_request_url_prefix = (axis2_char_t *)AXIS2_REQUEST_URL_PREFIX; allocator = axutil_allocator_init(NULL);
