summaryrefslogtreecommitdiffstats
path: root/axiom
diff options
context:
space:
mode:
authorGravatar shankar2010-04-07 07:20:41 +0000
committerGravatar shankar2010-04-07 07:20:41 +0000
commitda05a0173e5d9b33231745471c5d6ae4def5c9c3 (patch)
tree971d3e24adf4450a3137a1987cda4675355105d0 /axiom
parent2a417ee2eed32bec5891afe14ec8be558ae46ad7 (diff)
downloadaxis2c-da05a0173e5d9b33231745471c5d6ae4def5c9c3.tar.gz
axis2c-da05a0173e5d9b33231745471c5d6ae4def5c9c3.tar.bz2
Fixing issue AXIS2C-1233
git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@931454 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'axiom')
-rw-r--r--axiom/include/axiom_soap_builder.h1
-rw-r--r--axiom/src/om/axiom_stax_builder_internal.h14
-rw-r--r--axiom/src/om/om_stax_builder.c35
-rw-r--r--axiom/src/soap/axiom_soap_builder_internal.h36
-rw-r--r--axiom/src/soap/soap_builder.c53
5 files changed, 99 insertions, 40 deletions
diff --git a/axiom/include/axiom_soap_builder.h b/axiom/include/axiom_soap_builder.h
index 9fffb78..4d1ded0 100644
--- a/axiom/include/axiom_soap_builder.h
+++ b/axiom/include/axiom_soap_builder.h
@@ -245,7 +245,6 @@ extern "C"
const axutil_env_t * env);
-
/** @} */
#ifdef __cplusplus
}
diff --git a/axiom/src/om/axiom_stax_builder_internal.h b/axiom/src/om/axiom_stax_builder_internal.h
index 12fcb53..4294778 100644
--- a/axiom/src/om/axiom_stax_builder_internal.h
+++ b/axiom/src/om/axiom_stax_builder_internal.h
@@ -24,9 +24,8 @@
* @{
*/
-/** @} */
-
#include <axiom_stax_builder.h>
+#include <axiom_soap_builder.h>
#ifdef __cplusplus
extern "C"
@@ -97,6 +96,17 @@ extern "C"
struct axiom_stax_builder *builder,
const axutil_env_t * env);
+ void AXIS2_CALL
+ axiom_stax_builder_set_soap_builder(
+ axiom_stax_builder_t *om_builder,
+ const axutil_env_t *env,
+ axiom_soap_builder_t *soap_builder);
+
+ axiom_node_t *AXIS2_CALL
+ axiom_stax_builder_get_root_node(
+ axiom_stax_builder_t *om_builder,
+ const axutil_env_t * env);
+
#if 0
diff --git a/axiom/src/om/om_stax_builder.c b/axiom/src/om/om_stax_builder.c
index c43fd61..aca1878 100644
--- a/axiom/src/om/om_stax_builder.c
+++ b/axiom/src/om/om_stax_builder.c
@@ -25,6 +25,7 @@
#include <axiom_doctype.h>
#include "axiom_node_internal.h"
#include "axiom_stax_builder_internal.h"
+#include <axiom_soap_builder_internal.h>
#include "axiom_document_internal.h"
struct axiom_stax_builder
@@ -50,6 +51,9 @@ struct axiom_stax_builder
/** Indicate the current element level. */
int element_level;
+ /** reference to the soap builder, to build soap releated elements */
+ axiom_soap_builder_t *soap_builder;
+
axutil_hash_t *declared_namespaces;
};
@@ -104,6 +108,7 @@ axiom_stax_builder_create(
om_builder->current_event = -1;
om_builder->root_node = NULL;
om_builder->element_level = 0;
+ om_builder->soap_builder = NULL;
return om_builder;
}
@@ -742,6 +747,20 @@ axiom_stax_builder_next_with_token(
default:
break;
}
+
+ /* if stax builder is also a soap builder, build soap related elements */
+ if(om_builder->soap_builder &&
+ (token == AXIOM_XML_READER_START_ELEMENT || token == AXIOM_XML_READER_EMPTY_ELEMENT))
+ {
+ AXIS2_ASSERT(om_builder->lastnode != NULL);
+ if(axiom_soap_builder_construct_node(om_builder->soap_builder, env, om_builder->lastnode)
+ != AXIS2_SUCCESS)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error occurred when building soap node");
+ om_builder->done = AXIS2_TRUE;
+ return -1;
+ }
+ }
return token;
}
@@ -813,6 +832,22 @@ axiom_stax_builder_set_element_level(
om_builder->element_level = element_level;
}
+void AXIS2_CALL
+axiom_stax_builder_set_soap_builder(
+ axiom_stax_builder_t *om_builder,
+ const axutil_env_t *env,
+ axiom_soap_builder_t *soap_builder)
+{
+ om_builder->soap_builder = soap_builder;
+}
+
+axiom_node_t *AXIS2_CALL
+axiom_stax_builder_get_root_node(
+ axiom_stax_builder_t *om_builder,
+ const axutil_env_t * env)
+{
+ return om_builder->root_node;
+}
#if 0
static axiom_node_t *
axiom_stax_builder_create_om_doctype(
diff --git a/axiom/src/soap/axiom_soap_builder_internal.h b/axiom/src/soap/axiom_soap_builder_internal.h
new file mode 100644
index 0000000..d23b8e8
--- /dev/null
+++ b/axiom/src/soap/axiom_soap_builder_internal.h
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AXIOM_SOAP_BUILDER_INTERNAL_H_
+#define AXIOM_SOAP_BUILDER_INTERNAL_H_
+
+/** @defgroup axiom_soap AXIOM (Axis Object Model)
+ * @ingroup axis2
+ * @{
+ */
+
+#include <axiom_soap_builder.h>
+
+ axis2_status_t AXIS2_CALL
+ axiom_soap_builder_construct_node(
+ axiom_soap_builder_t * soap_builder,
+ const axutil_env_t * env,
+ axiom_node_t * om_element_node);
+
+/** @} */
+
+#endif /* AXIOM_SOAP_BUILDER_INTERNAL_H_ */
diff --git a/axiom/src/soap/soap_builder.c b/axiom/src/soap/soap_builder.c
index 2496506..a2e8b23 100644
--- a/axiom/src/soap/soap_builder.c
+++ b/axiom/src/soap/soap_builder.c
@@ -24,16 +24,11 @@
#include "_axiom_soap_body.h"
#include "_axiom_soap_header_block.h"
#include <axiom_stax_builder_internal.h>
+#include "axiom_soap_builder_internal.h"
#include "_axiom_soap_fault.h"
#include <axutil_http_chunked_stream.h>
static axis2_status_t
-axiom_soap_builder_construct_node(
- axiom_soap_builder_t * soap_builder,
- const axutil_env_t * env,
- axiom_node_t * om_element_node);
-
-static axis2_status_t
axiom_soap_builder_identify_soap_version(
axiom_soap_builder_t * soap_builder,
const axutil_env_t * env,
@@ -151,6 +146,7 @@ axiom_soap_builder_create(
soap_builder->soap_version = AXIOM_SOAP12;
soap_builder->last_node_status = -1;
soap_builder->om_builder = stax_builder;
+ axiom_stax_builder_set_soap_builder(stax_builder, env, soap_builder);
soap_builder->done = AXIS2_FALSE;
status = axiom_soap_builder_identify_soap_version(soap_builder, env, soap_version);
@@ -324,37 +320,8 @@ axiom_soap_builder_next(
return AXIS2_FAILURE;
}
- /* Get the status of previous node before building next node. We need the previous state of the
- * node to identify very first element, which is SOAP Envelope. If last_node_status is
- * AXIS2_BUILDER_LAST_NODE_NULL, then it means next node is SOAP Envelope
- */
- if(axiom_stax_builder_get_lastnode(soap_builder->om_builder, env))
- {
- soap_builder->last_node_status = AXIS2_BUILDER_LAST_NODE_NOT_NULL;
- }
- else
- {
- soap_builder->last_node_status = AXIS2_BUILDER_LAST_NODE_NULL;
- }
-
current_event = axiom_stax_builder_next_with_token(soap_builder->om_builder, env);
- if(current_event == AXIOM_XML_READER_START_ELEMENT
- || current_event == AXIOM_XML_READER_EMPTY_ELEMENT)
- {
- axiom_node_t *current_node = axiom_stax_builder_get_lastnode(soap_builder->om_builder, env);
- if(current_node)
- {
- status = axiom_soap_builder_construct_node(soap_builder, env, current_node);
- }
- else
- {
- /* there is an error. So, don't continue building it */
- soap_builder->done = AXIS2_TRUE;
- status = AXIS2_FAILURE;
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error occurred when building node");
- }
- }
- else if(current_event == -1)
+ if(current_event == -1)
{
/* there is an error. So, don't continue building it */
soap_builder->done = AXIS2_TRUE;
@@ -381,7 +348,7 @@ axiom_soap_builder_get_document_element(
return document_node;
}
-static axis2_status_t
+axis2_status_t AXIS2_CALL
axiom_soap_builder_construct_node(
axiom_soap_builder_t * soap_builder,
const axutil_env_t * env,
@@ -393,6 +360,18 @@ axiom_soap_builder_construct_node(
int status = AXIS2_SUCCESS;
axiom_node_t *parent = NULL;
+ /* Check whether current node is the very first element, which is SOAP Envelope.
+ * If last_node_status is AXIS2_BUILDER_LAST_NODE_NULL, then it means next node is SOAP Envelope
+ */
+ if(om_element_node == axiom_stax_builder_get_root_node(soap_builder->om_builder, env))
+ {
+ soap_builder->last_node_status = AXIS2_BUILDER_LAST_NODE_NULL;
+ }
+ else
+ {
+ soap_builder->last_node_status = AXIS2_BUILDER_LAST_NODE_NOT_NULL;
+ }
+
/* get OM element struct from node */
om_element = (axiom_element_t *)axiom_node_get_data_element(om_element_node, env);
if(!om_element)