You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by ro...@apache.org on 2026/01/15 01:36:00 UTC
(axis-axis2-c-core) branch master updated (639dd76e9 -> ef9e13703)
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
from 639dd76e9 Enhance JSON writer/reader with AXIOM node support for HTTP/2 mode
new 0d6f6547e Revert "Enhance JSON writer/reader with AXIOM node support for HTTP/2 mode"
new ef9e13703 Add conditional compilation for JSON writer HTTP/1.1 vs HTTP/2 modes
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/core/transport/h2/test/Makefile.am | 8 --
src/core/transport/http/sender/axis2_json_writer.c | 95 +++++++++++++++++++++-
src/core/transport/http/util/axis2_json_reader.c | 3 +-
3 files changed, 93 insertions(+), 13 deletions(-)
(axis-axis2-c-core) 01/02: Revert "Enhance JSON writer/reader with AXIOM node support for HTTP/2 mode"
Posted by ro...@apache.org.
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 0d6f6547e33f6650fe4d3de00a493f168d11b329
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Wed Jan 14 14:59:49 2026 -1000
Revert "Enhance JSON writer/reader with AXIOM node support for HTTP/2 mode"
This reverts commit 639dd76e9bd8730e558ae8ebb24c55c729f0e1a1.
---
src/core/transport/h2/test/Makefile.am | 8 --
src/core/transport/http/sender/axis2_json_writer.c | 160 ++++-----------------
src/core/transport/http/util/axis2_json_reader.c | 3 +-
3 files changed, 29 insertions(+), 142 deletions(-)
diff --git a/src/core/transport/h2/test/Makefile.am b/src/core/transport/h2/test/Makefile.am
index 4b6d683db..391e2d29c 100644
--- a/src/core/transport/h2/test/Makefile.am
+++ b/src/core/transport/h2/test/Makefile.am
@@ -30,10 +30,6 @@ h2_json_integration_test_SOURCES = h2_json_integration_test.c \
h2_json_integration_test_LDADD = \
$(LDFLAGS) \
$(top_builddir)/util/src/libaxutil.la \
- $(top_builddir)/axiom/src/om/libaxis2_axiom.la \
- $(top_builddir)/axiom/src/parser/@WRAPPER_DIR@/libaxis2_parser.la \
- $(top_builddir)/src/core/engine/libaxis2_engine.la \
- $(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la \
$(top_builddir)/src/core/transport/http/util/libaxis2_http_util.la \
$(JSON_LIBS)
@@ -52,10 +48,6 @@ h2_performance_benchmark_test_SOURCES = h2_performance_benchmark_test.c \
h2_performance_benchmark_test_LDADD = \
$(LDFLAGS) \
$(top_builddir)/util/src/libaxutil.la \
- $(top_builddir)/axiom/src/om/libaxis2_axiom.la \
- $(top_builddir)/axiom/src/parser/@WRAPPER_DIR@/libaxis2_parser.la \
- $(top_builddir)/src/core/engine/libaxis2_engine.la \
- $(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la \
$(top_builddir)/src/core/transport/http/util/libaxis2_http_util.la \
$(JSON_LIBS) \
-lm
diff --git a/src/core/transport/http/sender/axis2_json_writer.c b/src/core/transport/http/sender/axis2_json_writer.c
index 41afcc624..84d2e5535 100644
--- a/src/core/transport/http/sender/axis2_json_writer.c
+++ b/src/core/transport/http/sender/axis2_json_writer.c
@@ -12,174 +12,70 @@
* limitations under the License.
*/
-#include <axiom_node.h>
-#include <axiom_element.h>
-#include <axiom_attribute.h>
+/* Revolutionary HTTP/2 JSON Architecture - AXIOM-free stub implementation */
#include <json-c/json.h>
+#include <string.h>
#include "axis2_json_writer.h"
-#define AXIS2_JSON_XSI_URI "http://www.w3.org/2001/XMLSchema-instance"
-
struct axis2_json_writer
{
json_object* json_obj;
};
-axis2_bool_t axis2_json_element_is_nil(axiom_element_t* om_element, const axutil_env_t* env)
-{
- axiom_attribute_t* attr = NULL;
- axutil_hash_index_t* index;
- axutil_hash_t* attr_hash = axiom_element_get_all_attributes(om_element, env);
- axis2_bool_t result = AXIS2_FALSE;
-
- if (!attr_hash)
- return AXIS2_FALSE;
-
- for (index = axutil_hash_first(attr_hash, env);
- index; index = axutil_hash_next(env, index))
- {
- axutil_hash_this(index, NULL, NULL, (void**)&attr);
- if (attr && !strcmp(axiom_attribute_get_localname(attr, env), "nil"))
- {
- /* found some "nil" attribute, check it namespace */
- axutil_qname_t* qname =
- axiom_attribute_get_qname(attr, env);
- if (qname && !strcmp(axutil_qname_get_uri(qname, env), AXIS2_JSON_XSI_URI))
- {
- axis2_char_t* attr_value =
- axiom_attribute_get_value(attr, env);
- result = (!strcmp(attr_value, "true") || !strcmp(attr_value, "1")) ?
- AXIS2_TRUE : AXIS2_FALSE;
- /* Found what we're looking for - use axutil_hash_index_free to cleanup */
- axutil_hash_index_free(index, env);
- return result;
- }
- }
- }
-
- return result;
-}
-
-void axis2_json_write_node(json_object* parent, axiom_node_t* om_node, const axutil_env_t* env)
-{
- axiom_element_t* elem;
- axiom_node_t* child_node;
- const axis2_char_t* local_name;
- json_object* obj;
- json_object* array = NULL;
-
- if (!om_node || axiom_node_get_node_type(om_node, env) != AXIOM_ELEMENT)
- return;
-
- elem = (axiom_element_t*)axiom_node_get_data_element(om_node, env);
- local_name = axiom_element_get_localname(elem, env);
-
- child_node = axiom_node_get_first_element(om_node, env);
-
- /* find existing object */
- if (json_object_object_get_ex(parent, local_name, &obj))
- {
- /* check that object is array? */
- if (!json_object_is_type(obj, json_type_array))
- {
- /* convert to array */
- obj = json_object_get(obj);
- array = json_object_new_array();
- json_object_array_add(array, obj);
- json_object_object_del(parent, local_name);
- json_object_object_add(parent, local_name, array);
- }
- else
- array = obj;
- }
-
- if (!child_node)
- {
- /* this is a leaf node */
- json_object* json_value = NULL;
-
- /* check for nillable */
- if (!axis2_json_element_is_nil(elem, env))
- {
- const axis2_char_t* value =
- axiom_element_get_text(elem, env, om_node);
- json_value = json_object_new_string(value ? value : "");
- }
-
- if (array)
- json_object_array_add(array, json_value);
- else
- json_object_object_add(parent, local_name, json_value);
- return;
- }
-
- /* iterate through children elements */
- obj = json_object_new_object();
- if (array)
- json_object_array_add(array, obj);
- else
- json_object_object_add(parent, local_name, obj);
-
- for (; child_node; child_node = axiom_node_get_next_sibling(child_node, env))
- if (axiom_node_get_node_type(child_node, env) == AXIOM_ELEMENT)
- axis2_json_write_node(obj, child_node, env);
-}
-
-
+/* Revolutionary AXIOM-free stub implementation */
AXIS2_EXTERN axis2_json_writer_t* AXIS2_CALL
-axis2_json_writer_create(
- const axutil_env_t* env)
+axis2_json_writer_create(const axutil_env_t* env)
{
+ /* Revolutionary: Stub implementation - actual JSON processing handled by JsonRpcMessageReceiver */
axis2_json_writer_t* writer = (axis2_json_writer_t*)AXIS2_MALLOC(env->allocator,
sizeof(struct axis2_json_writer));
- if (writer)
- writer->json_obj = NULL;
-
+ if (writer) {
+ writer->json_obj = json_object_new_object();
+ }
return writer;
}
-
AXIS2_EXTERN void AXIS2_CALL
axis2_json_writer_free(
axis2_json_writer_t* writer,
const axutil_env_t* env)
{
- if (writer)
- {
- if (writer->json_obj)
+ /* Revolutionary: Minimal cleanup */
+ if (writer) {
+ if (writer->json_obj) {
json_object_put(writer->json_obj);
+ }
AXIS2_FREE(env->allocator, writer);
}
}
-
AXIS2_EXTERN void AXIS2_CALL
axis2_json_writer_write(
axis2_json_writer_t* writer,
const axiom_node_t* node,
const axutil_env_t* env)
{
- /* free existing object */
- if (writer->json_obj)
- json_object_put(writer->json_obj);
-
- writer->json_obj = json_object_new_object();
- axis2_json_write_node(writer->json_obj, (axiom_node_t*)node, env);
+ /* Revolutionary: Stub - actual JSON processing done by JsonRpcMessageReceiver */
+ /* Compatibility shim for existing tests */
+ return;
}
-
AXIS2_EXTERN const axis2_char_t* AXIS2_CALL
axis2_json_writer_get_json_string(
axis2_json_writer_t* writer,
const axutil_env_t* env,
int* json_string_length)
{
- (void)env;
- const axis2_char_t* result =
- (const axis2_char_t*)json_object_to_json_string_ext(writer->json_obj,
- JSON_C_TO_STRING_PLAIN);
- if (json_string_length)
- *json_string_length = strlen(result);
-
- return result;
-}
+ /* Revolutionary: Return empty JSON object */
+ if (writer && writer->json_obj) {
+ const char* json_str = json_object_to_json_string(writer->json_obj);
+ if (json_string_length) {
+ *json_string_length = (int)strlen(json_str);
+ }
+ return json_str;
+ }
+ if (json_string_length) {
+ *json_string_length = 2;
+ }
+ return "{}";
+}
\ No newline at end of file
diff --git a/src/core/transport/http/util/axis2_json_reader.c b/src/core/transport/http/util/axis2_json_reader.c
index 9c46c13d5..e9194bb0e 100644
--- a/src/core/transport/http/util/axis2_json_reader.c
+++ b/src/core/transport/http/util/axis2_json_reader.c
@@ -165,6 +165,7 @@ axis2_json_read_child_node(
attr = axiom_attribute_create(env, "nil", "true", ns);
if (!attr)
{
+ axiom_attribute_free(attr, env);
return AXIS2_FAILURE;
}
@@ -174,8 +175,6 @@ axis2_json_read_child_node(
axiom_attribute_free(attr, env);
return AXIS2_FAILURE;
}
- /* AXIS2C-1590: Release our reference after adding - element now owns a reference */
- axiom_attribute_free(attr, env);
/* Free the namespace after successful use */
axiom_namespace_free(ns, env);
(axis-axis2-c-core) 02/02: Add conditional compilation for JSON writer HTTP/1.1 vs HTTP/2 modes
Posted by ro...@apache.org.
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 ef9e13703fabec0b971e08d722f1b647dc682d27
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Wed Jan 14 15:35:13 2026 -1000
Add conditional compilation for JSON writer HTTP/1.1 vs HTTP/2 modes
Use #ifdef WITH_NGHTTP2 to select between:
- HTTP/2 mode: AXIOM-free stub (JSON handled by JsonRpcMessageReceiver)
- HTTP/1.1 mode: Full AXIOM-to-JSON conversion for SOAP support
This fixes the HTTP/1.1 JSON tests that were broken when the json_writer
was converted to a stub-only implementation.
Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
src/core/transport/http/sender/axis2_json_writer.c | 211 ++++++++++++++++++++-
1 file changed, 202 insertions(+), 9 deletions(-)
diff --git a/src/core/transport/http/sender/axis2_json_writer.c b/src/core/transport/http/sender/axis2_json_writer.c
index 84d2e5535..11e114ff4 100644
--- a/src/core/transport/http/sender/axis2_json_writer.c
+++ b/src/core/transport/http/sender/axis2_json_writer.c
@@ -12,7 +12,21 @@
* limitations under the License.
*/
-/* Revolutionary HTTP/2 JSON Architecture - AXIOM-free stub implementation */
+/*
+ * JSON Writer - Conditional compilation for HTTP/1.1 vs HTTP/2 modes
+ *
+ * HTTP/1.1 mode (no WITH_NGHTTP2): Full AXIOM-to-JSON conversion
+ * HTTP/2 mode (WITH_NGHTTP2): Stub implementation - JSON handled by JsonRpcMessageReceiver
+ */
+
+#ifdef WITH_NGHTTP2
+/* ============================================================================
+ * HTTP/2 JSON Mode - Stub Implementation (AXIOM-free)
+ * ============================================================================
+ * In HTTP/2 JSON mode, JSON processing is handled directly by the
+ * JsonRpcMessageReceiver without AXIOM intermediation.
+ */
+
#include <json-c/json.h>
#include <string.h>
#include "axis2_json_writer.h"
@@ -22,11 +36,9 @@ struct axis2_json_writer
json_object* json_obj;
};
-/* Revolutionary AXIOM-free stub implementation */
AXIS2_EXTERN axis2_json_writer_t* AXIS2_CALL
axis2_json_writer_create(const axutil_env_t* env)
{
- /* Revolutionary: Stub implementation - actual JSON processing handled by JsonRpcMessageReceiver */
axis2_json_writer_t* writer = (axis2_json_writer_t*)AXIS2_MALLOC(env->allocator,
sizeof(struct axis2_json_writer));
if (writer) {
@@ -40,7 +52,6 @@ axis2_json_writer_free(
axis2_json_writer_t* writer,
const axutil_env_t* env)
{
- /* Revolutionary: Minimal cleanup */
if (writer) {
if (writer->json_obj) {
json_object_put(writer->json_obj);
@@ -55,9 +66,10 @@ axis2_json_writer_write(
const axiom_node_t* node,
const axutil_env_t* env)
{
- /* Revolutionary: Stub - actual JSON processing done by JsonRpcMessageReceiver */
- /* Compatibility shim for existing tests */
- return;
+ /* Stub - HTTP/2 JSON processing done by JsonRpcMessageReceiver */
+ (void)writer;
+ (void)node;
+ (void)env;
}
AXIS2_EXTERN const axis2_char_t* AXIS2_CALL
@@ -66,7 +78,7 @@ axis2_json_writer_get_json_string(
const axutil_env_t* env,
int* json_string_length)
{
- /* Revolutionary: Return empty JSON object */
+ (void)env;
if (writer && writer->json_obj) {
const char* json_str = json_object_to_json_string(writer->json_obj);
if (json_string_length) {
@@ -78,4 +90,185 @@ axis2_json_writer_get_json_string(
*json_string_length = 2;
}
return "{}";
-}
\ No newline at end of file
+}
+
+#else /* !WITH_NGHTTP2 */
+/* ============================================================================
+ * HTTP/1.1 SOAP Mode - Full AXIOM-to-JSON Implementation
+ * ============================================================================
+ * Traditional mode with full AXIOM node to JSON conversion support.
+ */
+
+#include <axiom_node.h>
+#include <axiom_element.h>
+#include <axiom_attribute.h>
+#include <json-c/json.h>
+#include "axis2_json_writer.h"
+
+#define AXIS2_JSON_XSI_URI "http://www.w3.org/2001/XMLSchema-instance"
+
+struct axis2_json_writer
+{
+ json_object* json_obj;
+};
+
+axis2_bool_t axis2_json_element_is_nil(axiom_element_t* om_element, const axutil_env_t* env)
+{
+ axiom_attribute_t* attr = NULL;
+ axutil_hash_index_t* index;
+ axutil_hash_t* attr_hash = axiom_element_get_all_attributes(om_element, env);
+ axis2_bool_t result = AXIS2_FALSE;
+
+ if (!attr_hash)
+ return AXIS2_FALSE;
+
+ for (index = axutil_hash_first(attr_hash, env);
+ index; index = axutil_hash_next(env, index))
+ {
+ axutil_hash_this(index, NULL, NULL, (void**)&attr);
+ if (attr && !strcmp(axiom_attribute_get_localname(attr, env), "nil"))
+ {
+ /* found some "nil" attribute, check it namespace */
+ axutil_qname_t* qname =
+ axiom_attribute_get_qname(attr, env);
+ if (qname && !strcmp(axutil_qname_get_uri(qname, env), AXIS2_JSON_XSI_URI))
+ {
+ axis2_char_t* attr_value =
+ axiom_attribute_get_value(attr, env);
+ result = (!strcmp(attr_value, "true") || !strcmp(attr_value, "1")) ?
+ AXIS2_TRUE : AXIS2_FALSE;
+ /* Found what we're looking for - use axutil_hash_index_free to cleanup */
+ axutil_hash_index_free(index, env);
+ return result;
+ }
+ }
+ }
+
+ return result;
+}
+
+void axis2_json_write_node(json_object* parent, axiom_node_t* om_node, const axutil_env_t* env)
+{
+ axiom_element_t* elem;
+ axiom_node_t* child_node;
+ const axis2_char_t* local_name;
+ json_object* obj;
+ json_object* array = NULL;
+
+ if (!om_node || axiom_node_get_node_type(om_node, env) != AXIOM_ELEMENT)
+ return;
+
+ elem = (axiom_element_t*)axiom_node_get_data_element(om_node, env);
+ local_name = axiom_element_get_localname(elem, env);
+
+ child_node = axiom_node_get_first_element(om_node, env);
+
+ /* find existing object */
+ if (json_object_object_get_ex(parent, local_name, &obj))
+ {
+ /* check that object is array? */
+ if (!json_object_is_type(obj, json_type_array))
+ {
+ /* convert to array */
+ obj = json_object_get(obj);
+ array = json_object_new_array();
+ json_object_array_add(array, obj);
+ json_object_object_del(parent, local_name);
+ json_object_object_add(parent, local_name, array);
+ }
+ else
+ array = obj;
+ }
+
+ if (!child_node)
+ {
+ /* this is a leaf node */
+ json_object* json_value = NULL;
+
+ /* check for nillable */
+ if (!axis2_json_element_is_nil(elem, env))
+ {
+ const axis2_char_t* value =
+ axiom_element_get_text(elem, env, om_node);
+ json_value = json_object_new_string(value ? value : "");
+ }
+
+ if (array)
+ json_object_array_add(array, json_value);
+ else
+ json_object_object_add(parent, local_name, json_value);
+ return;
+ }
+
+ /* iterate through children elements */
+ obj = json_object_new_object();
+ if (array)
+ json_object_array_add(array, obj);
+ else
+ json_object_object_add(parent, local_name, obj);
+
+ for (; child_node; child_node = axiom_node_get_next_sibling(child_node, env))
+ if (axiom_node_get_node_type(child_node, env) == AXIOM_ELEMENT)
+ axis2_json_write_node(obj, child_node, env);
+}
+
+
+AXIS2_EXTERN axis2_json_writer_t* AXIS2_CALL
+axis2_json_writer_create(
+ const axutil_env_t* env)
+{
+ axis2_json_writer_t* writer = (axis2_json_writer_t*)AXIS2_MALLOC(env->allocator,
+ sizeof(struct axis2_json_writer));
+ if (writer)
+ writer->json_obj = NULL;
+
+ return writer;
+}
+
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_json_writer_free(
+ axis2_json_writer_t* writer,
+ const axutil_env_t* env)
+{
+ if (writer) {
+ if (writer->json_obj) {
+ json_object_put(writer->json_obj);
+ }
+ AXIS2_FREE(env->allocator, writer);
+ }
+}
+
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_json_writer_write(
+ axis2_json_writer_t* writer,
+ const axiom_node_t* node,
+ const axutil_env_t* env)
+{
+ /* free existing object */
+ if (writer->json_obj)
+ json_object_put(writer->json_obj);
+
+ writer->json_obj = json_object_new_object();
+ axis2_json_write_node(writer->json_obj, (axiom_node_t*)node, env);
+}
+
+
+AXIS2_EXTERN const axis2_char_t* AXIS2_CALL
+axis2_json_writer_get_json_string(
+ axis2_json_writer_t* writer,
+ const axutil_env_t* env,
+ int* json_string_length)
+{
+ (void)env;
+ const axis2_char_t* result =
+ (const axis2_char_t*)json_object_to_json_string_ext(writer->json_obj,
+ JSON_C_TO_STRING_PLAIN);
+ if (json_string_length)
+ *json_string_length = strlen(result);
+
+ return result;
+}
+
+#endif /* WITH_NGHTTP2 */