summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar damitha2010-06-29 08:57:05 +0000
committerGravatar damitha2010-06-29 08:57:05 +0000
commitc35e1616e67de2d5852dae647c2db6d811f451bd (patch)
tree00333633e1410647421457733ffa827efb1db0f2
parentb16ecb885592c2a78dc9d69e1eb2ea7432ef4173 (diff)
downloadaxis2c-c35e1616e67de2d5852dae647c2db6d811f451bd.tar.gz
axis2c-c35e1616e67de2d5852dae647c2db6d811f451bd.tar.bz2
Partial fix of AXIS2C-1440
git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@958884 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--axiom/src/om/axiom_document_internal.h240
-rw-r--r--axiom/src/om/axiom_element_internal.h294
-rw-r--r--axiom/src/soap/axiom_soap_builder_internal.h72
-rw-r--r--samples/client/amqp/echo/echo_blocking.c248
-rw-r--r--samples/client/amqp/echo/echo_blocking_addr.c264
-rw-r--r--samples/client/amqp/echo/echo_blocking_dual.c284
-rw-r--r--samples/client/amqp/echo/echo_blocking_soap11.c270
-rw-r--r--samples/client/amqp/echo/echo_non_blocking.c434
-rw-r--r--samples/client/amqp/echo/echo_non_blocking_dual.c470
-rw-r--r--samples/client/amqp/echo/echo_util.c94
-rw-r--r--samples/client/amqp/echo/echo_util.h108
-rw-r--r--samples/client/amqp/mtom/mtom_client.c518
-rw-r--r--samples/client/amqp/notify/notify_client.c304
-rw-r--r--src/core/deployment/conf_init.c44
-rw-r--r--src/core/transport/amqp/receiver/axis2_amqp_receiver.c550
-rw-r--r--src/core/transport/amqp/receiver/axis2_amqp_receiver.h164
-rw-r--r--src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver.h78
-rw-r--r--src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_interface.h116
-rw-r--r--src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_listener.h86
-rw-r--r--src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.c668
-rw-r--r--src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.h110
-rw-r--r--src/core/transport/amqp/sender/axis2_amqp_sender.c688
-rw-r--r--src/core/transport/amqp/sender/axis2_amqp_sender.h126
-rw-r--r--src/core/transport/amqp/sender/qpid_sender/axis2_qpid_sender.h98
-rw-r--r--src/core/transport/amqp/sender/qpid_sender/axis2_qpid_sender_interface.h100
-rw-r--r--src/core/transport/amqp/server/axis2_amqp_server/axis2_amqp_server.c464
-rw-r--r--src/core/transport/amqp/server/axis2_amqp_server/axis2_amqp_server.h82
-rw-r--r--src/core/transport/amqp/util/axis2_amqp_defines.h130
-rw-r--r--src/core/transport/amqp/util/axis2_amqp_util.c1622
-rw-r--r--src/core/transport/amqp/util/axis2_amqp_util.h286
-rw-r--r--src/core/transport/http/receiver/http_receiver.c12
-rw-r--r--src/core/transport/http/server/IIS/axis2_iis_worker.h124
-rw-r--r--src/core/transport/http/server/IIS/axis2_isapi_plugin.c560
-rw-r--r--src/core/transport/http/server/IIS/iis_iaspi_plugin_51/axis2_isapi_51.c306
-rw-r--r--src/core/transport/http/server/apache2/apache2_worker.c3374
-rw-r--r--src/modules/mod_addr/addr_out_handler.c1724
-rw-r--r--test/find_policy.c132
-rw-r--r--util/include/axutil_network_handler.h388
-rw-r--r--util/include/axutil_utils_defines.h12
-rw-r--r--util/include/platforms/os400/axutil_os400.h554
-rw-r--r--util/include/platforms/windows/axutil_uuid_gen_windows.h90
-rw-r--r--util/src/network_handler.c1292
-rw-r--r--util/src/platforms/os400/platformSpecificOS400.c770
-rw-r--r--util/src/platforms/windows/axutil_windows.c186
44 files changed, 9268 insertions, 9268 deletions
diff --git a/axiom/src/om/axiom_document_internal.h b/axiom/src/om/axiom_document_internal.h
index daf28c8..44c65ba 100644
--- a/axiom/src/om/axiom_document_internal.h
+++ b/axiom/src/om/axiom_document_internal.h
@@ -1,120 +1,120 @@
-/*
- * 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_DOCUMENT_INTERNAL_H_
-#define AXIOM_DOCUMENT_INTERNAL_H_
-
-#include <axiom_document.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /**
- * creates an axiom_document_t struct
- * @param env Environment. MUST NOT be NULL.
- * @param root pointer to document's root node. Optional, can be NULL
- * @param builder pointer to axiom_stax_builder
- * @return pointer to the newly created document.
- */
- axiom_document_t *AXIS2_CALL
- axiom_document_create(
- const axutil_env_t * env,
- axiom_node_t * root,
- struct axiom_stax_builder *builder);
-
- /**
- * Free document struct
- * @param document pointer to axiom_document_t struct to be freed
- * @param env Environment. MUST NOT be NULL
- * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
- */
- void AXIS2_CALL
- axiom_document_free(
- struct axiom_document *document,
- const axutil_env_t * env);
-
- /**
- * Free document struct only, Does not free the associated axiom structure.
- * @param document pointer to axiom_document_t struct to be freed
- * @param env Environment. MUST NOT be NULL
- * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
- */
- void AXIS2_CALL
- axiom_document_free_self(
- struct axiom_document *document,
- const axutil_env_t * env);
-
- /**
- * set the root element of the document. IF a root node is already exist,it is freed
- * before setting to root element
- * @param document document struct to return the root of
- * @param env Environment. MUST NOT be NULL.
- * @return returns status code AXIS2_SUCCESS on success ,AXIS2_FAILURE on error.
- */
- axis2_status_t AXIS2_CALL
- axiom_document_set_root_element(
- struct axiom_document *document,
- const axutil_env_t * env,
- axiom_node_t * om_node);
-
-#if 0
- /* these methods are commented, because it is not used anymore (1.6.0)*/
-
- /**
- * get builder
- * @param document pointer to axiom_document_t struct to be built.
- * @param env environment MUST NOT be NULL.
- * @return builder, returns NULL if a builder is not associated with
- * document
- */
- AXIS2_EXTERN struct axiom_stax_builder *AXIS2_CALL
- axiom_document_get_builder(
- struct axiom_document *document,
- const axutil_env_t * env);
-
- /**
- * sets builder for document.
- * @param document pointer to axiom_document_t struct to be built.
- * @param env environment MUST NOT be NULL.
- * @param builder pointer to builder to associate with document
- */
- AXIS2_EXTERN void AXIS2_CALL
- axiom_document_set_builder(
- axiom_document_t * document,
- const axutil_env_t * env,
- struct axiom_stax_builder * builder);
-
- /**
- * @param om_document
- * @return status code AXIS2_SUCCESS on success , otherwise AXIS2_FAILURE
- */
- AXIS2_EXTERN axis2_status_t AXIS2_CALL
- axiom_document_serialize(
- struct axiom_document *document,
- const axutil_env_t * env,
- axiom_output_t * om_output);
-
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* AXIOM_DOCUMENT_INTERNAL_H_ */
+/*
+ * 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_DOCUMENT_INTERNAL_H_
+#define AXIOM_DOCUMENT_INTERNAL_H_
+
+#include <axiom_document.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /**
+ * creates an axiom_document_t struct
+ * @param env Environment. MUST NOT be NULL.
+ * @param root pointer to document's root node. Optional, can be NULL
+ * @param builder pointer to axiom_stax_builder
+ * @return pointer to the newly created document.
+ */
+ axiom_document_t *AXIS2_CALL
+ axiom_document_create(
+ const axutil_env_t * env,
+ axiom_node_t * root,
+ struct axiom_stax_builder *builder);
+
+ /**
+ * Free document struct
+ * @param document pointer to axiom_document_t struct to be freed
+ * @param env Environment. MUST NOT be NULL
+ * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
+ */
+ void AXIS2_CALL
+ axiom_document_free(
+ struct axiom_document *document,
+ const axutil_env_t * env);
+
+ /**
+ * Free document struct only, Does not free the associated axiom structure.
+ * @param document pointer to axiom_document_t struct to be freed
+ * @param env Environment. MUST NOT be NULL
+ * @return status of the op. AXIS2_SUCCESS on success else AXIS2_FAILURE.
+ */
+ void AXIS2_CALL
+ axiom_document_free_self(
+ struct axiom_document *document,
+ const axutil_env_t * env);
+
+ /**
+ * set the root element of the document. IF a root node is already exist,it is freed
+ * before setting to root element
+ * @param document document struct to return the root of
+ * @param env Environment. MUST NOT be NULL.
+ * @return returns status code AXIS2_SUCCESS on success ,AXIS2_FAILURE on error.
+ */
+ axis2_status_t AXIS2_CALL
+ axiom_document_set_root_element(
+ struct axiom_document *document,
+ const axutil_env_t * env,
+ axiom_node_t * om_node);
+
+#if 0
+ /* these methods are commented, because it is not used anymore (1.6.0)*/
+
+ /**
+ * get builder
+ * @param document pointer to axiom_document_t struct to be built.
+ * @param env environment MUST NOT be NULL.
+ * @return builder, returns NULL if a builder is not associated with
+ * document
+ */
+ AXIS2_EXTERN struct axiom_stax_builder *AXIS2_CALL
+ axiom_document_get_builder(
+ struct axiom_document *document,
+ const axutil_env_t * env);
+
+ /**
+ * sets builder for document.
+ * @param document pointer to axiom_document_t struct to be built.
+ * @param env environment MUST NOT be NULL.
+ * @param builder pointer to builder to associate with document
+ */
+ AXIS2_EXTERN void AXIS2_CALL
+ axiom_document_set_builder(
+ axiom_document_t * document,
+ const axutil_env_t * env,
+ struct axiom_stax_builder * builder);
+
+ /**
+ * @param om_document
+ * @return status code AXIS2_SUCCESS on success , otherwise AXIS2_FAILURE
+ */
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axiom_document_serialize(
+ struct axiom_document *document,
+ const axutil_env_t * env,
+ axiom_output_t * om_output);
+
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AXIOM_DOCUMENT_INTERNAL_H_ */
diff --git a/axiom/src/om/axiom_element_internal.h b/axiom/src/om/axiom_element_internal.h
index adbce79..df515f9 100644
--- a/axiom/src/om/axiom_element_internal.h
+++ b/axiom/src/om/axiom_element_internal.h
@@ -1,147 +1,147 @@
-/*
- * 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_ELEMENT_INTERNAL_H_
-#define AXIOM_ELEMENT_INTERNAL_H_
-
-/** @defgroup axiom AXIOM (Axis Object Model)
- * @ingroup axis2
- * @{
- */
-
-/** @} */
-
-#include <axiom_element.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /**
- * @defgroup axiom_element element
- * @ingroup axiom
- * @{
- */
-
- /**
- * Collect all the namespaces with distinct prefixes in the parents of the given element.
- * Effectively this is the set of namespaces declared above this element that are inscope at
- * this element and might be used by it or its children.
- * @param om_element pointer to om_element
- * @param env environment MUST not be NULL
- * @param om_node pointer to this element node
- * @returns pointer to hash of relevant namespaces
- */
- axutil_hash_t * AXIS2_CALL
- axiom_element_gather_parent_namespaces(
- axiom_element_t * om_element,
- const axutil_env_t * env,
- axiom_node_t * om_node);
-
- /**
- * Examines the subtree beginning at the provided element for each element or attribute,
- * if it refers to a namespace declared in a parent of the subtree root element, if not already
- * declared, redeclares that namespace at the level of the subtree root and removes
- * it from the set of parent inscope_namespaces. inscope_namespaces contains all the parent
- * namespaces which should be redeclared at some point.
- * @param om_element pointer to om_element
- * @param env environment MUST not be NULL
- * @param om_node pointer to this element node
- * @param inscope_namespaces pointer to hash of parent namespaces
- */
- void AXIS2_CALL
- axiom_element_redeclare_parent_namespaces(
- axiom_element_t * om_element,
- const axutil_env_t * env,
- axiom_node_t * om_node,
- axutil_hash_t *inscope_namespaces);
-
- /**
- * If the provided namespace used by the provided element is one of the namespaces from the
- * parent of the root element, redeclares that namespace at the root element and removes it
- * from the hash of parent namespaces
- * @param om_element pointer to om_element
- * @param env environment MUST not be NULL
- * @param om_node pointer to this element node
- * @param ns pointer to namespace to redeclare
- * @param inscope_namespaces pointer to hash of parent namespaces
- */
- void AXIS2_CALL
- axiom_element_use_parent_namespace(
- axiom_element_t * om_element,
- const axutil_env_t * env,
- axiom_node_t * om_node,
- axiom_namespace_t *ns,
- axutil_hash_t *inscope_namespaces);
-
- /**
- * retrieves the default namespace of this element
- * @param om_element pointer to om element
- * @param env axutil_environment MUST Not be NULL
- * @param element_node corresponding om element node of this om element
- * @returns pointer to default namespace if available , NULL otherwise
- */
- axiom_namespace_t *AXIS2_CALL
- axiom_element_get_default_namespace(
- axiom_element_t * om_element,
- const axutil_env_t * env,
- axiom_node_t * element_node);
-
- /**
- * Serializes the start part of the given element
- * @param element element to be serialized.
- * @param env Environment. MUST NOT be NULL.
- * @param om_output AXIOM output handler to be used in serializing
- * @return status of the operation. AXIS2_SUCCESS on success else AXIS2_FAILURE
- */
- axis2_status_t AXIS2_CALL
- axiom_element_serialize_start_part(
- axiom_element_t * om_element,
- const axutil_env_t * env,
- axiom_output_t * om_output,
- axiom_node_t * ele_node);
-
- /**
- * Serializes the end part of the given element. serialize_start_part must
- * have been called before calling this method.
- * @param om_element pointer to om_element
- * @param env environment MUST not be NULL
- * @param om_node pointer to this element node
- * @param om_output AXIOM output handler to be used in serializing
- * @return status of the operation. AXIS2_SUCCESS on success else AXIS2_FAILURE
- */
- axis2_status_t AXIS2_CALL
- axiom_element_serialize_end_part(
- axiom_element_t * om_element,
- const axutil_env_t * env,
- axiom_output_t * om_output);
-
- /**
- * Set whether the element is empty or not
- * @param om_element pointer to om_element
- * @param env environment MUST not be NULL
- * @param is_empty AXIS2_TRUE if empty AXIS2_FALSE if not empty
- * @return VOID
- */
- void AXIS2_CALL
- axiom_element_set_is_empty(
- axiom_element_t * om_element,
- const axutil_env_t * env,
- axis2_bool_t is_empty);
-
-#endif /* AXIOM_ELEMENT_INTERNAL_H_ */
+/*
+ * 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_ELEMENT_INTERNAL_H_
+#define AXIOM_ELEMENT_INTERNAL_H_
+
+/** @defgroup axiom AXIOM (Axis Object Model)
+ * @ingroup axis2
+ * @{
+ */
+
+/** @} */
+
+#include <axiom_element.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /**
+ * @defgroup axiom_element element
+ * @ingroup axiom
+ * @{
+ */
+
+ /**
+ * Collect all the namespaces with distinct prefixes in the parents of the given element.
+ * Effectively this is the set of namespaces declared above this element that are inscope at
+ * this element and might be used by it or its children.
+ * @param om_element pointer to om_element
+ * @param env environment MUST not be NULL
+ * @param om_node pointer to this element node
+ * @returns pointer to hash of relevant namespaces
+ */
+ axutil_hash_t * AXIS2_CALL
+ axiom_element_gather_parent_namespaces(
+ axiom_element_t * om_element,
+ const axutil_env_t * env,
+ axiom_node_t * om_node);
+
+ /**
+ * Examines the subtree beginning at the provided element for each element or attribute,
+ * if it refers to a namespace declared in a parent of the subtree root element, if not already
+ * declared, redeclares that namespace at the level of the subtree root and removes
+ * it from the set of parent inscope_namespaces. inscope_namespaces contains all the parent
+ * namespaces which should be redeclared at some point.
+ * @param om_element pointer to om_element
+ * @param env environment MUST not be NULL
+ * @param om_node pointer to this element node
+ * @param inscope_namespaces pointer to hash of parent namespaces
+ */
+ void AXIS2_CALL
+ axiom_element_redeclare_parent_namespaces(
+ axiom_element_t * om_element,
+ const axutil_env_t * env,
+ axiom_node_t * om_node,
+ axutil_hash_t *inscope_namespaces);
+
+ /**
+ * If the provided namespace used by the provided element is one of the namespaces from the
+ * parent of the root element, redeclares that namespace at the root element and removes it
+ * from the hash of parent namespaces
+ * @param om_element pointer to om_element
+ * @param env environment MUST not be NULL
+ * @param om_node pointer to this element node
+ * @param ns pointer to namespace to redeclare
+ * @param inscope_namespaces pointer to hash of parent namespaces
+ */
+ void AXIS2_CALL
+ axiom_element_use_parent_namespace(
+ axiom_element_t * om_element,
+ const axutil_env_t * env,
+ axiom_node_t * om_node,
+ axiom_namespace_t *ns,
+ axutil_hash_t *inscope_namespaces);
+
+ /**
+ * retrieves the default namespace of this element
+ * @param om_element pointer to om element
+ * @param env axutil_environment MUST Not be NULL
+ * @param element_node corresponding om element node of this om element
+ * @returns pointer to default namespace if available , NULL otherwise
+ */
+ axiom_namespace_t *AXIS2_CALL
+ axiom_element_get_default_namespace(
+ axiom_element_t * om_element,
+ const axutil_env_t * env,
+ axiom_node_t * element_node);
+
+ /**
+ * Serializes the start part of the given element
+ * @param element element to be serialized.
+ * @param env Environment. MUST NOT be NULL.
+ * @param om_output AXIOM output handler to be used in serializing
+ * @return status of the operation. AXIS2_SUCCESS on success else AXIS2_FAILURE
+ */
+ axis2_status_t AXIS2_CALL
+ axiom_element_serialize_start_part(
+ axiom_element_t * om_element,
+ const axutil_env_t * env,
+ axiom_output_t * om_output,
+ axiom_node_t * ele_node);
+
+ /**
+ * Serializes the end part of the given element. serialize_start_part must
+ * have been called before calling this method.
+ * @param om_element pointer to om_element
+ * @param env environment MUST not be NULL
+ * @param om_node pointer to this element node
+ * @param om_output AXIOM output handler to be used in serializing
+ * @return status of the operation. AXIS2_SUCCESS on success else AXIS2_FAILURE
+ */
+ axis2_status_t AXIS2_CALL
+ axiom_element_serialize_end_part(
+ axiom_element_t * om_element,
+ const axutil_env_t * env,
+ axiom_output_t * om_output);
+
+ /**
+ * Set whether the element is empty or not
+ * @param om_element pointer to om_element
+ * @param env environment MUST not be NULL
+ * @param is_empty AXIS2_TRUE if empty AXIS2_FALSE if not empty
+ * @return VOID
+ */
+ void AXIS2_CALL
+ axiom_element_set_is_empty(
+ axiom_element_t * om_element,
+ const axutil_env_t * env,
+ axis2_bool_t is_empty);
+
+#endif /* AXIOM_ELEMENT_INTERNAL_H_ */
diff --git a/axiom/src/soap/axiom_soap_builder_internal.h b/axiom/src/soap/axiom_soap_builder_internal.h
index d23b8e8..5dd7de6 100644
--- a/axiom/src/soap/axiom_soap_builder_internal.h
+++ b/axiom/src/soap/axiom_soap_builder_internal.h
@@ -1,36 +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_ */
+/*
+ * 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/samples/client/amqp/echo/echo_blocking.c b/samples/client/amqp/echo/echo_blocking.c
index d21b2bb..38b7418 100644
--- a/samples/client/amqp/echo/echo_blocking.c
+++ b/samples/client/amqp/echo/echo_blocking.c
@@ -1,124 +1,124 @@
-
-/*
- * 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.
- */
-
-#include "echo_util.h"
-#include <axis2_util.h>
-#include <axiom_soap.h>
-#include <axis2_client.h>
-
-int
-main (int argc, char **argv)
-{
- const axutil_env_t* env = NULL;
- const axis2_char_t* address = NULL;
- axis2_endpoint_ref_t* endpoint_ref = NULL;
- axis2_options_t* options = NULL;
- const axis2_char_t* client_home = NULL;
- axis2_svc_client_t* svc_client = NULL;
- axiom_node_t* payload = NULL;
- axiom_node_t* ret_node = NULL;
-
- /* Set up the environment */
- env = axutil_env_create_all ("echo_blocking_amqp.log", AXIS2_LOG_LEVEL_TRACE);
-
- /* Set end point reference of echo service */
- address = "amqp://localhost:5672/axis2/services/echo";
- if (argc > 1)
- address = argv[1];
-
- if (axutil_strcmp (address, "-h") == 0)
- {
- printf ("Usage : %s [endpoint_url]\n", argv[0]);
- printf ("use -h for help\n");
-
- return 0;
- }
-
- printf ("Using endpoint : %s\n", address);
-
- /* Create EPR with given address */
- endpoint_ref = axis2_endpoint_ref_create (env, address);
-
- /* Setup options */
- options = axis2_options_create (env);
- axis2_options_set_to (options, env, endpoint_ref);
-
- /* Set up deploy folder */
- client_home = AXIS2_GETENV ("AXIS2C_HOME");
- if (!client_home || !strcmp (client_home, ""))
- client_home = "../..";
-
- /* Create service client */
- svc_client = axis2_svc_client_create (env, client_home);
- if (!svc_client)
- {
- printf ("Error creating service client, Please check AXIS2C_HOME again\n");
- AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE (env->error));
- return -1;
- }
-
- /* Set service client options */
- axis2_svc_client_set_options (svc_client, env, options);
-
- /* Build the SOAP request message payload using OM API. */
- payload = build_om_payload_for_echo_svc (env);
-
- /* Send request and get response */
- ret_node = axis2_svc_client_send_receive (svc_client, env, payload);
-
- if (ret_node)
- {
- axis2_char_t *om_str = NULL;
- om_str = axiom_node_to_string (ret_node, env);
- if (om_str)
- {
- printf ("\nReceived OM : %s\n", om_str);
- AXIS2_FREE (env->allocator, om_str);
- }
-
- printf ("\necho client invoke SUCCESSFUL!\n");
- }
- else
- {
- AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE (env->error));
-
- printf ("echo client invoke FAILED!\n");
- }
-
- if (svc_client)
- {
- axis2_svc_client_free (svc_client, env);
- svc_client = NULL;
- }
-
- if (env)
- {
- axutil_env_free ((axutil_env_t*)env);
- env = NULL;
- }
-
- return 0;
-}
-
-
+
+/*
+ * 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.
+ */
+
+#include "echo_util.h"
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+int
+main (int argc, char **argv)
+{
+ const axutil_env_t* env = NULL;
+ const axis2_char_t* address = NULL;
+ axis2_endpoint_ref_t* endpoint_ref = NULL;
+ axis2_options_t* options = NULL;
+ const axis2_char_t* client_home = NULL;
+ axis2_svc_client_t* svc_client = NULL;
+ axiom_node_t* payload = NULL;
+ axiom_node_t* ret_node = NULL;
+
+ /* Set up the environment */
+ env = axutil_env_create_all ("echo_blocking_amqp.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/echo";
+ if (argc > 1)
+ address = argv[1];
+
+ if (axutil_strcmp (address, "-h") == 0)
+ {
+ printf ("Usage : %s [endpoint_url]\n", argv[0]);
+ printf ("use -h for help\n");
+
+ return 0;
+ }
+
+ printf ("Using endpoint : %s\n", address);
+
+ /* Create EPR with given address */
+ endpoint_ref = axis2_endpoint_ref_create (env, address);
+
+ /* Setup options */
+ options = axis2_options_create (env);
+ axis2_options_set_to (options, env, endpoint_ref);
+
+ /* Set up deploy folder */
+ client_home = AXIS2_GETENV ("AXIS2C_HOME");
+ if (!client_home || !strcmp (client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create (env, client_home);
+ if (!svc_client)
+ {
+ printf ("Error creating service client, Please check AXIS2C_HOME again\n");
+ AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE (env->error));
+ return -1;
+ }
+
+ /* Set service client options */
+ axis2_svc_client_set_options (svc_client, env, options);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_payload_for_echo_svc (env);
+
+ /* Send request and get response */
+ ret_node = axis2_svc_client_send_receive (svc_client, env, payload);
+
+ if (ret_node)
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = axiom_node_to_string (ret_node, env);
+ if (om_str)
+ {
+ printf ("\nReceived OM : %s\n", om_str);
+ AXIS2_FREE (env->allocator, om_str);
+ }
+
+ printf ("\necho client invoke SUCCESSFUL!\n");
+ }
+ else
+ {
+ AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE (env->error));
+
+ printf ("echo client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free (svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free ((axutil_env_t*)env);
+ env = NULL;
+ }
+
+ return 0;
+}
+
+
diff --git a/samples/client/amqp/echo/echo_blocking_addr.c b/samples/client/amqp/echo/echo_blocking_addr.c
index 1c0383c..f951972 100644
--- a/samples/client/amqp/echo/echo_blocking_addr.c
+++ b/samples/client/amqp/echo/echo_blocking_addr.c
@@ -1,132 +1,132 @@
-
-/*
- * 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.
- */
-
-#include "echo_util.h"
-#include <axis2_util.h>
-#include <axiom_soap.h>
-#include <axis2_client.h>
-
-int
-main(
- int argc,
- char **argv)
-{
- const axutil_env_t *env = NULL;
- const axis2_char_t *address = NULL;
- axis2_endpoint_ref_t *endpoint_ref = NULL;
- axis2_options_t *options = NULL;
- const axis2_char_t *client_home = NULL;
- axis2_svc_client_t *svc_client = NULL;
- axiom_node_t *payload = NULL;
- axiom_node_t *ret_node = NULL;
-
- /* Set up the environment */
- env =
- axutil_env_create_all("echo_blocking_addr_amqp.log", AXIS2_LOG_LEVEL_TRACE);
-
- /* Set end point reference of echo service */
- address = "amqp://localhost:5672/axis2/services/echo";
- if (argc > 1)
- address = argv[1];
- if (axutil_strcmp(address, "-h") == 0)
- {
- printf("Usage : %s [endpoint_url]\n", argv[0]);
- printf("use -h for help\n");
- return 0;
- }
- printf("Using endpoint : %s\n", address);
-
- /* Create EPR with given address */
- endpoint_ref = axis2_endpoint_ref_create(env, address);
-
- /* Setup options */
- options = axis2_options_create(env);
- axis2_options_set_to(options, env, endpoint_ref);
- axis2_options_set_action(options, env,
- "http://ws.apache.org/axis2/c/samples/echoString");
-
- /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
- * using the axis2.xml file.
- * In this sample client_home points to the Axis2/C default deploy folder. The client_home can
- * be different from this folder on your system. For example, you may have a different folder
- * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the
- * modules that the client uses
- */
- client_home = AXIS2_GETENV("AXIS2C_HOME");
- if (!client_home || !strcmp(client_home, ""))
- client_home = "../..";
-
- /* Create service client */
- svc_client = axis2_svc_client_create(env, client_home);
- if (!svc_client)
- {
- printf
- ("Error creating service client, Please check AXIS2C_HOME again\n");
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- return -1;
- }
-
- /* Set service client options */
- axis2_svc_client_set_options(svc_client, env, options);
-
- /* Engage addressing module */
- axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
-
- /* Build the SOAP request message payload using OM API. */
- payload = build_om_payload_for_echo_svc(env);
-
- /* Send request */
- ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
-
- if (ret_node)
- {
- axis2_char_t *om_str = NULL;
- om_str = axiom_node_to_string(ret_node, env);
- if (om_str)
- {
- printf("\nReceived OM : %s\n", om_str);
- AXIS2_FREE(env->allocator, om_str);
- }
- printf("\necho client invoke SUCCESSFUL!\n");
- }
- else
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- printf("echo client invoke FAILED!\n");
- }
-
- if (svc_client)
- {
- axis2_svc_client_free(svc_client, env);
- svc_client = NULL;
- }
-
- if (env)
- {
- axutil_env_free((axutil_env_t *) env);
- env = NULL;
- }
-
- return 0;
-}
+
+/*
+ * 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.
+ */
+
+#include "echo_util.h"
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_options_t *options = NULL;
+ const axis2_char_t *client_home = NULL;
+ axis2_svc_client_t *svc_client = NULL;
+ axiom_node_t *payload = NULL;
+ axiom_node_t *ret_node = NULL;
+
+ /* Set up the environment */
+ env =
+ axutil_env_create_all("echo_blocking_addr_amqp.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/echo";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_strcmp(address, "-h") == 0)
+ {
+ printf("Usage : %s [endpoint_url]\n", argv[0]);
+ printf("use -h for help\n");
+ return 0;
+ }
+ printf("Using endpoint : %s\n", address);
+
+ /* Create EPR with given address */
+ endpoint_ref = axis2_endpoint_ref_create(env, address);
+
+ /* Setup options */
+ options = axis2_options_create(env);
+ axis2_options_set_to(options, env, endpoint_ref);
+ axis2_options_set_action(options, env,
+ "http://ws.apache.org/axis2/c/samples/echoString");
+
+ /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
+ * using the axis2.xml file.
+ * In this sample client_home points to the Axis2/C default deploy folder. The client_home can
+ * be different from this folder on your system. For example, you may have a different folder
+ * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the
+ * modules that the client uses
+ */
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\n");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ return -1;
+ }
+
+ /* Set service client options */
+ axis2_svc_client_set_options(svc_client, env, options);
+
+ /* Engage addressing module */
+ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_payload_for_echo_svc(env);
+
+ /* Send request */
+ ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+
+ if (ret_node)
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = axiom_node_to_string(ret_node, env);
+ if (om_str)
+ {
+ printf("\nReceived OM : %s\n", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ printf("\necho client invoke SUCCESSFUL!\n");
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ printf("echo client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
diff --git a/samples/client/amqp/echo/echo_blocking_dual.c b/samples/client/amqp/echo/echo_blocking_dual.c
index 2d20ad0..dd95b43 100644
--- a/samples/client/amqp/echo/echo_blocking_dual.c
+++ b/samples/client/amqp/echo/echo_blocking_dual.c
@@ -1,142 +1,142 @@
-
-/*
- * 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.
- */
-
-#include "echo_util.h"
-#include <axis2_util.h>
-#include <axiom_soap.h>
-#include <axis2_client.h>
-
-int
-main(
- int argc,
- char **argv)
-{
- const axutil_env_t *env = NULL;
- const axis2_char_t *address = NULL;
- axis2_endpoint_ref_t *endpoint_ref = NULL;
- axis2_endpoint_ref_t *reply_to = NULL;
- axis2_options_t *options = NULL;
- const axis2_char_t *client_home = NULL;
- axis2_svc_client_t *svc_client = NULL;
- axiom_node_t *payload = NULL;
- axiom_node_t *ret_node = NULL;
-
- /* Set up the environment */
- env =
- axutil_env_create_all("echo_blocking_dual_amqp.log", AXIS2_LOG_LEVEL_TRACE);
-
- /* Set end point reference of echo service */
- address = "amqp://localhost:5672/axis2/services/echo";
- if (argc > 1)
- address = argv[1];
- if (axutil_strcmp(address, "-h") == 0)
- {
- printf("Usage : %s [endpoint_url]\n", argv[0]);
- printf("use -h for help\n");
- return 0;
- }
- printf("Using endpoint : %s\n", address);
-
- /* Create EPR with given address */
- endpoint_ref = axis2_endpoint_ref_create(env, address);
-
- /* Setup options */
- options = axis2_options_create(env);
- axis2_options_set_to(options, env, endpoint_ref);
- axis2_options_set_use_separate_listener(options, env, AXIS2_TRUE);
-
- /* Seperate listner needs addressing, hence addressing stuff in options */
- axis2_options_set_action(options, env,
- "http://ws.apache.org/axis2/c/samples/echoString");
- reply_to =
- axis2_endpoint_ref_create(env,
- "amqp://localhost:5672/axis2/services/__ANONYMOUS_SERVICE__");
- axis2_options_set_reply_to(options, env, reply_to);
-
- axis2_options_set_transport_in_protocol(options, env, AXIS2_TRANSPORT_ENUM_AMQP);
-
- /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
- * using the axis2.xml file.
- * In this sample client_home points to the Axis2/C default deploy folder. The client_home can
- * be different from this folder on your system. For example, you may have a different folder
- * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the
- * modules that the client uses
- */
- client_home = AXIS2_GETENV("AXIS2C_HOME");
- if (!client_home || !strcmp(client_home, ""))
- client_home = "../..";
-
- /* Create service client */
- svc_client = axis2_svc_client_create(env, client_home);
- if (!svc_client)
- {
- printf
- ("Error creating service client, Please check AXIS2C_HOME again\n");
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- return -1;
- }
-
- /* Set service client options */
- axis2_svc_client_set_options(svc_client, env, options);
-
- axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
-
- /* Build the SOAP request message payload using OM API. */
- payload = build_om_payload_for_echo_svc(env);
-
- /* Send request */
- ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
-
- if (ret_node)
- {
- axis2_char_t *om_str = NULL;
- om_str = axiom_node_to_string(ret_node, env);
- if (om_str)
- {
- printf("\nReceived OM : %s\n", om_str);
- AXIS2_FREE(env->allocator, om_str);
- }
- printf("\necho client invoke SUCCESSFUL!\n");
- }
- else
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- printf("echo client invoke FAILED!\n");
- }
-
- if (svc_client)
- {
- AXIS2_SLEEP(1);
- axis2_svc_client_free(svc_client, env);
- svc_client = NULL;
- }
-
- if (env)
- {
- axutil_env_free((axutil_env_t *) env);
- env = NULL;
- }
-
- return 0;
-}
+
+/*
+ * 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.
+ */
+
+#include "echo_util.h"
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_endpoint_ref_t *reply_to = NULL;
+ axis2_options_t *options = NULL;
+ const axis2_char_t *client_home = NULL;
+ axis2_svc_client_t *svc_client = NULL;
+ axiom_node_t *payload = NULL;
+ axiom_node_t *ret_node = NULL;
+
+ /* Set up the environment */
+ env =
+ axutil_env_create_all("echo_blocking_dual_amqp.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/echo";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_strcmp(address, "-h") == 0)
+ {
+ printf("Usage : %s [endpoint_url]\n", argv[0]);
+ printf("use -h for help\n");
+ return 0;
+ }
+ printf("Using endpoint : %s\n", address);
+
+ /* Create EPR with given address */
+ endpoint_ref = axis2_endpoint_ref_create(env, address);
+
+ /* Setup options */
+ options = axis2_options_create(env);
+ axis2_options_set_to(options, env, endpoint_ref);
+ axis2_options_set_use_separate_listener(options, env, AXIS2_TRUE);
+
+ /* Seperate listner needs addressing, hence addressing stuff in options */
+ axis2_options_set_action(options, env,
+ "http://ws.apache.org/axis2/c/samples/echoString");
+ reply_to =
+ axis2_endpoint_ref_create(env,
+ "amqp://localhost:5672/axis2/services/__ANONYMOUS_SERVICE__");
+ axis2_options_set_reply_to(options, env, reply_to);
+
+ axis2_options_set_transport_in_protocol(options, env, AXIS2_TRANSPORT_ENUM_AMQP);
+
+ /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
+ * using the axis2.xml file.
+ * In this sample client_home points to the Axis2/C default deploy folder. The client_home can
+ * be different from this folder on your system. For example, you may have a different folder
+ * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the
+ * modules that the client uses
+ */
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\n");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ return -1;
+ }
+
+ /* Set service client options */
+ axis2_svc_client_set_options(svc_client, env, options);
+
+ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_payload_for_echo_svc(env);
+
+ /* Send request */
+ ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+
+ if (ret_node)
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = axiom_node_to_string(ret_node, env);
+ if (om_str)
+ {
+ printf("\nReceived OM : %s\n", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ printf("\necho client invoke SUCCESSFUL!\n");
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ printf("echo client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ AXIS2_SLEEP(1);
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
diff --git a/samples/client/amqp/echo/echo_blocking_soap11.c b/samples/client/amqp/echo/echo_blocking_soap11.c
index 4281e14..5fab182 100644
--- a/samples/client/amqp/echo/echo_blocking_soap11.c
+++ b/samples/client/amqp/echo/echo_blocking_soap11.c
@@ -1,135 +1,135 @@
-
-/*
- * 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.
- */
-
-#include "echo_util.h"
-#include <axis2_util.h>
-#include <axiom_soap.h>
-#include <axis2_client.h>
-
-int
-main(
- int argc,
- char **argv)
-{
- const axutil_env_t *env = NULL;
- const axis2_char_t *address = NULL;
- axis2_endpoint_ref_t *endpoint_ref = NULL;
- axis2_options_t *options = NULL;
- const axis2_char_t *client_home = NULL;
- axis2_svc_client_t *svc_client = NULL;
- axiom_node_t *payload = NULL;
- axiom_node_t *ret_node = NULL;
- axutil_string_t *soap_action = NULL;
-
- /* Set up the environment */
- env =
- axutil_env_create_all("echo_blocking_soap11_amqp.log",
- AXIS2_LOG_LEVEL_TRACE);
-
- /* Set end point reference of echo service */
- address = "amqp://localhost:5672/axis2/services/echo";
- if (argc > 1)
- address = argv[1];
- if (axutil_strcmp(address, "-h") == 0)
- {
- printf("Usage : %s [endpoint_url]\n", argv[0]);
- printf("use -h for help\n");
- return 0;
- }
- printf("Using endpoint : %s\n", address);
-
- /* Create EPR with given address */
- endpoint_ref = axis2_endpoint_ref_create(env, address);
-
- /* Setup options */
- options = axis2_options_create(env);
- axis2_options_set_to(options, env, endpoint_ref);
- axis2_options_set_soap_version(options, env, AXIOM_SOAP11);
- soap_action =
- axutil_string_create(env,
- "http://ws.apache.org/axis2/c/samples/echo/soap_action");
- axis2_options_set_soap_action(options, env, soap_action);
- axutil_string_free(soap_action, env);
-
- /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
- * using the axis2.xml file.
- * In this sample client_home points to the Axis2/C default deploy folder. The client_home can
- * be different from this folder on your system. For example, you may have a different folder
- * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the
- * modules that the client uses
- */
- client_home = AXIS2_GETENV("AXIS2C_HOME");
- if (!client_home || !strcmp(client_home, ""))
- client_home = "../..";
-
- /* Create service client */
- svc_client = axis2_svc_client_create(env, client_home);
- if (!svc_client)
- {
- printf
- ("Error creating service client, Please check AXIS2C_HOME again\n");
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- return -1;
- }
-
- /* Set service client options */
- axis2_svc_client_set_options(svc_client, env, options);
-
- /* Build the SOAP request message payload using OM API. */
- payload = build_om_payload_for_echo_svc(env);
-
- /* Send request */
- ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
-
- if (ret_node)
- {
- axis2_char_t *om_str = NULL;
- om_str = axiom_node_to_string(ret_node, env);
- if (om_str)
- {
- printf("\nReceived OM : %s\n", om_str);
- AXIS2_FREE(env->allocator, om_str);
- }
- printf("\necho client invoke SUCCESSFUL!\n");
- }
- else
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- printf("echo client invoke FAILED!\n");
- }
-
- if (svc_client)
- {
- axis2_svc_client_free(svc_client, env);
- svc_client = NULL;
- }
-
- if (env)
- {
- axutil_env_free((axutil_env_t *) env);
- env = NULL;
- }
-
- return 0;
-}
+
+/*
+ * 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.
+ */
+
+#include "echo_util.h"
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_options_t *options = NULL;
+ const axis2_char_t *client_home = NULL;
+ axis2_svc_client_t *svc_client = NULL;
+ axiom_node_t *payload = NULL;
+ axiom_node_t *ret_node = NULL;
+ axutil_string_t *soap_action = NULL;
+
+ /* Set up the environment */
+ env =
+ axutil_env_create_all("echo_blocking_soap11_amqp.log",
+ AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/echo";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_strcmp(address, "-h") == 0)
+ {
+ printf("Usage : %s [endpoint_url]\n", argv[0]);
+ printf("use -h for help\n");
+ return 0;
+ }
+ printf("Using endpoint : %s\n", address);
+
+ /* Create EPR with given address */
+ endpoint_ref = axis2_endpoint_ref_create(env, address);
+
+ /* Setup options */
+ options = axis2_options_create(env);
+ axis2_options_set_to(options, env, endpoint_ref);
+ axis2_options_set_soap_version(options, env, AXIOM_SOAP11);
+ soap_action =
+ axutil_string_create(env,
+ "http://ws.apache.org/axis2/c/samples/echo/soap_action");
+ axis2_options_set_soap_action(options, env, soap_action);
+ axutil_string_free(soap_action, env);
+
+ /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
+ * using the axis2.xml file.
+ * In this sample client_home points to the Axis2/C default deploy folder. The client_home can
+ * be different from this folder on your system. For example, you may have a different folder
+ * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the
+ * modules that the client uses
+ */
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\n");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ return -1;
+ }
+
+ /* Set service client options */
+ axis2_svc_client_set_options(svc_client, env, options);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_payload_for_echo_svc(env);
+
+ /* Send request */
+ ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+
+ if (ret_node)
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = axiom_node_to_string(ret_node, env);
+ if (om_str)
+ {
+ printf("\nReceived OM : %s\n", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ printf("\necho client invoke SUCCESSFUL!\n");
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ printf("echo client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
diff --git a/samples/client/amqp/echo/echo_non_blocking.c b/samples/client/amqp/echo/echo_non_blocking.c
index 9846977..0d13aa0 100644
--- a/samples/client/amqp/echo/echo_non_blocking.c
+++ b/samples/client/amqp/echo/echo_non_blocking.c
@@ -1,217 +1,217 @@
-
-/*
- * 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.
- */
-
-#include "echo_util.h"
-#include <axis2_util.h>
-#include <axiom_soap.h>
-#include <axis2_client.h>
-
-/* my on_complete callback function */
-axis2_status_t AXIS2_CALL
-echo_callback_on_complete (struct axis2_callback* callback,
- const axutil_env_t* env);
-
-/* my on_error callback function */
-axis2_status_t AXIS2_CALL
-echo_callback_on_error (struct axis2_callback* callback,
- const axutil_env_t* env,
- int exception);
-
-/* to check whether the callback is completed */
-int isComplete = 0;
-
-int
-main(int argc, char **argv)
-{
- const axutil_env_t *env = NULL;
- const axis2_char_t *address = NULL;
- axis2_endpoint_ref_t *endpoint_ref = NULL;
- axis2_options_t *options = NULL;
- const axis2_char_t *client_home = NULL;
- axis2_svc_client_t *svc_client = NULL;
- axiom_node_t *payload = NULL;
- axis2_callback_t *callback = NULL;
- int count = 0;
-
- /* Set up the environment */
- env = axutil_env_create_all ("echo_non_blocking_amqp.log", AXIS2_LOG_LEVEL_TRACE);
-
- /* Set end point reference of echo service */
- address = "amqp://localhost:5672/axis2/services/echo";
- if (argc > 1)
- address = argv[1];
-
- if (axutil_strcmp (address, "-h") == 0)
- {
- printf ("Usage : %s [endpoint_url]\n", argv[0]);
- printf ("use -h for help\n");
-
- return 0;
- }
-
- printf ("Using endpoint : %s\n", address);
-
- /* Create EPR with given address */
- endpoint_ref = axis2_endpoint_ref_create (env, address);
-
- /* Setup options */
- options = axis2_options_create (env);
- axis2_options_set_to (options, env, endpoint_ref);
-
- /* Set up deploy folder */
- client_home = AXIS2_GETENV ("AXIS2C_HOME");
- if (!client_home || !strcmp (client_home, ""))
- client_home = "../..";
-
- /* Create service client */
- svc_client = axis2_svc_client_create (env, client_home);
- if (!svc_client)
- {
- printf ("Error creating service client, Please check AXIS2C_HOME again\n");
- AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE (env->error));
- return -1;
- }
-
- /* Set service client options */
- axis2_svc_client_set_options (svc_client, env, options);
-
- /* Build the SOAP request message payload using OM API. */
- payload = build_om_payload_for_echo_svc (env);
-
- /* Create the callback object with default on_complete and on_error
- callback functions */
- callback = axis2_callback_create (env);
-
- /* Set our on_complete fucntion pointer to the callback object */
- axis2_callback_set_on_complete (callback, echo_callback_on_complete);
-
- /* Set our on_error function pointer to the callback object */
- axis2_callback_set_on_error (callback, echo_callback_on_error);
-
- /* Send request */
- axis2_svc_client_send_receive_non_blocking (svc_client, env,
- payload, callback);
-
- /*Wait till callback is complete. Simply keep the parent thread running
- until our on_complete or on_error is invoked */
- while (count < 30)
- {
- if (isComplete)
- {
- /* We are done with the callback */
- break;
- }
-
- AXIS2_SLEEP (1);
- count++;
- }
-
- if (!(count < 30))
- {
- printf ("\necho client invoke FAILED. Counter timed out.\n");
- }
-
- if (svc_client)
- {
- axis2_svc_client_free (svc_client, env);
- svc_client = NULL;
- }
-
- if (env)
- {
- axutil_env_free ((axutil_env_t *) env);
- env = NULL;
- }
-
- return 0;
-}
-
-axis2_status_t AXIS2_CALL
-echo_callback_on_complete(struct axis2_callback* callback,
- const axutil_env_t* env)
-{
-
- /** SOAP response has arrived here; get the soap envelope
- from the callback object and do whatever you want to do with it */
-
- axiom_soap_envelope_t *soap_envelope = NULL;
- axiom_node_t *ret_node = NULL;
- axis2_status_t status = AXIS2_SUCCESS;
-
- soap_envelope = axis2_callback_get_envelope (callback, env);
-
- if (!soap_envelope)
- {
- AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE (env->error));
- printf ("echo stub invoke FAILED!\n");
- status = AXIS2_FAILURE;
- }
- else
- {
- ret_node = axiom_soap_envelope_get_base_node (soap_envelope, env);
-
- if (!ret_node)
- {
- AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE (env->error));
-
- printf ("echo stub invoke FAILED!\n");
- status = AXIS2_FAILURE;
- }
- else
- {
- axis2_char_t *om_str = NULL;
- om_str = axiom_node_to_string (ret_node, env);
- if (om_str)
- {
- printf ("\nReceived OM : %s\n", om_str);
- AXIS2_FREE (env->allocator, om_str);
- }
-
- printf ("\necho client invoke SUCCESSFUL!\n");
- }
- }
-
- isComplete = 1;
- return status;
-}
-
-axis2_status_t AXIS2_CALL
-echo_callback_on_error (struct axis2_callback* callback,
- const axutil_env_t* env,
- int exception)
-{
-
- /** take necessary action on error */
- printf ("\necho client invike FAILED. Error code:%d ::%s", exception,
- AXIS2_ERROR_GET_MESSAGE (env->error));
-
- isComplete = 1;
-
- return AXIS2_SUCCESS;
-}
-
-
+
+/*
+ * 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.
+ */
+
+#include "echo_util.h"
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+/* my on_complete callback function */
+axis2_status_t AXIS2_CALL
+echo_callback_on_complete (struct axis2_callback* callback,
+ const axutil_env_t* env);
+
+/* my on_error callback function */
+axis2_status_t AXIS2_CALL
+echo_callback_on_error (struct axis2_callback* callback,
+ const axutil_env_t* env,
+ int exception);
+
+/* to check whether the callback is completed */
+int isComplete = 0;
+
+int
+main(int argc, char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_options_t *options = NULL;
+ const axis2_char_t *client_home = NULL;
+ axis2_svc_client_t *svc_client = NULL;
+ axiom_node_t *payload = NULL;
+ axis2_callback_t *callback = NULL;
+ int count = 0;
+
+ /* Set up the environment */
+ env = axutil_env_create_all ("echo_non_blocking_amqp.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/echo";
+ if (argc > 1)
+ address = argv[1];
+
+ if (axutil_strcmp (address, "-h") == 0)
+ {
+ printf ("Usage : %s [endpoint_url]\n", argv[0]);
+ printf ("use -h for help\n");
+
+ return 0;
+ }
+
+ printf ("Using endpoint : %s\n", address);
+
+ /* Create EPR with given address */
+ endpoint_ref = axis2_endpoint_ref_create (env, address);
+
+ /* Setup options */
+ options = axis2_options_create (env);
+ axis2_options_set_to (options, env, endpoint_ref);
+
+ /* Set up deploy folder */
+ client_home = AXIS2_GETENV ("AXIS2C_HOME");
+ if (!client_home || !strcmp (client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create (env, client_home);
+ if (!svc_client)
+ {
+ printf ("Error creating service client, Please check AXIS2C_HOME again\n");
+ AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE (env->error));
+ return -1;
+ }
+
+ /* Set service client options */
+ axis2_svc_client_set_options (svc_client, env, options);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_payload_for_echo_svc (env);
+
+ /* Create the callback object with default on_complete and on_error
+ callback functions */
+ callback = axis2_callback_create (env);
+
+ /* Set our on_complete fucntion pointer to the callback object */
+ axis2_callback_set_on_complete (callback, echo_callback_on_complete);
+
+ /* Set our on_error function pointer to the callback object */
+ axis2_callback_set_on_error (callback, echo_callback_on_error);
+
+ /* Send request */
+ axis2_svc_client_send_receive_non_blocking (svc_client, env,
+ payload, callback);
+
+ /*Wait till callback is complete. Simply keep the parent thread running
+ until our on_complete or on_error is invoked */
+ while (count < 30)
+ {
+ if (isComplete)
+ {
+ /* We are done with the callback */
+ break;
+ }
+
+ AXIS2_SLEEP (1);
+ count++;
+ }
+
+ if (!(count < 30))
+ {
+ printf ("\necho client invoke FAILED. Counter timed out.\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free (svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free ((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
+
+axis2_status_t AXIS2_CALL
+echo_callback_on_complete(struct axis2_callback* callback,
+ const axutil_env_t* env)
+{
+
+ /** SOAP response has arrived here; get the soap envelope
+ from the callback object and do whatever you want to do with it */
+
+ axiom_soap_envelope_t *soap_envelope = NULL;
+ axiom_node_t *ret_node = NULL;
+ axis2_status_t status = AXIS2_SUCCESS;
+
+ soap_envelope = axis2_callback_get_envelope (callback, env);
+
+ if (!soap_envelope)
+ {
+ AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE (env->error));
+ printf ("echo stub invoke FAILED!\n");
+ status = AXIS2_FAILURE;
+ }
+ else
+ {
+ ret_node = axiom_soap_envelope_get_base_node (soap_envelope, env);
+
+ if (!ret_node)
+ {
+ AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE (env->error));
+
+ printf ("echo stub invoke FAILED!\n");
+ status = AXIS2_FAILURE;
+ }
+ else
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = axiom_node_to_string (ret_node, env);
+ if (om_str)
+ {
+ printf ("\nReceived OM : %s\n", om_str);
+ AXIS2_FREE (env->allocator, om_str);
+ }
+
+ printf ("\necho client invoke SUCCESSFUL!\n");
+ }
+ }
+
+ isComplete = 1;
+ return status;
+}
+
+axis2_status_t AXIS2_CALL
+echo_callback_on_error (struct axis2_callback* callback,
+ const axutil_env_t* env,
+ int exception)
+{
+
+ /** take necessary action on error */
+ printf ("\necho client invike FAILED. Error code:%d ::%s", exception,
+ AXIS2_ERROR_GET_MESSAGE (env->error));
+
+ isComplete = 1;
+
+ return AXIS2_SUCCESS;
+}
+
+
diff --git a/samples/client/amqp/echo/echo_non_blocking_dual.c b/samples/client/amqp/echo/echo_non_blocking_dual.c
index b1ce5a1..db10389 100644
--- a/samples/client/amqp/echo/echo_non_blocking_dual.c
+++ b/samples/client/amqp/echo/echo_non_blocking_dual.c
@@ -1,235 +1,235 @@
-
-/*
- * 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.
- */
-
-#include "echo_util.h"
-#include <axis2_util.h>
-#include <axiom_soap.h>
-#include <axis2_client.h>
-
-#define MAX_COUNT 10
-
-/* my on_complete callback function */
-axis2_status_t AXIS2_CALL echo_callback_on_complete(
- struct axis2_callback * callback,
- const axutil_env_t * env);
-
-/* my on_error callback function */
-axis2_status_t AXIS2_CALL echo_callback_on_error(
- struct axis2_callback *callback,
- const axutil_env_t * env,
- int exception);
-
-/* to check whether the callback is completed */
-int isComplete = 0;
-
-int
-main(
- int argc,
- char **argv)
-{
- const axutil_env_t *env = NULL;
- const axis2_char_t *address = NULL;
- axis2_endpoint_ref_t *endpoint_ref = NULL;
- axis2_endpoint_ref_t *reply_to = NULL;
- axis2_options_t *options = NULL;
- const axis2_char_t *client_home = NULL;
- axis2_svc_client_t *svc_client = NULL;
- axiom_node_t *payload = NULL;
- axis2_callback_t *callback = NULL;
- int count = 0;
-
- /* Set up the environment */
- env =
- axutil_env_create_all("echo_non_blocking_dual_amqp.log",
- AXIS2_LOG_LEVEL_TRACE);
-
- /* Set end point reference of echo service */
- address = "amqp://localhost:5672/axis2/services/echo";
- if (argc > 1)
- address = argv[1];
- if (axutil_strcmp(address, "-h") == 0)
- {
- printf("Usage : %s [endpoint_url]\n", argv[0]);
- printf("use -h for help\n");
- return 0;
- }
- printf("Using endpoint : %s\n", address);
-
- /* Create EPR with given address */
- endpoint_ref = axis2_endpoint_ref_create(env, address);
-
- /* Setup options */
- options = axis2_options_create(env);
- axis2_options_set_to(options, env, endpoint_ref);
- axis2_options_set_use_separate_listener(options, env, AXIS2_TRUE);
-
- /* Seperate listner needs addressing, hence addressing stuff in options */
- axis2_options_set_action(options, env,
- "http://ws.apache.org/axis2/c/samples/echoString");
- reply_to =
- axis2_endpoint_ref_create(env,
- "amqp://localhost:5672/axis2/services/__ANONYMOUS_SERVICE__");
- axis2_options_set_reply_to(options, env, reply_to);
-
- axis2_options_set_transport_in_protocol(options, env, AXIS2_TRANSPORT_ENUM_AMQP);
-
- /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
- * using the axis2.xml file.
- * In this sample client_home points to the Axis2/C default deploy folder. The client_home can
- * be different from this folder on your system. For example, you may have a different folder
- * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the
- * modules that the client uses
- */
- client_home = AXIS2_GETENV("AXIS2C_HOME");
- if (!client_home || !strcmp(client_home, ""))
- client_home = "../..";
-
- /* Create service client */
- svc_client = axis2_svc_client_create(env, client_home);
- if (!svc_client)
- {
- printf
- ("Error creating service client, Please check AXIS2C_HOME again\n");
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- return -1;
- }
-
- /* Set service client options */
- axis2_svc_client_set_options(svc_client, env, options);
-
- axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
- /*axis2_svc_client_engage_module(svc_client, env, "sandesha2"); */
-
- /* Build the SOAP request message payload using OM API. */
- payload = build_om_payload_for_echo_svc(env);
-
- /* Create the callback object with default on_complete and on_error
- callback functions */
- callback = axis2_callback_create(env);
-
- /* Set our on_complete fucntion pointer to the callback object */
- axis2_callback_set_on_complete(callback, echo_callback_on_complete);
-
- /* Set our on_error function pointer to the callback object */
- axis2_callback_set_on_error(callback, echo_callback_on_error);
-
- /* Send request */
- axis2_svc_client_send_receive_non_blocking(svc_client, env,
- payload, callback);
-
- /** Wait till callback is complete. Simply keep the parent thread running
- until our on_complete or on_error is invoked */
- while (count < MAX_COUNT)
- {
- if (isComplete)
- {
- /* We are done with the callback */
- break;
- }
-
- AXIS2_SLEEP(1);
- count++;
- }
-
- if (!(count < MAX_COUNT))
- {
- printf("\necho client invoke FAILED. Counter timed out.\n");
- }
-
- if (svc_client)
- {
- AXIS2_SLEEP(1);
- axis2_svc_client_free(svc_client, env);
- svc_client = NULL;
- }
-
- if (env)
- {
- axutil_env_free((axutil_env_t *) env);
- env = NULL;
- }
-
- return 0;
-}
-
-axis2_status_t AXIS2_CALL
-echo_callback_on_complete(
- struct axis2_callback * callback,
- const axutil_env_t * env)
-{
-
- /** SOAP response has arrived here; get the soap envelope
- from the callback object and do whatever you want to do with it */
-
- axiom_soap_envelope_t *soap_envelope = NULL;
- axiom_node_t *ret_node = NULL;
- axis2_status_t status = AXIS2_SUCCESS;
-
- soap_envelope = axis2_callback_get_envelope(callback, env);
-
- if (!soap_envelope)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- printf("echo stub invoke FAILED!\n");
- status = AXIS2_FAILURE;
- }
- else
- {
- ret_node = axiom_soap_envelope_get_base_node(soap_envelope, env);
-
- if (!ret_node)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- printf("echo stub invoke FAILED!\n");
- status = AXIS2_FAILURE;
- }
- else
- {
- axis2_char_t *om_str = NULL;
- om_str = axiom_node_to_string(ret_node, env);
- if (om_str)
- printf("\nReceived OM : %s\n", om_str);
- printf("\necho client invoke SUCCESSFUL!\n");
- }
- }
- isComplete = 1;
- return status;
-}
-
-axis2_status_t AXIS2_CALL
-echo_callback_on_error(
- struct axis2_callback * callback,
- const axutil_env_t * env,
- int exception)
-{
-
- /** take necessary action on error */
- printf("\nEcho client invoke FAILED. Error code:%d ::%s", exception,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- isComplete = 1;
- return AXIS2_SUCCESS;
-}
+
+/*
+ * 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.
+ */
+
+#include "echo_util.h"
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+#define MAX_COUNT 10
+
+/* my on_complete callback function */
+axis2_status_t AXIS2_CALL echo_callback_on_complete(
+ struct axis2_callback * callback,
+ const axutil_env_t * env);
+
+/* my on_error callback function */
+axis2_status_t AXIS2_CALL echo_callback_on_error(
+ struct axis2_callback *callback,
+ const axutil_env_t * env,
+ int exception);
+
+/* to check whether the callback is completed */
+int isComplete = 0;
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_endpoint_ref_t *reply_to = NULL;
+ axis2_options_t *options = NULL;
+ const axis2_char_t *client_home = NULL;
+ axis2_svc_client_t *svc_client = NULL;
+ axiom_node_t *payload = NULL;
+ axis2_callback_t *callback = NULL;
+ int count = 0;
+
+ /* Set up the environment */
+ env =
+ axutil_env_create_all("echo_non_blocking_dual_amqp.log",
+ AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/echo";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_strcmp(address, "-h") == 0)
+ {
+ printf("Usage : %s [endpoint_url]\n", argv[0]);
+ printf("use -h for help\n");
+ return 0;
+ }
+ printf("Using endpoint : %s\n", address);
+
+ /* Create EPR with given address */
+ endpoint_ref = axis2_endpoint_ref_create(env, address);
+
+ /* Setup options */
+ options = axis2_options_create(env);
+ axis2_options_set_to(options, env, endpoint_ref);
+ axis2_options_set_use_separate_listener(options, env, AXIS2_TRUE);
+
+ /* Seperate listner needs addressing, hence addressing stuff in options */
+ axis2_options_set_action(options, env,
+ "http://ws.apache.org/axis2/c/samples/echoString");
+ reply_to =
+ axis2_endpoint_ref_create(env,
+ "amqp://localhost:5672/axis2/services/__ANONYMOUS_SERVICE__");
+ axis2_options_set_reply_to(options, env, reply_to);
+
+ axis2_options_set_transport_in_protocol(options, env, AXIS2_TRANSPORT_ENUM_AMQP);
+
+ /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
+ * using the axis2.xml file.
+ * In this sample client_home points to the Axis2/C default deploy folder. The client_home can
+ * be different from this folder on your system. For example, you may have a different folder
+ * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the
+ * modules that the client uses
+ */
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\n");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ return -1;
+ }
+
+ /* Set service client options */
+ axis2_svc_client_set_options(svc_client, env, options);
+
+ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
+ /*axis2_svc_client_engage_module(svc_client, env, "sandesha2"); */
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_payload_for_echo_svc(env);
+
+ /* Create the callback object with default on_complete and on_error
+ callback functions */
+ callback = axis2_callback_create(env);
+
+ /* Set our on_complete fucntion pointer to the callback object */
+ axis2_callback_set_on_complete(callback, echo_callback_on_complete);
+
+ /* Set our on_error function pointer to the callback object */
+ axis2_callback_set_on_error(callback, echo_callback_on_error);
+
+ /* Send request */
+ axis2_svc_client_send_receive_non_blocking(svc_client, env,
+ payload, callback);
+
+ /** Wait till callback is complete. Simply keep the parent thread running
+ until our on_complete or on_error is invoked */
+ while (count < MAX_COUNT)
+ {
+ if (isComplete)
+ {
+ /* We are done with the callback */
+ break;
+ }
+
+ AXIS2_SLEEP(1);
+ count++;
+ }
+
+ if (!(count < MAX_COUNT))
+ {
+ printf("\necho client invoke FAILED. Counter timed out.\n");
+ }
+
+ if (svc_client)
+ {
+ AXIS2_SLEEP(1);
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
+
+axis2_status_t AXIS2_CALL
+echo_callback_on_complete(
+ struct axis2_callback * callback,
+ const axutil_env_t * env)
+{
+
+ /** SOAP response has arrived here; get the soap envelope
+ from the callback object and do whatever you want to do with it */
+
+ axiom_soap_envelope_t *soap_envelope = NULL;
+ axiom_node_t *ret_node = NULL;
+ axis2_status_t status = AXIS2_SUCCESS;
+
+ soap_envelope = axis2_callback_get_envelope(callback, env);
+
+ if (!soap_envelope)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ printf("echo stub invoke FAILED!\n");
+ status = AXIS2_FAILURE;
+ }
+ else
+ {
+ ret_node = axiom_soap_envelope_get_base_node(soap_envelope, env);
+
+ if (!ret_node)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ printf("echo stub invoke FAILED!\n");
+ status = AXIS2_FAILURE;
+ }
+ else
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = axiom_node_to_string(ret_node, env);
+ if (om_str)
+ printf("\nReceived OM : %s\n", om_str);
+ printf("\necho client invoke SUCCESSFUL!\n");
+ }
+ }
+ isComplete = 1;
+ return status;
+}
+
+axis2_status_t AXIS2_CALL
+echo_callback_on_error(
+ struct axis2_callback * callback,
+ const axutil_env_t * env,
+ int exception)
+{
+
+ /** take necessary action on error */
+ printf("\nEcho client invoke FAILED. Error code:%d ::%s", exception,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ isComplete = 1;
+ return AXIS2_SUCCESS;
+}
diff --git a/samples/client/amqp/echo/echo_util.c b/samples/client/amqp/echo/echo_util.c
index c49d42d..eb5dd98 100644
--- a/samples/client/amqp/echo/echo_util.c
+++ b/samples/client/amqp/echo/echo_util.c
@@ -1,47 +1,47 @@
-
-/*
- * 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.
- */
-
-#include "echo_util.h"
-
-/* build SOAP request message content using OM */
-axiom_node_t*
-build_om_payload_for_echo_svc (const axutil_env_t* env)
-{
- axiom_node_t* echo_om_node = NULL;
- axiom_element_t* echo_om_ele = NULL;
- axiom_node_t* text_om_node = NULL;
- axiom_element_t* text_om_ele = NULL;
- axiom_namespace_t* ns1 = NULL;
- axis2_char_t* om_str = NULL;
-
- ns1 = axiom_namespace_create (env, "http://ws.apache.org/axis2/services/echo",
- "ns1");
- echo_om_ele = axiom_element_create (env, NULL, "echoString", ns1, &echo_om_node);
- text_om_ele = axiom_element_create (env, echo_om_node, "text", NULL, &text_om_node);
- axiom_element_set_text (text_om_ele, env, "Hello World!", text_om_node);
-
- om_str = axiom_node_to_string (echo_om_node, env);
- if (om_str)
- printf ("\nSending OM : %s\n", om_str);
-
- AXIS2_FREE (env->allocator, om_str);
-
- return echo_om_node;
-}
-
-
+
+/*
+ * 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.
+ */
+
+#include "echo_util.h"
+
+/* build SOAP request message content using OM */
+axiom_node_t*
+build_om_payload_for_echo_svc (const axutil_env_t* env)
+{
+ axiom_node_t* echo_om_node = NULL;
+ axiom_element_t* echo_om_ele = NULL;
+ axiom_node_t* text_om_node = NULL;
+ axiom_element_t* text_om_ele = NULL;
+ axiom_namespace_t* ns1 = NULL;
+ axis2_char_t* om_str = NULL;
+
+ ns1 = axiom_namespace_create (env, "http://ws.apache.org/axis2/services/echo",
+ "ns1");
+ echo_om_ele = axiom_element_create (env, NULL, "echoString", ns1, &echo_om_node);
+ text_om_ele = axiom_element_create (env, echo_om_node, "text", NULL, &text_om_node);
+ axiom_element_set_text (text_om_ele, env, "Hello World!", text_om_node);
+
+ om_str = axiom_node_to_string (echo_om_node, env);
+ if (om_str)
+ printf ("\nSending OM : %s\n", om_str);
+
+ AXIS2_FREE (env->allocator, om_str);
+
+ return echo_om_node;
+}
+
+
diff --git a/samples/client/amqp/echo/echo_util.h b/samples/client/amqp/echo/echo_util.h
index c932efb..9bce13b 100644
--- a/samples/client/amqp/echo/echo_util.h
+++ b/samples/client/amqp/echo/echo_util.h
@@ -1,54 +1,54 @@
-
-/*
- * 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 AXIS2_UG_ECHO_UTIL_H
-#define AXIS2_UG_ECHO_UTIL_H
-
-#include <stdio.h>
-#include <axiom.h>
-
-axiom_node_t* build_om_payload_for_echo_svc (const axutil_env_t * env);
-
-#endif
-
-/*
- * 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 AXIS2_UG_ECHO_UTIL_H
-#define AXIS2_UG_ECHO_UTIL_H
-
-#include <stdio.h>
-#include <axiom.h>
-
-axiom_node_t* build_om_payload_for_echo_svc (const axutil_env_t * env);
-
-#endif
+
+/*
+ * 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 AXIS2_UG_ECHO_UTIL_H
+#define AXIS2_UG_ECHO_UTIL_H
+
+#include <stdio.h>
+#include <axiom.h>
+
+axiom_node_t* build_om_payload_for_echo_svc (const axutil_env_t * env);
+
+#endif
+
+/*
+ * 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 AXIS2_UG_ECHO_UTIL_H
+#define AXIS2_UG_ECHO_UTIL_H
+
+#include <stdio.h>
+#include <axiom.h>
+
+axiom_node_t* build_om_payload_for_echo_svc (const axutil_env_t * env);
+
+#endif
diff --git a/samples/client/amqp/mtom/mtom_client.c b/samples/client/amqp/mtom/mtom_client.c
index da87e1b..804b796 100644
--- a/samples/client/amqp/mtom/mtom_client.c
+++ b/samples/client/amqp/mtom/mtom_client.c
@@ -1,259 +1,259 @@
-
-/*
- * 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.
- */
-
-#include <stdio.h>
-#include <axiom.h>
-#include <axis2_util.h>
-#include <axiom_soap.h>
-#include <axis2_client.h>
-
-axiom_node_t *build_om_programatically(
- const axutil_env_t * env,
- const axis2_char_t * image_name,
- const axis2_char_t * to_save_name,
- axis2_bool_t optimized);
-
-int
-process_response_node(
- const axutil_env_t * env,
- axiom_node_t *node,
- const axis2_char_t * to_save_name);
-
-
-int
-main(
- int argc,
- char **argv)
-{
- const axutil_env_t *env = NULL;
- const axis2_char_t *address = NULL;
- axis2_endpoint_ref_t *endpoint_ref = NULL;
- axis2_options_t *options = NULL;
- const axis2_char_t *client_home = NULL;
- axis2_svc_client_t *svc_client = NULL;
- axiom_node_t *payload = NULL;
- axiom_node_t *ret_node = NULL;
- const axis2_char_t *image_name = "resources/axis2.jpg";
- const axis2_char_t *to_save_name = "test.jpg";
- axis2_bool_t optimized = AXIS2_TRUE;
-
- /* Set up the environment */
- env = axutil_env_create_all("mtom_amqp.log", AXIS2_LOG_LEVEL_TRACE);
-
- /* Set end point reference of mtom service */
- address = "amqp://localhost:5672/axis2/services/mtom";
- if (argc > 1)
- address = argv[1];
- if (axutil_strcmp(address, "-h") == 0)
- {
- printf
- ("Usage : %s [endpoint_url] [image_name] [to_save_name] [do_not_optimize]\n",
- argv[0]);
- printf("use -h for help\n");
- return 0;
- }
- if (argc > 2)
- image_name = argv[2];
- if (argc > 3)
- to_save_name = argv[3];
- if (argc > 4)
- optimized = AXIS2_FALSE;
-
- printf("Using endpoint : %s\n", address);
-
- /* Create EPR with given address */
- endpoint_ref = axis2_endpoint_ref_create(env, address);
-
- /* Setup options */
- options = axis2_options_create(env);
- axis2_options_set_to(options, env, endpoint_ref);
- axis2_options_set_action(options, env,
- "http://ws.apache.org/axis2/c/samples/mtomSample");
-
- axis2_options_set_soap_version(options, env, AXIOM_SOAP11);
-
- if(optimized)
- {
- axis2_options_set_enable_mtom(options, env, AXIS2_TRUE);
- }
-
- /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
- * using the axis2.xml file.
- * In this sample client_home points to the Axis2/C default deploy folder. The client_home can
- * be different from this folder on your system. For example, you may have a different folder
- * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the
- * modules that the client uses
- */
- client_home = AXIS2_GETENV("AXIS2C_HOME");
- if (!client_home || !strcmp(client_home, ""))
- client_home = "../..";
-
- /* Create service client */
- svc_client = axis2_svc_client_create(env, client_home);
- if (!svc_client)
- {
- printf
- ("Error creating service client, Please check AXIS2C_HOME again\n");
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- return -1;
- }
-
- /* Set service client options */
- axis2_svc_client_set_options(svc_client, env, options);
-
- /* Engage addressing module */
- axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
-
- /* Build the SOAP request message payload using OM API. */
- payload =
- build_om_programatically(env, image_name, to_save_name, optimized);
-
- /* Send request */
- ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
- if (ret_node)
- {
- axis2_char_t *om_str = NULL;
- om_str = axiom_node_to_string(ret_node, env);
- if (om_str)
- {
- if (axis2_svc_client_get_last_response_has_fault(svc_client, env) == AXIS2_TRUE)
- {
- printf("\nRecieved Fault : %s\n", om_str);
- AXIS2_FREE(env->allocator, om_str);
- }
- else
- {
- printf("\nReceived OM : %s\n", om_str);
- AXIS2_FREE(env->allocator, om_str);
- printf("\nmtom client invoke SUCCESSFUL!\n");
- process_response_node(env, ret_node, to_save_name);
- }
- }
- }
- else
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- printf("\nmtom client invoke FAILED!\n");
- }
-
- if (svc_client)
- {
- axis2_svc_client_free(svc_client, env);
- svc_client = NULL;
- }
-
- if (env)
- {
- axutil_env_free((axutil_env_t *) env);
- env = NULL;
- }
-
- return 0;
-
-}
-
-/* build SOAP request message content using OM */
-axiom_node_t *
-build_om_programatically(
- const axutil_env_t * env,
- const axis2_char_t * image_name,
- const axis2_char_t * to_save_name,
- axis2_bool_t optimized)
-{
- axiom_node_t *mtom_om_node = NULL;
- axiom_element_t *mtom_om_ele = NULL;
- axiom_node_t *image_om_node = NULL;
- axiom_element_t *image_om_ele = NULL;
- axiom_node_t *file_om_node = NULL;
- axiom_element_t *file_om_ele = NULL;
- axiom_node_t *data_om_node = NULL;
- axiom_text_t *data_text = NULL;
- axiom_namespace_t *ns1 = NULL;
- axis2_char_t *om_str = NULL;
-
- axiom_data_handler_t *data_handler = NULL;
-
- ns1 =
- axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples/mtom",
- "ns1");
- mtom_om_ele =
- axiom_element_create(env, NULL, "mtomSample", ns1, &mtom_om_node);
-
- file_om_ele =
- axiom_element_create(env, mtom_om_node, "fileName", ns1, &file_om_node);
- axiom_element_set_text(file_om_ele, env, to_save_name, file_om_node);
-
- image_om_ele =
- axiom_element_create(env, mtom_om_node, "image", ns1, &image_om_node);
-
- data_handler = axiom_data_handler_create(env, image_name, "image/jpeg");
- data_text =
- axiom_text_create_with_data_handler(env, image_om_node, data_handler,
- &data_om_node);
- axiom_text_set_optimize(data_text, env, optimized);
- om_str = axiom_node_to_string(mtom_om_node, env);
- if (om_str)
- {
- printf("%s", om_str);
- AXIS2_FREE(env->allocator, om_str);
- }
- return mtom_om_node;
-}
-
-
-int
-process_response_node(
- const axutil_env_t * env,
- axiom_node_t *node,
- const axis2_char_t * to_save_name)
-{
- axiom_node_t *res_om_node = NULL;
- axiom_element_t *res_om_ele = NULL;
- res_om_node = axiom_node_get_first_child(node, env);
-
- if(axiom_node_get_node_type(res_om_node, env) == AXIOM_TEXT)
- {/** received mtom atttachment */
- axiom_data_handler_t *data_handler = NULL;
- axiom_text_t *axiom_text = (axiom_text_t*)axiom_node_get_data_element(res_om_node, env);
- data_handler = axiom_text_get_data_handler(axiom_text, env);
-
- /*axiom_data_handler_set_file_name(data_handler, env, (axis2_char_t *)to_save_name);*/
- if(axiom_data_handler_get_cached(data_handler, env))
- {
- printf("Attachment is cached.\n");
- }
- else
- {
- axiom_data_handler_set_file_name(data_handler, env, "test");
- axiom_data_handler_write_to(data_handler, env);
- }
- }else if(axiom_node_get_node_type(res_om_node, env) == AXIOM_ELEMENT){
- res_om_ele = axiom_node_get_data_element(res_om_node, env);
- printf("Base64 String received \n\n\n %s \n\n", axiom_element_get_text(res_om_ele, env, res_om_node));
- }
-
- return 0;
-}
-
-
+
+/*
+ * 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.
+ */
+
+#include <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+axiom_node_t *build_om_programatically(
+ const axutil_env_t * env,
+ const axis2_char_t * image_name,
+ const axis2_char_t * to_save_name,
+ axis2_bool_t optimized);
+
+int
+process_response_node(
+ const axutil_env_t * env,
+ axiom_node_t *node,
+ const axis2_char_t * to_save_name);
+
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_options_t *options = NULL;
+ const axis2_char_t *client_home = NULL;
+ axis2_svc_client_t *svc_client = NULL;
+ axiom_node_t *payload = NULL;
+ axiom_node_t *ret_node = NULL;
+ const axis2_char_t *image_name = "resources/axis2.jpg";
+ const axis2_char_t *to_save_name = "test.jpg";
+ axis2_bool_t optimized = AXIS2_TRUE;
+
+ /* Set up the environment */
+ env = axutil_env_create_all("mtom_amqp.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of mtom service */
+ address = "amqp://localhost:5672/axis2/services/mtom";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_strcmp(address, "-h") == 0)
+ {
+ printf
+ ("Usage : %s [endpoint_url] [image_name] [to_save_name] [do_not_optimize]\n",
+ argv[0]);
+ printf("use -h for help\n");
+ return 0;
+ }
+ if (argc > 2)
+ image_name = argv[2];
+ if (argc > 3)
+ to_save_name = argv[3];
+ if (argc > 4)
+ optimized = AXIS2_FALSE;
+
+ printf("Using endpoint : %s\n", address);
+
+ /* Create EPR with given address */
+ endpoint_ref = axis2_endpoint_ref_create(env, address);
+
+ /* Setup options */
+ options = axis2_options_create(env);
+ axis2_options_set_to(options, env, endpoint_ref);
+ axis2_options_set_action(options, env,
+ "http://ws.apache.org/axis2/c/samples/mtomSample");
+
+ axis2_options_set_soap_version(options, env, AXIOM_SOAP11);
+
+ if(optimized)
+ {
+ axis2_options_set_enable_mtom(options, env, AXIS2_TRUE);
+ }
+
+ /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
+ * using the axis2.xml file.
+ * In this sample client_home points to the Axis2/C default deploy folder. The client_home can
+ * be different from this folder on your system. For example, you may have a different folder
+ * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the
+ * modules that the client uses
+ */
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\n");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ return -1;
+ }
+
+ /* Set service client options */
+ axis2_svc_client_set_options(svc_client, env, options);
+
+ /* Engage addressing module */
+ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload =
+ build_om_programatically(env, image_name, to_save_name, optimized);
+
+ /* Send request */
+ ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
+ if (ret_node)
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = axiom_node_to_string(ret_node, env);
+ if (om_str)
+ {
+ if (axis2_svc_client_get_last_response_has_fault(svc_client, env) == AXIS2_TRUE)
+ {
+ printf("\nRecieved Fault : %s\n", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ else
+ {
+ printf("\nReceived OM : %s\n", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ printf("\nmtom client invoke SUCCESSFUL!\n");
+ process_response_node(env, ret_node, to_save_name);
+ }
+ }
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ printf("\nmtom client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+
+}
+
+/* build SOAP request message content using OM */
+axiom_node_t *
+build_om_programatically(
+ const axutil_env_t * env,
+ const axis2_char_t * image_name,
+ const axis2_char_t * to_save_name,
+ axis2_bool_t optimized)
+{
+ axiom_node_t *mtom_om_node = NULL;
+ axiom_element_t *mtom_om_ele = NULL;
+ axiom_node_t *image_om_node = NULL;
+ axiom_element_t *image_om_ele = NULL;
+ axiom_node_t *file_om_node = NULL;
+ axiom_element_t *file_om_ele = NULL;
+ axiom_node_t *data_om_node = NULL;
+ axiom_text_t *data_text = NULL;
+ axiom_namespace_t *ns1 = NULL;
+ axis2_char_t *om_str = NULL;
+
+ axiom_data_handler_t *data_handler = NULL;
+
+ ns1 =
+ axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples/mtom",
+ "ns1");
+ mtom_om_ele =
+ axiom_element_create(env, NULL, "mtomSample", ns1, &mtom_om_node);
+
+ file_om_ele =
+ axiom_element_create(env, mtom_om_node, "fileName", ns1, &file_om_node);
+ axiom_element_set_text(file_om_ele, env, to_save_name, file_om_node);
+
+ image_om_ele =
+ axiom_element_create(env, mtom_om_node, "image", ns1, &image_om_node);
+
+ data_handler = axiom_data_handler_create(env, image_name, "image/jpeg");
+ data_text =
+ axiom_text_create_with_data_handler(env, image_om_node, data_handler,
+ &data_om_node);
+ axiom_text_set_optimize(data_text, env, optimized);
+ om_str = axiom_node_to_string(mtom_om_node, env);
+ if (om_str)
+ {
+ printf("%s", om_str);
+ AXIS2_FREE(env->allocator, om_str);
+ }
+ return mtom_om_node;
+}
+
+
+int
+process_response_node(
+ const axutil_env_t * env,
+ axiom_node_t *node,
+ const axis2_char_t * to_save_name)
+{
+ axiom_node_t *res_om_node = NULL;
+ axiom_element_t *res_om_ele = NULL;
+ res_om_node = axiom_node_get_first_child(node, env);
+
+ if(axiom_node_get_node_type(res_om_node, env) == AXIOM_TEXT)
+ {/** received mtom atttachment */
+ axiom_data_handler_t *data_handler = NULL;
+ axiom_text_t *axiom_text = (axiom_text_t*)axiom_node_get_data_element(res_om_node, env);
+ data_handler = axiom_text_get_data_handler(axiom_text, env);
+
+ /*axiom_data_handler_set_file_name(data_handler, env, (axis2_char_t *)to_save_name);*/
+ if(axiom_data_handler_get_cached(data_handler, env))
+ {
+ printf("Attachment is cached.\n");
+ }
+ else
+ {
+ axiom_data_handler_set_file_name(data_handler, env, "test");
+ axiom_data_handler_write_to(data_handler, env);
+ }
+ }else if(axiom_node_get_node_type(res_om_node, env) == AXIOM_ELEMENT){
+ res_om_ele = axiom_node_get_data_element(res_om_node, env);
+ printf("Base64 String received \n\n\n %s \n\n", axiom_element_get_text(res_om_ele, env, res_om_node));
+ }
+
+ return 0;
+}
+
+
diff --git a/samples/client/amqp/notify/notify_client.c b/samples/client/amqp/notify/notify_client.c
index f562a5c..acc341e 100644
--- a/samples/client/amqp/notify/notify_client.c
+++ b/samples/client/amqp/notify/notify_client.c
@@ -1,152 +1,152 @@
-
-/*
- * 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.
- */
-
-#include <stdio.h>
-#include <axiom.h>
-#include <axis2_util.h>
-#include <axiom_soap.h>
-#include <axis2_client.h>
-
-axiom_node_t *build_om_programatically(
- const axutil_env_t * env);
-
-int
-main(
- int argc,
- char **argv)
-{
- const axutil_env_t *env = NULL;
- const axis2_char_t *address = NULL;
- axis2_endpoint_ref_t *endpoint_ref = NULL;
- axis2_options_t *options = NULL;
- const axis2_char_t *client_home = NULL;
- axis2_svc_client_t *svc_client = NULL;
- axiom_node_t *payload = NULL;
- axis2_status_t status = AXIS2_FAILURE;
-
- /* Set up the environment */
- env = axutil_env_create_all("notify_amqp.log", AXIS2_LOG_LEVEL_TRACE);
-
- /* Set end point reference of echo service */
- address = "amqp://localhost:5672/axis2/services/notify";
- if (argc > 1)
- address = argv[1];
- if (axutil_strcmp(address, "-h") == 0)
- {
- printf("Usage : %s [endpoint_url]\n", argv[0]);
- printf("use -h for help\n");
- return 0;
- }
- printf("Using endpoint : %s\n", address);
-
- /* Create EPR with given address */
- endpoint_ref = axis2_endpoint_ref_create(env, address);
-
- /* Setup options */
- options = axis2_options_create(env);
- axis2_options_set_to(options, env, endpoint_ref);
- axis2_options_set_action(options, env, "http://example.org/action/notify");
-
- /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
- * using the axis2.xml file.
- * In this sample client_home points to the Axis2/C default deploy folder. The client_home can
- * be different from this folder on your system. For example, you may have a different folder
- * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the
- * modules that the client uses
- */
- client_home = AXIS2_GETENV("AXIS2C_HOME");
- if (!client_home || !strcmp(client_home, ""))
- client_home = "../..";
-
- /* Create service client */
- svc_client = axis2_svc_client_create(env, client_home);
- if (!svc_client)
- {
- printf
- ("Error creating service client, Please check AXIS2C_HOME again\n");
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- return -1;
- }
-
- /* Set service client options */
- axis2_svc_client_set_options(svc_client, env, options);
-
- /* Engage addressing module */
- axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
-
- /* Build the SOAP request message payload using OM API. */
- payload = build_om_programatically(env);
-
- /* Send request */
- status = axis2_svc_client_send_robust(svc_client, env, payload);
-
- if (status == AXIS2_SUCCESS)
- {
- printf("\nnotify client invoke SUCCESSFUL!\n");
- }
- else
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Stub invoke FAILED: Error code:" " %d :: %s",
- env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(env->error));
- printf("notify client invoke FAILED!\n");
- }
-
- if (svc_client)
- {
- axis2_svc_client_free(svc_client, env);
- svc_client = NULL;
- }
-
- if (env)
- {
- axutil_env_free((axutil_env_t *) env);
- env = NULL;
- }
-
- return 0;
-}
-
-/* build SOAP request message content using OM */
-axiom_node_t *
-build_om_programatically(
- const axutil_env_t * env)
-{
- axiom_node_t *notify_om_node = NULL;
- axiom_element_t *notify_om_ele = NULL;
- axiom_namespace_t *ns1 = NULL;
- axis2_char_t *buffer = NULL;
-
- ns1 = axiom_namespace_create(env, "http://example.org/notify", "m");
- notify_om_ele =
- axiom_element_create(env, NULL, "notify", ns1, &notify_om_node);
- axiom_element_set_text(notify_om_ele, env, "notify5", notify_om_node);
-
- buffer = axiom_node_to_string(notify_om_node, env);
- if (buffer)
- {
- printf("\nSending OM node in XML : %s \n", buffer);
- AXIS2_FREE(env->allocator, buffer);
- }
-
- return notify_om_node;
-}
+
+/*
+ * 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.
+ */
+
+#include <stdio.h>
+#include <axiom.h>
+#include <axis2_util.h>
+#include <axiom_soap.h>
+#include <axis2_client.h>
+
+axiom_node_t *build_om_programatically(
+ const axutil_env_t * env);
+
+int
+main(
+ int argc,
+ char **argv)
+{
+ const axutil_env_t *env = NULL;
+ const axis2_char_t *address = NULL;
+ axis2_endpoint_ref_t *endpoint_ref = NULL;
+ axis2_options_t *options = NULL;
+ const axis2_char_t *client_home = NULL;
+ axis2_svc_client_t *svc_client = NULL;
+ axiom_node_t *payload = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+
+ /* Set up the environment */
+ env = axutil_env_create_all("notify_amqp.log", AXIS2_LOG_LEVEL_TRACE);
+
+ /* Set end point reference of echo service */
+ address = "amqp://localhost:5672/axis2/services/notify";
+ if (argc > 1)
+ address = argv[1];
+ if (axutil_strcmp(address, "-h") == 0)
+ {
+ printf("Usage : %s [endpoint_url]\n", argv[0]);
+ printf("use -h for help\n");
+ return 0;
+ }
+ printf("Using endpoint : %s\n", address);
+
+ /* Create EPR with given address */
+ endpoint_ref = axis2_endpoint_ref_create(env, address);
+
+ /* Setup options */
+ options = axis2_options_create(env);
+ axis2_options_set_to(options, env, endpoint_ref);
+ axis2_options_set_action(options, env, "http://example.org/action/notify");
+
+ /* Set up deploy folder. It is from the deploy folder, the configuration is picked up
+ * using the axis2.xml file.
+ * In this sample client_home points to the Axis2/C default deploy folder. The client_home can
+ * be different from this folder on your system. For example, you may have a different folder
+ * (say, my_client_folder) with its own axis2.xml file. my_client_folder/modules will have the
+ * modules that the client uses
+ */
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home || !strcmp(client_home, ""))
+ client_home = "../..";
+
+ /* Create service client */
+ svc_client = axis2_svc_client_create(env, client_home);
+ if (!svc_client)
+ {
+ printf
+ ("Error creating service client, Please check AXIS2C_HOME again\n");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ return -1;
+ }
+
+ /* Set service client options */
+ axis2_svc_client_set_options(svc_client, env, options);
+
+ /* Engage addressing module */
+ axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);
+
+ /* Build the SOAP request message payload using OM API. */
+ payload = build_om_programatically(env);
+
+ /* Send request */
+ status = axis2_svc_client_send_robust(svc_client, env, payload);
+
+ if (status == AXIS2_SUCCESS)
+ {
+ printf("\nnotify client invoke SUCCESSFUL!\n");
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Stub invoke FAILED: Error code:" " %d :: %s",
+ env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(env->error));
+ printf("notify client invoke FAILED!\n");
+ }
+
+ if (svc_client)
+ {
+ axis2_svc_client_free(svc_client, env);
+ svc_client = NULL;
+ }
+
+ if (env)
+ {
+ axutil_env_free((axutil_env_t *) env);
+ env = NULL;
+ }
+
+ return 0;
+}
+
+/* build SOAP request message content using OM */
+axiom_node_t *
+build_om_programatically(
+ const axutil_env_t * env)
+{
+ axiom_node_t *notify_om_node = NULL;
+ axiom_element_t *notify_om_ele = NULL;
+ axiom_namespace_t *ns1 = NULL;
+ axis2_char_t *buffer = NULL;
+
+ ns1 = axiom_namespace_create(env, "http://example.org/notify", "m");
+ notify_om_ele =
+ axiom_element_create(env, NULL, "notify", ns1, &notify_om_node);
+ axiom_element_set_text(notify_om_ele, env, "notify5", notify_om_node);
+
+ buffer = axiom_node_to_string(notify_om_node, env);
+ if (buffer)
+ {
+ printf("\nSending OM node in XML : %s \n", buffer);
+ AXIS2_FREE(env->allocator, buffer);
+ }
+
+ return notify_om_node;
+}
diff --git a/src/core/deployment/conf_init.c b/src/core/deployment/conf_init.c
index 6a622b4..f9d8958 100644
--- a/src/core/deployment/conf_init.c
+++ b/src/core/deployment/conf_init.c
@@ -333,30 +333,30 @@ axis2_load_services(
{
continue;
}
- impl_class = axis2_svc_get_impl_class(svc, env);
- if(impl_class)
+ impl_class = axis2_svc_get_impl_class(svc, env);
+ if(impl_class)
continue;
- ops_hash = axis2_svc_get_all_ops(svc, env);
- if(ops_hash)
- {
- axutil_hash_index_t *op_hi = NULL;
- void *op = NULL;
- op_hi = axutil_hash_first(ops_hash, env);
- if(op_hi)
- {
- axutil_hash_this(op_hi, NULL, NULL, &op);
- if(op)
- {
- msg_recv = axis2_op_get_msg_recv(op, env);
- if(msg_recv)
- {
- axis2_msg_recv_set_conf_ctx(msg_recv, env, conf_ctx);
- axis2_msg_recv_load_and_init_svc(msg_recv, env, svc);
- }
- }
- }
-
+ ops_hash = axis2_svc_get_all_ops(svc, env);
+ if(ops_hash)
+ {
+ axutil_hash_index_t *op_hi = NULL;
+ void *op = NULL;
+ op_hi = axutil_hash_first(ops_hash, env);
+ if(op_hi)
+ {
+ axutil_hash_this(op_hi, NULL, NULL, &op);
+ if(op)
+ {
+ msg_recv = axis2_op_get_msg_recv(op, env);
+ if(msg_recv)
+ {
+ axis2_msg_recv_set_conf_ctx(msg_recv, env, conf_ctx);
+ axis2_msg_recv_load_and_init_svc(msg_recv, env, svc);
+ }
+ }
+ }
+
}
/*
svc_desc = (axis2_svc_t *)svc;
diff --git a/src/core/transport/amqp/receiver/axis2_amqp_receiver.c b/src/core/transport/amqp/receiver/axis2_amqp_receiver.c
index 5ff69af..3dd38c5 100644
--- a/src/core/transport/amqp/receiver/axis2_amqp_receiver.c
+++ b/src/core/transport/amqp/receiver/axis2_amqp_receiver.c
@@ -1,275 +1,275 @@
-/*
- * 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.
- */
-
-#include <axis2_amqp_util.h>
-#include <axis2_amqp_defines.h>
-#include <axis2_amqp_receiver.h>
-
-static const axis2_transport_receiver_ops_t amqp_receiver_ops =
-{
- axis2_amqp_receiver_init,
- axis2_amqp_receiver_start,
- axis2_amqp_receiver_get_reply_to_epr,
- axis2_amqp_receiver_get_conf_ctx,
- axis2_amqp_receiver_is_running,
- axis2_amqp_receiver_stop,
- axis2_amqp_receiver_free
-};
-
-AXIS2_EXTERN axis2_transport_receiver_t* AXIS2_CALL
-axis2_amqp_receiver_create(
- const axutil_env_t* env,
- const axis2_char_t* repo,
- const axis2_char_t* qpid_broker_ip,
- int qpid_broker_port)
-{
- AXIS2_ENV_CHECK(env, NULL);
-
- axis2_amqp_receiver_resource_pack_t* receiver_resource_pack = NULL;
-
- receiver_resource_pack = (axis2_amqp_receiver_resource_pack_t*)AXIS2_MALLOC(env->allocator,
- sizeof(axis2_amqp_receiver_resource_pack_t));
-
- if(!receiver_resource_pack)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- return NULL;
- }
-
- receiver_resource_pack->receiver.ops = &amqp_receiver_ops;
- receiver_resource_pack->qpid_receiver = NULL;
- receiver_resource_pack->conf_ctx = NULL;
- receiver_resource_pack->conf_ctx_private = NULL;
-
- if(repo)
- {
- /**
- * 1. We first create a private conf ctx which is owned by this server
- * we only free this private conf context. We should never free the
- * receiver_impl->conf_ctx because it may be owned by any other object which
- * may lead to double free.
- *
- * 2. The Qpid broker IP and port are set in conf_ctx at two different places.
- * If the repo is specified, they are set here. Otherwise, they are set
- * in axis2_amqp_receiver_init method.
- */
- axutil_property_t* property = NULL;
- const axis2_char_t* broker_ip = NULL;
- int* broker_port = (int*)AXIS2_MALLOC(env->allocator, sizeof(int));
- *broker_port = AXIS2_QPID_NULL_CONF_INT;
-
- receiver_resource_pack->conf_ctx_private = axis2_build_conf_ctx(env, repo);
- if(!receiver_resource_pack->conf_ctx_private)
- {
- axis2_amqp_receiver_free((axis2_transport_receiver_t *)receiver_resource_pack, env);
- return NULL;
- }
-
- /* Set broker IP */
- broker_ip = qpid_broker_ip ? qpid_broker_ip : AXIS2_QPID_DEFAULT_BROKER_IP;
- property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0,
- (void*)broker_ip);
- axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx_private, env,
- AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP, property);
-
- /* Set broker port */
- *broker_port = (qpid_broker_port != AXIS2_QPID_NULL_CONF_INT) ? qpid_broker_port
- : AXIS2_QPID_DEFAULT_BROKER_PORT;
- property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0,
- (void*)broker_port);
- axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx_private, env,
- AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT, property);
-
- receiver_resource_pack->conf_ctx = receiver_resource_pack->conf_ctx_private;
- }
-
- return &(receiver_resource_pack->receiver);
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_amqp_receiver_init(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env,
- axis2_conf_ctx_t* conf_ctx,
- axis2_transport_in_desc_t* in_desc)
-{
- axis2_amqp_receiver_resource_pack_t* receiver_resource_pack = NULL;
- axutil_property_t* property = NULL;
- const axis2_char_t* broker_ip = NULL;
- int* broker_port = (int*)AXIS2_MALLOC(env->allocator, sizeof(int));
- *broker_port = AXIS2_QPID_NULL_CONF_INT;
-
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
- receiver_resource_pack = AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(receiver);
- receiver_resource_pack->conf_ctx = conf_ctx;
-
- /* Set broker IP */
- broker_ip = axis2_amqp_util_get_in_desc_conf_value_string(in_desc, env,
- AXIS2_AMQP_CONF_QPID_BROKER_IP);
- if(!broker_ip)
- {
- broker_ip = AXIS2_QPID_DEFAULT_BROKER_IP;
- }
- property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0,
- (void*)broker_ip);
- axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx, env,
- AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP, property);
-
- /* Set broker port */
- *broker_port = axis2_amqp_util_get_in_desc_conf_value_int(in_desc, env,
- AXIS2_AMQP_CONF_QPID_BROKER_PORT);
- if(*broker_port == AXIS2_QPID_NULL_CONF_INT)
- {
- *broker_port = AXIS2_QPID_DEFAULT_BROKER_PORT;
- }
- property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0,
- (void*)broker_port);
- axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx, env,
- AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT, property);
-
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_amqp_receiver_start(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env)
-{
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
- axis2_status_t status = AXIS2_FAILURE;
-
- axis2_amqp_receiver_resource_pack_t* amqp_receiver_resource_pack = NULL;
- axis2_qpid_receiver_resource_pack_t* qpid_receiver_resource_pack = NULL;
-
- amqp_receiver_resource_pack = AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(receiver);
-
- /* Create Qpid Receiver */
- qpid_receiver_resource_pack = axis2_qpid_receiver_create(env,
- amqp_receiver_resource_pack->conf_ctx);
-
- if(qpid_receiver_resource_pack)
- {
- amqp_receiver_resource_pack->qpid_receiver = qpid_receiver_resource_pack;
-
- status = axis2_qpid_receiver_start(qpid_receiver_resource_pack, env);
- }
-
- return status;
-}
-
-AXIS2_EXTERN axis2_endpoint_ref_t* AXIS2_CALL
-axis2_amqp_receiver_get_reply_to_epr(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env,
- const axis2_char_t* svc_name)
-{
- return NULL;
-}
-
-AXIS2_EXTERN axis2_conf_ctx_t* AXIS2_CALL
-axis2_amqp_receiver_get_conf_ctx(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env)
-{
- AXIS2_ENV_CHECK(env, NULL);
-
- return AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(receiver)->conf_ctx;
-}
-
-AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-axis2_amqp_receiver_is_running(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env)
-{
- return AXIS2_TRUE;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_amqp_receiver_stop(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env)
-{
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN void AXIS2_CALL
-axis2_amqp_receiver_free(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env)
-{
- AXIS2_ENV_CHECK(env, void);
-
- axis2_amqp_receiver_resource_pack_t* receiver_resource_pack = NULL;
- receiver_resource_pack = AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(receiver);
-
- if(receiver_resource_pack->qpid_receiver)
- {
- axis2_qpid_receiver_free(receiver_resource_pack->qpid_receiver, env);
- receiver_resource_pack->qpid_receiver = NULL;
- }
-
- if(receiver_resource_pack->conf_ctx_private)
- {
- axis2_conf_ctx_free(receiver_resource_pack->conf_ctx_private, env);
- receiver_resource_pack->conf_ctx_private = NULL;
- }
-
- receiver_resource_pack->conf_ctx = NULL; /* Do not free this. It may be owned by some other object */
-
- AXIS2_FREE(env->allocator, receiver_resource_pack);
-}
-
-/* Library Exports */
-
-AXIS2_EXPORT int
-#ifndef AXIS2_STATIC_DEPLOY
-axis2_get_instance(
-#else
- axis2_amqp_receiver_get_instance(
-#endif
- struct axis2_transport_receiver** inst,
- const axutil_env_t* env)
-{
- int status = AXIS2_SUCCESS;
-
- *inst = axis2_amqp_receiver_create(env, NULL, NULL, AXIS2_QPID_NULL_CONF_INT);
- if(!(*inst))
- {
- status = AXIS2_FAILURE;
- }
-
- return status;
-}
-
-AXIS2_EXPORT int
-#ifndef AXIS2_STATIC_DEPLOY
-axis2_remove_instance(
-#else
- axis2_amqp_receiver_remove_instance(
-#endif
- axis2_transport_receiver_t* inst,
- const axutil_env_t* env)
-{
- if(inst)
- {
- axis2_transport_receiver_free(inst, env);
- }
-
- return AXIS2_SUCCESS;
-}
+/*
+ * 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.
+ */
+
+#include <axis2_amqp_util.h>
+#include <axis2_amqp_defines.h>
+#include <axis2_amqp_receiver.h>
+
+static const axis2_transport_receiver_ops_t amqp_receiver_ops =
+{
+ axis2_amqp_receiver_init,
+ axis2_amqp_receiver_start,
+ axis2_amqp_receiver_get_reply_to_epr,
+ axis2_amqp_receiver_get_conf_ctx,
+ axis2_amqp_receiver_is_running,
+ axis2_amqp_receiver_stop,
+ axis2_amqp_receiver_free
+};
+
+AXIS2_EXTERN axis2_transport_receiver_t* AXIS2_CALL
+axis2_amqp_receiver_create(
+ const axutil_env_t* env,
+ const axis2_char_t* repo,
+ const axis2_char_t* qpid_broker_ip,
+ int qpid_broker_port)
+{
+ AXIS2_ENV_CHECK(env, NULL);
+
+ axis2_amqp_receiver_resource_pack_t* receiver_resource_pack = NULL;
+
+ receiver_resource_pack = (axis2_amqp_receiver_resource_pack_t*)AXIS2_MALLOC(env->allocator,
+ sizeof(axis2_amqp_receiver_resource_pack_t));
+
+ if(!receiver_resource_pack)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ receiver_resource_pack->receiver.ops = &amqp_receiver_ops;
+ receiver_resource_pack->qpid_receiver = NULL;
+ receiver_resource_pack->conf_ctx = NULL;
+ receiver_resource_pack->conf_ctx_private = NULL;
+
+ if(repo)
+ {
+ /**
+ * 1. We first create a private conf ctx which is owned by this server
+ * we only free this private conf context. We should never free the
+ * receiver_impl->conf_ctx because it may be owned by any other object which
+ * may lead to double free.
+ *
+ * 2. The Qpid broker IP and port are set in conf_ctx at two different places.
+ * If the repo is specified, they are set here. Otherwise, they are set
+ * in axis2_amqp_receiver_init method.
+ */
+ axutil_property_t* property = NULL;
+ const axis2_char_t* broker_ip = NULL;
+ int* broker_port = (int*)AXIS2_MALLOC(env->allocator, sizeof(int));
+ *broker_port = AXIS2_QPID_NULL_CONF_INT;
+
+ receiver_resource_pack->conf_ctx_private = axis2_build_conf_ctx(env, repo);
+ if(!receiver_resource_pack->conf_ctx_private)
+ {
+ axis2_amqp_receiver_free((axis2_transport_receiver_t *)receiver_resource_pack, env);
+ return NULL;
+ }
+
+ /* Set broker IP */
+ broker_ip = qpid_broker_ip ? qpid_broker_ip : AXIS2_QPID_DEFAULT_BROKER_IP;
+ property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0,
+ (void*)broker_ip);
+ axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx_private, env,
+ AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP, property);
+
+ /* Set broker port */
+ *broker_port = (qpid_broker_port != AXIS2_QPID_NULL_CONF_INT) ? qpid_broker_port
+ : AXIS2_QPID_DEFAULT_BROKER_PORT;
+ property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0,
+ (void*)broker_port);
+ axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx_private, env,
+ AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT, property);
+
+ receiver_resource_pack->conf_ctx = receiver_resource_pack->conf_ctx_private;
+ }
+
+ return &(receiver_resource_pack->receiver);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_amqp_receiver_init(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env,
+ axis2_conf_ctx_t* conf_ctx,
+ axis2_transport_in_desc_t* in_desc)
+{
+ axis2_amqp_receiver_resource_pack_t* receiver_resource_pack = NULL;
+ axutil_property_t* property = NULL;
+ const axis2_char_t* broker_ip = NULL;
+ int* broker_port = (int*)AXIS2_MALLOC(env->allocator, sizeof(int));
+ *broker_port = AXIS2_QPID_NULL_CONF_INT;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ receiver_resource_pack = AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(receiver);
+ receiver_resource_pack->conf_ctx = conf_ctx;
+
+ /* Set broker IP */
+ broker_ip = axis2_amqp_util_get_in_desc_conf_value_string(in_desc, env,
+ AXIS2_AMQP_CONF_QPID_BROKER_IP);
+ if(!broker_ip)
+ {
+ broker_ip = AXIS2_QPID_DEFAULT_BROKER_IP;
+ }
+ property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0,
+ (void*)broker_ip);
+ axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx, env,
+ AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP, property);
+
+ /* Set broker port */
+ *broker_port = axis2_amqp_util_get_in_desc_conf_value_int(in_desc, env,
+ AXIS2_AMQP_CONF_QPID_BROKER_PORT);
+ if(*broker_port == AXIS2_QPID_NULL_CONF_INT)
+ {
+ *broker_port = AXIS2_QPID_DEFAULT_BROKER_PORT;
+ }
+ property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0,
+ (void*)broker_port);
+ axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx, env,
+ AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT, property);
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_amqp_receiver_start(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ axis2_status_t status = AXIS2_FAILURE;
+
+ axis2_amqp_receiver_resource_pack_t* amqp_receiver_resource_pack = NULL;
+ axis2_qpid_receiver_resource_pack_t* qpid_receiver_resource_pack = NULL;
+
+ amqp_receiver_resource_pack = AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(receiver);
+
+ /* Create Qpid Receiver */
+ qpid_receiver_resource_pack = axis2_qpid_receiver_create(env,
+ amqp_receiver_resource_pack->conf_ctx);
+
+ if(qpid_receiver_resource_pack)
+ {
+ amqp_receiver_resource_pack->qpid_receiver = qpid_receiver_resource_pack;
+
+ status = axis2_qpid_receiver_start(qpid_receiver_resource_pack, env);
+ }
+
+ return status;
+}
+
+AXIS2_EXTERN axis2_endpoint_ref_t* AXIS2_CALL
+axis2_amqp_receiver_get_reply_to_epr(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env,
+ const axis2_char_t* svc_name)
+{
+ return NULL;
+}
+
+AXIS2_EXTERN axis2_conf_ctx_t* AXIS2_CALL
+axis2_amqp_receiver_get_conf_ctx(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env)
+{
+ AXIS2_ENV_CHECK(env, NULL);
+
+ return AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(receiver)->conf_ctx;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_amqp_receiver_is_running(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env)
+{
+ return AXIS2_TRUE;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_amqp_receiver_stop(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env)
+{
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_amqp_receiver_free(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env)
+{
+ AXIS2_ENV_CHECK(env, void);
+
+ axis2_amqp_receiver_resource_pack_t* receiver_resource_pack = NULL;
+ receiver_resource_pack = AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(receiver);
+
+ if(receiver_resource_pack->qpid_receiver)
+ {
+ axis2_qpid_receiver_free(receiver_resource_pack->qpid_receiver, env);
+ receiver_resource_pack->qpid_receiver = NULL;
+ }
+
+ if(receiver_resource_pack->conf_ctx_private)
+ {
+ axis2_conf_ctx_free(receiver_resource_pack->conf_ctx_private, env);
+ receiver_resource_pack->conf_ctx_private = NULL;
+ }
+
+ receiver_resource_pack->conf_ctx = NULL; /* Do not free this. It may be owned by some other object */
+
+ AXIS2_FREE(env->allocator, receiver_resource_pack);
+}
+
+/* Library Exports */
+
+AXIS2_EXPORT int
+#ifndef AXIS2_STATIC_DEPLOY
+axis2_get_instance(
+#else
+ axis2_amqp_receiver_get_instance(
+#endif
+ struct axis2_transport_receiver** inst,
+ const axutil_env_t* env)
+{
+ int status = AXIS2_SUCCESS;
+
+ *inst = axis2_amqp_receiver_create(env, NULL, NULL, AXIS2_QPID_NULL_CONF_INT);
+ if(!(*inst))
+ {
+ status = AXIS2_FAILURE;
+ }
+
+ return status;
+}
+
+AXIS2_EXPORT int
+#ifndef AXIS2_STATIC_DEPLOY
+axis2_remove_instance(
+#else
+ axis2_amqp_receiver_remove_instance(
+#endif
+ axis2_transport_receiver_t* inst,
+ const axutil_env_t* env)
+{
+ if(inst)
+ {
+ axis2_transport_receiver_free(inst, env);
+ }
+
+ return AXIS2_SUCCESS;
+}
diff --git a/src/core/transport/amqp/receiver/axis2_amqp_receiver.h b/src/core/transport/amqp/receiver/axis2_amqp_receiver.h
index 209e2bb..5527ad8 100644
--- a/src/core/transport/amqp/receiver/axis2_amqp_receiver.h
+++ b/src/core/transport/amqp/receiver/axis2_amqp_receiver.h
@@ -1,82 +1,82 @@
-/*
-* 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 AXIS2_AMQP_RECEIVER_H
-#define AXIS2_AMQP_RECEIVER_H
-
-#include <axis2_transport_receiver.h>
-#include <axis2_conf_init.h>
-#include <axis2_qpid_receiver_interface.h>
-
-typedef struct axis2_amqp_receiver_resource_pack
-{
- axis2_transport_receiver_t receiver;
- axis2_qpid_receiver_resource_pack_t* qpid_receiver;
- axis2_conf_ctx_t* conf_ctx;
- axis2_conf_ctx_t* conf_ctx_private;
-}
-axis2_amqp_receiver_resource_pack_t;
-
-#define AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(amqp_receiver) \
- ((axis2_amqp_receiver_resource_pack_t*)(amqp_receiver))
-
-AXIS2_EXTERN axis2_transport_receiver_t* AXIS2_CALL
-axis2_amqp_receiver_create(
- const axutil_env_t* env,
- const axis2_char_t* repo,
- const axis2_char_t* qpid_broker_ip,
- int qpid_broker_port);
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_amqp_receiver_init(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env,
- axis2_conf_ctx_t* conf_ctx,
- axis2_transport_in_desc_t* in_desc);
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_amqp_receiver_start(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env);
-
-AXIS2_EXTERN axis2_endpoint_ref_t* AXIS2_CALL
-axis2_amqp_receiver_get_reply_to_epr(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env,
- const axis2_char_t* svc_name);
-
-AXIS2_EXTERN axis2_conf_ctx_t* AXIS2_CALL
-axis2_amqp_receiver_get_conf_ctx(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env);
-
-AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-axis2_amqp_receiver_is_running(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env);
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_amqp_receiver_stop(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env);
-
-AXIS2_EXTERN void AXIS2_CALL
-axis2_amqp_receiver_free(
- axis2_transport_receiver_t* receiver,
- const axutil_env_t* env);
-
-#endif
+/*
+* 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 AXIS2_AMQP_RECEIVER_H
+#define AXIS2_AMQP_RECEIVER_H
+
+#include <axis2_transport_receiver.h>
+#include <axis2_conf_init.h>
+#include <axis2_qpid_receiver_interface.h>
+
+typedef struct axis2_amqp_receiver_resource_pack
+{
+ axis2_transport_receiver_t receiver;
+ axis2_qpid_receiver_resource_pack_t* qpid_receiver;
+ axis2_conf_ctx_t* conf_ctx;
+ axis2_conf_ctx_t* conf_ctx_private;
+}
+axis2_amqp_receiver_resource_pack_t;
+
+#define AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(amqp_receiver) \
+ ((axis2_amqp_receiver_resource_pack_t*)(amqp_receiver))
+
+AXIS2_EXTERN axis2_transport_receiver_t* AXIS2_CALL
+axis2_amqp_receiver_create(
+ const axutil_env_t* env,
+ const axis2_char_t* repo,
+ const axis2_char_t* qpid_broker_ip,
+ int qpid_broker_port);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_amqp_receiver_init(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env,
+ axis2_conf_ctx_t* conf_ctx,
+ axis2_transport_in_desc_t* in_desc);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_amqp_receiver_start(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env);
+
+AXIS2_EXTERN axis2_endpoint_ref_t* AXIS2_CALL
+axis2_amqp_receiver_get_reply_to_epr(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env,
+ const axis2_char_t* svc_name);
+
+AXIS2_EXTERN axis2_conf_ctx_t* AXIS2_CALL
+axis2_amqp_receiver_get_conf_ctx(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env);
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_amqp_receiver_is_running(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_amqp_receiver_stop(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env);
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_amqp_receiver_free(
+ axis2_transport_receiver_t* receiver,
+ const axutil_env_t* env);
+
+#endif
diff --git a/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver.h b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver.h
index 66108d5..3fe9b44 100644
--- a/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver.h
+++ b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver.h
@@ -1,39 +1,39 @@
-/*
- * 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
- *
- * tcp://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 AXIS2_QPID_RECEIVER_H
-#define AXIS2_QPID_RECEIVER_H
-
-#include <axutil_env.h>
-#include <axis2_conf_init.h>
-
-class Axis2QpidReceiver
-{
- public:
- Axis2QpidReceiver(const axutil_env_t* env,
- axis2_conf_ctx_t* conf_ctx);
- ~Axis2QpidReceiver(void);
-
- bool start(void);
- bool shutdown(void);
-
- private:
- const axutil_env_t* env;
- axis2_conf_ctx_t* conf_ctx;
-};
-
-#endif
+/*
+ * 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
+ *
+ * tcp://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 AXIS2_QPID_RECEIVER_H
+#define AXIS2_QPID_RECEIVER_H
+
+#include <axutil_env.h>
+#include <axis2_conf_init.h>
+
+class Axis2QpidReceiver
+{
+ public:
+ Axis2QpidReceiver(const axutil_env_t* env,
+ axis2_conf_ctx_t* conf_ctx);
+ ~Axis2QpidReceiver(void);
+
+ bool start(void);
+ bool shutdown(void);
+
+ private:
+ const axutil_env_t* env;
+ axis2_conf_ctx_t* conf_ctx;
+};
+
+#endif
diff --git a/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_interface.h b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_interface.h
index d141dfc..5aa6471 100644
--- a/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_interface.h
+++ b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_interface.h
@@ -1,58 +1,58 @@
-/*
-* 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 AXIS2_QPID_RECEIVER_INTERFACE_H
-#define AXIS2_QPID_RECEIVER_INTERFACE_H
-
-#include <axis2_util.h>
-#include <axis2_conf_init.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- typedef struct axis2_qpid_receiver_resource_pack
- {
- void* qpid_receiver;
- }axis2_qpid_receiver_resource_pack_t;
-
- AXIS2_EXTERN axis2_qpid_receiver_resource_pack_t* AXIS2_CALL
- axis2_qpid_receiver_create(
- const axutil_env_t* env,
- axis2_conf_ctx_t* conf_ctx);
-
- AXIS2_EXTERN axis2_status_t AXIS2_CALL
- axis2_qpid_receiver_start(
- axis2_qpid_receiver_resource_pack_t* receiver_resource_pack,
- const axutil_env_t* env);
-
- AXIS2_EXTERN axis2_bool_t AXIS2_CALL
- axis2_qpid_receiver_is_running(
- axis2_qpid_receiver_resource_pack_t* receiver_resource_pack,
- const axutil_env_t* env);
-
- AXIS2_EXTERN void AXIS2_CALL
- axis2_qpid_receiver_free(
- axis2_qpid_receiver_resource_pack_t* receiver_resource_pack,
- const axutil_env_t* env);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+/*
+* 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 AXIS2_QPID_RECEIVER_INTERFACE_H
+#define AXIS2_QPID_RECEIVER_INTERFACE_H
+
+#include <axis2_util.h>
+#include <axis2_conf_init.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct axis2_qpid_receiver_resource_pack
+ {
+ void* qpid_receiver;
+ }axis2_qpid_receiver_resource_pack_t;
+
+ AXIS2_EXTERN axis2_qpid_receiver_resource_pack_t* AXIS2_CALL
+ axis2_qpid_receiver_create(
+ const axutil_env_t* env,
+ axis2_conf_ctx_t* conf_ctx);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axis2_qpid_receiver_start(
+ axis2_qpid_receiver_resource_pack_t* receiver_resource_pack,
+ const axutil_env_t* env);
+
+ AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+ axis2_qpid_receiver_is_running(
+ axis2_qpid_receiver_resource_pack_t* receiver_resource_pack,
+ const axutil_env_t* env);
+
+ AXIS2_EXTERN void AXIS2_CALL
+ axis2_qpid_receiver_free(
+ axis2_qpid_receiver_resource_pack_t* receiver_resource_pack,
+ const axutil_env_t* env);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_listener.h b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_listener.h
index d5923db..5d3f615 100644
--- a/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_listener.h
+++ b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_listener.h
@@ -1,43 +1,43 @@
-/*
- * 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
- *
- * tcp://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 AXIS2_QPID_RECEIVER_LISTENER_H
-#define AXIS2_QPID_RECEIVER_LISTENER_H
-
-#include <qpid/client/MessageListener.h>
-#include <qpid/client/Message.h>
-#include <axutil_env.h>
-#include <axis2_conf_init.h>
-
-using namespace qpid::client;
-using namespace qpid::framing;
-
-class Axis2QpidReceiverListener : public MessageListener
-{
- public:
- Axis2QpidReceiverListener(const axutil_env_t* env,
- axis2_conf_ctx_t* conf_ctx);
- ~Axis2QpidReceiverListener(void);
-
- private:
- virtual void received(Message& message);
-
- const axutil_env_t* env;
- axis2_conf_ctx_t* conf_ctx;
-};
-
-#endif
+/*
+ * 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
+ *
+ * tcp://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 AXIS2_QPID_RECEIVER_LISTENER_H
+#define AXIS2_QPID_RECEIVER_LISTENER_H
+
+#include <qpid/client/MessageListener.h>
+#include <qpid/client/Message.h>
+#include <axutil_env.h>
+#include <axis2_conf_init.h>
+
+using namespace qpid::client;
+using namespace qpid::framing;
+
+class Axis2QpidReceiverListener : public MessageListener
+{
+ public:
+ Axis2QpidReceiverListener(const axutil_env_t* env,
+ axis2_conf_ctx_t* conf_ctx);
+ ~Axis2QpidReceiverListener(void);
+
+ private:
+ virtual void received(Message& message);
+
+ const axutil_env_t* env;
+ axis2_conf_ctx_t* conf_ctx;
+};
+
+#endif
diff --git a/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.c b/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.c
index 0e0c9f8..a748a8f 100644
--- a/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.c
+++ b/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.c
@@ -1,334 +1,334 @@
-/*
- * 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.
- */
-
-#include <signal.h>
-#include <axiom.h>
-#include <axiom_soap.h>
-#include <axis2_engine.h>
-#include <axiom_mime_parser.h>
-#include <axutil_http_chunked_stream.h>
-#include <axis2_amqp_defines.h>
-#include <axis2_amqp_util.h>
-#include <axis2_amqp_request_processor.h>
-
-void* AXIS2_THREAD_FUNC
-axis2_amqp_request_processor_thread_function(
- axutil_thread_t* thread,
- void* request_data)
-{
- axis2_status_t status = AXIS2_FAILURE;
- axutil_env_t* env = NULL;
- axutil_env_t* thread_env = NULL;
- axis2_amqp_request_processor_resource_pack_t* request_resource_pack = NULL;
-
-#ifndef WIN32
-#ifdef AXIS2_SVR_MULTI_THREADED
- signal(SIGPIPE, SIG_IGN);
-#endif
-#endif
-
- request_resource_pack = (axis2_amqp_request_processor_resource_pack_t*)request_data;
-
- env = request_resource_pack->env;
- thread_env = axutil_init_thread_env(env);
-
- /* Process Request */
- status = axis2_amqp_process_request(thread_env, request_resource_pack);
-
- if(status == AXIS2_SUCCESS)
- {
- AXIS2_LOG_INFO(thread_env->log, "Request Processed Successfully");
- }
- else
- {
- AXIS2_LOG_WARNING(thread_env->log, AXIS2_LOG_SI, "Error while Processing Request");
- }
-
- AXIS2_FREE(thread_env->allocator, request_resource_pack->request_content);
- AXIS2_FREE(thread_env->allocator, request_resource_pack->reply_to);
- AXIS2_FREE(thread_env->allocator, request_resource_pack->content_type);
- AXIS2_FREE(thread_env->allocator, request_resource_pack->soap_action);
-
- AXIS2_FREE(thread_env->allocator, request_resource_pack);
-
- if(thread_env)
- {
- thread_env = NULL;
- }
-
-#ifdef AXIS2_SVR_MULTI_THREADED
- axutil_thread_pool_exit_thread(env->thread_pool, thread);
-#endif
-
- return NULL;
-}
-
-axis2_status_t
-axis2_amqp_process_request(
- const axutil_env_t* env,
- axis2_amqp_request_processor_resource_pack_t* request_resource_pack)
-{
- axiom_xml_reader_t* xml_reader = NULL;
- axiom_stax_builder_t* stax_builder = NULL;
- axiom_soap_builder_t* soap_builder = NULL;
- axis2_transport_out_desc_t* out_desc = NULL;
- axis2_transport_in_desc_t* in_desc = NULL;
- axis2_msg_ctx_t* msg_ctx = NULL;
- axiom_soap_envelope_t* soap_envelope = NULL;
- axis2_engine_t* engine = NULL;
- const axis2_char_t* soap_ns_uri = NULL;
- axis2_bool_t is_soap_11 = AXIS2_FALSE;
- axis2_char_t *soap_body_str = NULL;
- int soap_body_len = 0;
- axis2_bool_t is_mtom = AXIS2_FALSE;
- axis2_status_t status = AXIS2_FAILURE;
- axutil_hash_t *binary_data_map = NULL;
- axiom_soap_body_t *soap_body = NULL;
- axutil_property_t* reply_to_property = NULL;
-
- /* Create msg_ctx */
- if(!request_resource_pack->conf_ctx)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Conf Context not Available");
- return AXIS2_FAILURE;
- }
-
- out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(
- request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP);
- if(!out_desc)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport Out Descriptor not Found");
- return AXIS2_FAILURE;
- }
-
- in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(request_resource_pack->conf_ctx,
- env), env, AXIS2_TRANSPORT_ENUM_AMQP);
- if(!in_desc)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport In Descriptor not Found");
- return AXIS2_FAILURE;
- }
-
- /* Create msg_ctx */
- msg_ctx = axis2_msg_ctx_create(env, request_resource_pack->conf_ctx, in_desc, out_desc);
-
- axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);
-
- /* Handle MTOM */
- if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED))
- {
- axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env,
- request_resource_pack->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY);
-
- if(mime_boundary)
- {
- axiom_mime_parser_t *mime_parser = NULL;
- int soap_body_len = 0;
- axutil_param_t *buffer_size_param = NULL;
- axutil_param_t *max_buffers_param = NULL;
- axutil_param_t *attachment_dir_param = NULL;
- axis2_char_t *value_size = NULL;
- axis2_char_t *value_num = NULL;
- axis2_char_t *value_dir = NULL;
- int size = 0;
- int num = 0;
-
- mime_parser = axiom_mime_parser_create(env);
-
- buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE);
- if(buffer_size_param)
- {
- value_size = (axis2_char_t*)axutil_param_get_value(buffer_size_param, env);
- if(value_size)
- {
- size = atoi(value_size);
- axiom_mime_parser_set_buffer_size(mime_parser, env, size);
- }
- }
-
- max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS);
- if(max_buffers_param)
- {
- value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env);
- if(value_num)
- {
- num = atoi(value_num);
- axiom_mime_parser_set_max_buffers(mime_parser, env, num);
- }
- }
-
- /* If this paramter is there mime_parser will cached the attachment
- * using to the directory for large attachments. */
- attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR);
- if(attachment_dir_param)
- {
- value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env);
- if(value_dir)
- {
- axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir);
- }
- }
-
- if(mime_parser)
- {
- axis2_callback_info_t *callback_ctx = NULL;
- axutil_stream_t *stream = NULL;
-
- callback_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_callback_info_t));
-
- stream = axutil_stream_create_basic(env);
- if(stream)
- {
- axutil_stream_write(stream, env, request_resource_pack->request_content,
- request_resource_pack->content_length);
- callback_ctx->env = env;
- callback_ctx->in_stream = stream;
- callback_ctx->content_length = request_resource_pack->content_length;
- callback_ctx->unread_len = request_resource_pack->content_length;
- callback_ctx->chunked_stream = NULL;
- }
-
- /*binary_data_map =
- axiom_mime_parser_parse(mime_parser, env,
- axis2_amqp_util_on_data_request,
- (void*)callback_ctx,
- mime_boundary);*/
- if(!binary_data_map)
- {
- return AXIS2_FAILURE;
- }
-
- soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env);
- soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env);
-
- axutil_stream_free(stream, env);
- AXIS2_FREE(env->allocator, callback_ctx);
- axiom_mime_parser_free(mime_parser, env);
- }
-
- AXIS2_FREE(env->allocator, mime_boundary);
- }
-
- is_mtom = AXIS2_TRUE;
- }
- else
- {
- soap_body_str = request_resource_pack->request_content;
- soap_body_len = request_resource_pack->content_length;
- }
-
- soap_body_len = axutil_strlen(soap_body_str);
-
- xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL,
- AXIS2_XML_PARSER_TYPE_BUFFER);
- if(!xml_reader)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader");
- return AXIS2_FAILURE;
- }
-
- stax_builder = axiom_stax_builder_create(env, xml_reader);
- if(!stax_builder)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder");
- return AXIS2_FAILURE;
- }
-
- soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
-
- if(request_resource_pack->content_type)
- {
- if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML))
- {
- is_soap_11 = AXIS2_TRUE;
- soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI;
- }
- /*if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP))
- {
- is_soap_11 = AXIS2_FALSE;
- soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
- }
- else if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML))
- {
- is_soap_11 = AXIS2_TRUE;
- soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI;
- }*/
- }
-
- soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri);
- if(!soap_builder)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder");
- return AXIS2_FAILURE;
- }
-
- if(binary_data_map)
- {
- axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map);
- }
-
- soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env);
- axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope);
-
- soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
-
- if(!soap_body)
- {
- return AXIS2_FAILURE;
- }
-
- /* SOAPAction */
- if(request_resource_pack->soap_action)
- {
- axis2_msg_ctx_set_soap_action(msg_ctx, env, axutil_string_create(env,
- request_resource_pack->soap_action));
- }
-
- /* SOAP version */
- axis2_msg_ctx_set_is_soap_11(msg_ctx, env, is_soap_11);
-
- /* Set ReplyTo in the msg_ctx as a property. This is used by the server when
- * 1. WS-A is not in use
- * 2. ReplyTo is an anonymous EPR - Sandesha2/Dual-channel */
- reply_to_property = axutil_property_create_with_args(env, AXIS2_SCOPE_REQUEST, 0, 0,
- (void*)request_resource_pack->reply_to);
- axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO,
- reply_to_property);
-
- engine = axis2_engine_create(env, request_resource_pack->conf_ctx);
-
- if(AXIS2_TRUE == axiom_soap_body_has_fault(soap_body, env))
- {
- status = axis2_engine_receive_fault(engine, env, msg_ctx);
- }
- else
- {
- status = axis2_engine_receive(engine, env, msg_ctx);
- }
-
- if(engine)
- {
- axis2_engine_free(engine, env);
- }
-
- if(soap_body_str && is_mtom)
- {
- AXIS2_FREE(env->allocator, soap_body_str);
- }
-
- return status;
-}
+/*
+ * 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.
+ */
+
+#include <signal.h>
+#include <axiom.h>
+#include <axiom_soap.h>
+#include <axis2_engine.h>
+#include <axiom_mime_parser.h>
+#include <axutil_http_chunked_stream.h>
+#include <axis2_amqp_defines.h>
+#include <axis2_amqp_util.h>
+#include <axis2_amqp_request_processor.h>
+
+void* AXIS2_THREAD_FUNC
+axis2_amqp_request_processor_thread_function(
+ axutil_thread_t* thread,
+ void* request_data)
+{
+ axis2_status_t status = AXIS2_FAILURE;
+ axutil_env_t* env = NULL;
+ axutil_env_t* thread_env = NULL;
+ axis2_amqp_request_processor_resource_pack_t* request_resource_pack = NULL;
+
+#ifndef WIN32
+#ifdef AXIS2_SVR_MULTI_THREADED
+ signal(SIGPIPE, SIG_IGN);
+#endif
+#endif
+
+ request_resource_pack = (axis2_amqp_request_processor_resource_pack_t*)request_data;
+
+ env = request_resource_pack->env;
+ thread_env = axutil_init_thread_env(env);
+
+ /* Process Request */
+ status = axis2_amqp_process_request(thread_env, request_resource_pack);
+
+ if(status == AXIS2_SUCCESS)
+ {
+ AXIS2_LOG_INFO(thread_env->log, "Request Processed Successfully");
+ }
+ else
+ {
+ AXIS2_LOG_WARNING(thread_env->log, AXIS2_LOG_SI, "Error while Processing Request");
+ }
+
+ AXIS2_FREE(thread_env->allocator, request_resource_pack->request_content);
+ AXIS2_FREE(thread_env->allocator, request_resource_pack->reply_to);
+ AXIS2_FREE(thread_env->allocator, request_resource_pack->content_type);
+ AXIS2_FREE(thread_env->allocator, request_resource_pack->soap_action);
+
+ AXIS2_FREE(thread_env->allocator, request_resource_pack);
+
+ if(thread_env)
+ {
+ thread_env = NULL;
+ }
+
+#ifdef AXIS2_SVR_MULTI_THREADED
+ axutil_thread_pool_exit_thread(env->thread_pool, thread);
+#endif
+
+ return NULL;
+}
+
+axis2_status_t
+axis2_amqp_process_request(
+ const axutil_env_t* env,
+ axis2_amqp_request_processor_resource_pack_t* request_resource_pack)
+{
+ axiom_xml_reader_t* xml_reader = NULL;
+ axiom_stax_builder_t* stax_builder = NULL;
+ axiom_soap_builder_t* soap_builder = NULL;
+ axis2_transport_out_desc_t* out_desc = NULL;
+ axis2_transport_in_desc_t* in_desc = NULL;
+ axis2_msg_ctx_t* msg_ctx = NULL;
+ axiom_soap_envelope_t* soap_envelope = NULL;
+ axis2_engine_t* engine = NULL;
+ const axis2_char_t* soap_ns_uri = NULL;
+ axis2_bool_t is_soap_11 = AXIS2_FALSE;
+ axis2_char_t *soap_body_str = NULL;
+ int soap_body_len = 0;
+ axis2_bool_t is_mtom = AXIS2_FALSE;
+ axis2_status_t status = AXIS2_FAILURE;
+ axutil_hash_t *binary_data_map = NULL;
+ axiom_soap_body_t *soap_body = NULL;
+ axutil_property_t* reply_to_property = NULL;
+
+ /* Create msg_ctx */
+ if(!request_resource_pack->conf_ctx)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Conf Context not Available");
+ return AXIS2_FAILURE;
+ }
+
+ out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(
+ request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP);
+ if(!out_desc)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport Out Descriptor not Found");
+ return AXIS2_FAILURE;
+ }
+
+ in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(request_resource_pack->conf_ctx,
+ env), env, AXIS2_TRANSPORT_ENUM_AMQP);
+ if(!in_desc)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport In Descriptor not Found");
+ return AXIS2_FAILURE;
+ }
+
+ /* Create msg_ctx */
+ msg_ctx = axis2_msg_ctx_create(env, request_resource_pack->conf_ctx, in_desc, out_desc);
+
+ axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);
+
+ /* Handle MTOM */
+ if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED))
+ {
+ axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env,
+ request_resource_pack->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY);
+
+ if(mime_boundary)
+ {
+ axiom_mime_parser_t *mime_parser = NULL;
+ int soap_body_len = 0;
+ axutil_param_t *buffer_size_param = NULL;
+ axutil_param_t *max_buffers_param = NULL;
+ axutil_param_t *attachment_dir_param = NULL;
+ axis2_char_t *value_size = NULL;
+ axis2_char_t *value_num = NULL;
+ axis2_char_t *value_dir = NULL;
+ int size = 0;
+ int num = 0;
+
+ mime_parser = axiom_mime_parser_create(env);
+
+ buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE);
+ if(buffer_size_param)
+ {
+ value_size = (axis2_char_t*)axutil_param_get_value(buffer_size_param, env);
+ if(value_size)
+ {
+ size = atoi(value_size);
+ axiom_mime_parser_set_buffer_size(mime_parser, env, size);
+ }
+ }
+
+ max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS);
+ if(max_buffers_param)
+ {
+ value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env);
+ if(value_num)
+ {
+ num = atoi(value_num);
+ axiom_mime_parser_set_max_buffers(mime_parser, env, num);
+ }
+ }
+
+ /* If this paramter is there mime_parser will cached the attachment
+ * using to the directory for large attachments. */
+ attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR);
+ if(attachment_dir_param)
+ {
+ value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env);
+ if(value_dir)
+ {
+ axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir);
+ }
+ }
+
+ if(mime_parser)
+ {
+ axis2_callback_info_t *callback_ctx = NULL;
+ axutil_stream_t *stream = NULL;
+
+ callback_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_callback_info_t));
+
+ stream = axutil_stream_create_basic(env);
+ if(stream)
+ {
+ axutil_stream_write(stream, env, request_resource_pack->request_content,
+ request_resource_pack->content_length);
+ callback_ctx->env = env;
+ callback_ctx->in_stream = stream;
+ callback_ctx->content_length = request_resource_pack->content_length;
+ callback_ctx->unread_len = request_resource_pack->content_length;
+ callback_ctx->chunked_stream = NULL;
+ }
+
+ /*binary_data_map =
+ axiom_mime_parser_parse(mime_parser, env,
+ axis2_amqp_util_on_data_request,
+ (void*)callback_ctx,
+ mime_boundary);*/
+ if(!binary_data_map)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env);
+ soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env);
+
+ axutil_stream_free(stream, env);
+ AXIS2_FREE(env->allocator, callback_ctx);
+ axiom_mime_parser_free(mime_parser, env);
+ }
+
+ AXIS2_FREE(env->allocator, mime_boundary);
+ }
+
+ is_mtom = AXIS2_TRUE;
+ }
+ else
+ {
+ soap_body_str = request_resource_pack->request_content;
+ soap_body_len = request_resource_pack->content_length;
+ }
+
+ soap_body_len = axutil_strlen(soap_body_str);
+
+ xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL,
+ AXIS2_XML_PARSER_TYPE_BUFFER);
+ if(!xml_reader)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader");
+ return AXIS2_FAILURE;
+ }
+
+ stax_builder = axiom_stax_builder_create(env, xml_reader);
+ if(!stax_builder)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder");
+ return AXIS2_FAILURE;
+ }
+
+ soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
+
+ if(request_resource_pack->content_type)
+ {
+ if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML))
+ {
+ is_soap_11 = AXIS2_TRUE;
+ soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI;
+ }
+ /*if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP))
+ {
+ is_soap_11 = AXIS2_FALSE;
+ soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
+ }
+ else if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML))
+ {
+ is_soap_11 = AXIS2_TRUE;
+ soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI;
+ }*/
+ }
+
+ soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri);
+ if(!soap_builder)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder");
+ return AXIS2_FAILURE;
+ }
+
+ if(binary_data_map)
+ {
+ axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map);
+ }
+
+ soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env);
+ axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope);
+
+ soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
+
+ if(!soap_body)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ /* SOAPAction */
+ if(request_resource_pack->soap_action)
+ {
+ axis2_msg_ctx_set_soap_action(msg_ctx, env, axutil_string_create(env,
+ request_resource_pack->soap_action));
+ }
+
+ /* SOAP version */
+ axis2_msg_ctx_set_is_soap_11(msg_ctx, env, is_soap_11);
+
+ /* Set ReplyTo in the msg_ctx as a property. This is used by the server when
+ * 1. WS-A is not in use
+ * 2. ReplyTo is an anonymous EPR - Sandesha2/Dual-channel */
+ reply_to_property = axutil_property_create_with_args(env, AXIS2_SCOPE_REQUEST, 0, 0,
+ (void*)request_resource_pack->reply_to);
+ axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO,
+ reply_to_property);
+
+ engine = axis2_engine_create(env, request_resource_pack->conf_ctx);
+
+ if(AXIS2_TRUE == axiom_soap_body_has_fault(soap_body, env))
+ {
+ status = axis2_engine_receive_fault(engine, env, msg_ctx);
+ }
+ else
+ {
+ status = axis2_engine_receive(engine, env, msg_ctx);
+ }
+
+ if(engine)
+ {
+ axis2_engine_free(engine, env);
+ }
+
+ if(soap_body_str && is_mtom)
+ {
+ AXIS2_FREE(env->allocator, soap_body_str);
+ }
+
+ return status;
+}
diff --git a/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.h b/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.h
index 97f13b2..1b92e45 100644
--- a/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.h
+++ b/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.h
@@ -1,55 +1,55 @@
-/*
- * 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 AXIS2_AMQP_REQUEST_PROCESSOR_H
-#define AXIS2_AMQP_REQUEST_PROCESSOR_H
-
-#include <axutil_env.h>
-#include <axis2_conf_init.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- typedef struct axis2_amqp_request_processor_resource_pack
- {
- axutil_env_t* env;
- axis2_conf_ctx_t* conf_ctx;
- axis2_char_t* request_content;
- int content_length;
- axis2_char_t* reply_to;
- axis2_char_t* content_type;
- axis2_char_t* soap_action;
- } axis2_amqp_request_processor_resource_pack_t;
-
- /* The worker thread function */
- void* AXIS2_THREAD_FUNC
- axis2_amqp_request_processor_thread_function(
- axutil_thread_t* thread,
- void* request_data);
-
- axis2_status_t
- axis2_amqp_process_request(
- const axutil_env_t* env,
- axis2_amqp_request_processor_resource_pack_t* request_resource_pack);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+/*
+ * 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 AXIS2_AMQP_REQUEST_PROCESSOR_H
+#define AXIS2_AMQP_REQUEST_PROCESSOR_H
+
+#include <axutil_env.h>
+#include <axis2_conf_init.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct axis2_amqp_request_processor_resource_pack
+ {
+ axutil_env_t* env;
+ axis2_conf_ctx_t* conf_ctx;
+ axis2_char_t* request_content;
+ int content_length;
+ axis2_char_t* reply_to;
+ axis2_char_t* content_type;
+ axis2_char_t* soap_action;
+ } axis2_amqp_request_processor_resource_pack_t;
+
+ /* The worker thread function */
+ void* AXIS2_THREAD_FUNC
+ axis2_amqp_request_processor_thread_function(
+ axutil_thread_t* thread,
+ void* request_data);
+
+ axis2_status_t
+ axis2_amqp_process_request(
+ const axutil_env_t* env,
+ axis2_amqp_request_processor_resource_pack_t* request_resource_pack);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/core/transport/amqp/sender/axis2_amqp_sender.c b/src/core/transport/amqp/sender/axis2_amqp_sender.c
index aae5496..c50a3db 100644
--- a/src/core/transport/amqp/sender/axis2_amqp_sender.c
+++ b/src/core/transport/amqp/sender/axis2_amqp_sender.c
@@ -1,344 +1,344 @@
-/*
- * 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.
- */
-
-#include <axiom_soap.h>
-#include <axis2_transport_in_desc.h>
-#include <axis2_amqp_defines.h>
-#include <axis2_amqp_util.h>
-#include <axis2_amqp_receiver.h>
-#include <axis2_amqp_sender.h>
-
-static const axis2_transport_sender_ops_t amqp_sender_ops =
-{
- axis2_amqp_sender_init,
- axis2_amqp_sender_invoke,
- axis2_amqp_sender_clean_up,
- axis2_amqp_sender_free
-};
-
-AXIS2_EXTERN axis2_transport_sender_t* AXIS2_CALL
-axis2_amqp_sender_create(
- const axutil_env_t* env)
-{
- AXIS2_ENV_CHECK(env, NULL);
-
- axis2_amqp_sender_resource_pack_t* sender_resource_pack = NULL;
-
- sender_resource_pack = (axis2_amqp_sender_resource_pack_t*)AXIS2_MALLOC(env->allocator,
- sizeof(axis2_amqp_sender_resource_pack_t));
-
- if(!sender_resource_pack)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- return NULL;
- }
-
- sender_resource_pack->sender.ops = &amqp_sender_ops;
- sender_resource_pack->conf_ctx = NULL;
-
- return &(sender_resource_pack->sender);
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_amqp_sender_init(
- axis2_transport_sender_t* sender,
- const axutil_env_t* env,
- axis2_conf_ctx_t* conf_ctx,
- axis2_transport_out_desc_t* out_desc)
-{
- axis2_amqp_sender_resource_pack_t* sender_resource_pack = NULL;
- axutil_property_t* property = NULL;
- int* request_timeout = (int*)AXIS2_MALLOC(env->allocator, sizeof(int));
- *request_timeout = AXIS2_QPID_NULL_CONF_INT;
-
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
- sender_resource_pack = AXIS2_AMQP_SENDER_TO_RESOURCE_PACK(sender);
- sender_resource_pack->conf_ctx = conf_ctx;
-
- /* Set request timeout */
- *request_timeout = axis2_amqp_util_get_out_desc_conf_value_int(out_desc, env,
- AXIS2_AMQP_CONF_QPID_REQUEST_TIMEOUT);
- if(*request_timeout == AXIS2_QPID_NULL_CONF_INT)
- {
- *request_timeout = AXIS2_QPID_DEFAULT_REQUEST_TIMEOUT;
- }
- property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0,
- (void*)request_timeout);
- axis2_conf_ctx_set_property(sender_resource_pack->conf_ctx, env,
- AXIS2_AMQP_CONF_CTX_PROPERTY_REQUEST_TIMEOUT, property);
-
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_amqp_sender_invoke(
- axis2_transport_sender_t* sender,
- const axutil_env_t* env,
- axis2_msg_ctx_t* msg_ctx)
-{
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
-
- axiom_soap_envelope_t* request_soap_envelope = NULL;
- axiom_xml_writer_t* xml_writer = NULL;
- axiom_output_t* request_om_output = NULL;
- axis2_char_t* request_content = NULL;
- axis2_bool_t is_server = AXIS2_TRUE;
- axis2_bool_t is_soap_11 = AXIS2_FALSE;
- axutil_string_t* content_type = NULL;
- const axis2_char_t* soap_action = NULL;
- axis2_bool_t do_mtom = AXIS2_FALSE;
- axis2_bool_t status = AXIS2_FAILURE;
-
- request_soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
-
- xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0,
- AXIS2_XML_PARSER_TYPE_BUFFER);
- if(!xml_writer)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Writer");
- return AXIS2_FAILURE;
- }
-
- request_om_output = axiom_output_create(env, xml_writer);
- if(!request_om_output)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create OM Output");
- axiom_xml_writer_free(xml_writer, env);
- xml_writer = NULL;
- return AXIS2_FAILURE;
- }
-
- is_soap_11 = axis2_msg_ctx_get_is_soap_11(msg_ctx, env);
-
- /* Set SOAP version */
- axiom_output_set_soap11(request_om_output, env, is_soap_11);
-
- /* Content-Type */
- if(AXIS2_TRUE == is_soap_11)
- {
- /* SOAP1.1 */
- content_type = axutil_string_create(env, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML);
- }
- else
- {
- /* SOAP1.2 */
- content_type = axutil_string_create(env, AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP);
- }
-
- /* SOAP action */
- soap_action = axutil_string_get_buffer(axis2_msg_ctx_get_soap_action(msg_ctx, env), env);
-
- if(!soap_action)
- soap_action = "";
-
- /* Handle MTOM */
- do_mtom = axis2_msg_ctx_get_doing_mtom(msg_ctx, env);
-
- axiom_output_set_do_optimize(request_om_output, env, do_mtom);
- axiom_soap_envelope_serialize(request_soap_envelope, env, request_om_output, AXIS2_FALSE);
-
- if(do_mtom)
- {
- axis2_status_t mtom_status = AXIS2_FAILURE;
- axutil_array_list_t* mime_parts = NULL;
-
- mtom_status = axiom_output_flush(request_om_output, env);
-
- if(mtom_status == AXIS2_SUCCESS)
- {
- mime_parts = axiom_output_get_mime_parts(request_om_output, env);
- if(!mime_parts)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "Unable to create the mime part list from request_om_output");
-
- return AXIS2_FAILURE;
- }
- else
- {
- axis2_msg_ctx_set_mime_parts(msg_ctx, env, mime_parts);
- }
- }
-
- content_type = axutil_string_create(env, axiom_output_get_content_type(request_om_output,
- env));
- }
-
- request_content = (axis2_char_t*)axiom_xml_writer_get_xml(xml_writer, env);
- if(!request_content)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Serialize the SOAP Envelope");
- return AXIS2_FAILURE;
- }
-
- is_server = axis2_amqp_util_msg_ctx_get_server_side(msg_ctx, env);
-
- if(is_server)
- {
- status = axis2_qpid_send(request_content, env, axutil_string_get_buffer(content_type, env),
- soap_action, msg_ctx);
- }
- else
- {
- if(AXIS2_TRUE == axis2_amqp_util_msg_ctx_get_use_separate_listener(msg_ctx, env)) /* Dual Channel */
- {
- status = axis2_qpid_send(request_content, env, axutil_string_get_buffer(content_type,
- env), soap_action, msg_ctx);
- }
- else
- {
- axis2_op_t* op = NULL;
- const axis2_char_t* mep = NULL;
-
- op = axis2_msg_ctx_get_op(msg_ctx, env);
-
- if(op)
- {
- mep = axis2_op_get_msg_exchange_pattern(op, env);
- }
-
- axis2_amqp_response_t* response = NULL;
- response = axis2_qpid_send_receive(request_content, env, axutil_string_get_buffer(
- content_type, env), soap_action, msg_ctx);
-
- if(response)
- {
- /* Create in stream */
- if(response->data)
- {
- axutil_stream_t* in_stream = NULL;
- axutil_property_t* property = NULL;
-
- in_stream = axutil_stream_create_basic(env);
- axutil_stream_write(in_stream, env, response->data, response->length);
-
- property = axutil_property_create(env);
- axutil_property_set_scope(property, env, AXIS2_SCOPE_REQUEST);
- axutil_property_set_free_func(property, env, axutil_stream_free_void_arg);
- axutil_property_set_value(property, env, in_stream);
-
- axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_TRANSPORT_IN, property);
- }
-
- if(mep)
- {
- if(0 == axutil_strcmp(mep, AXIS2_MEP_URI_OUT_IN)) /* Out-In */
- {
- axiom_soap_envelope_t* response_soap_envelope = NULL;
-
- response_soap_envelope = axis2_amqp_util_get_soap_envelope(response, env,
- msg_ctx);
- if(response_soap_envelope)
- {
- axis2_msg_ctx_set_response_soap_envelope(msg_ctx, env,
- response_soap_envelope);
- }
- }
- }
-
- status = AXIS2_SUCCESS;
-
- axis2_msg_ctx_set_status_code(msg_ctx, env, status);
-
- axis2_amqp_response_free(response, env);
- }
- else
- {
- if(mep)
- {
- if(axutil_strcmp(mep, AXIS2_MEP_URI_OUT_ONLY) == 0 || axutil_strcmp(mep,
- AXIS2_MEP_URI_ROBUST_OUT_ONLY) == 0) /* One-way */
- {
- status = AXIS2_SUCCESS;
-
- /* Set status code in msg_ctx */
- axis2_msg_ctx_set_status_code(msg_ctx, env, status);
- }
- }
- }
- }
- }
-
- if(content_type)
- axutil_string_free(content_type, env);
-
- return status;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_amqp_sender_clean_up(
- axis2_transport_sender_t* sender,
- const axutil_env_t* env,
- axis2_msg_ctx_t* msg_ctx)
-{
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN void AXIS2_CALL
-axis2_amqp_sender_free(
- axis2_transport_sender_t* sender,
- const axutil_env_t* env)
-{
- AXIS2_ENV_CHECK(env, void);
-
- axis2_amqp_sender_resource_pack_t* sender_resource_pack = NULL;
- sender_resource_pack = AXIS2_AMQP_SENDER_TO_RESOURCE_PACK(sender);
-
- AXIS2_FREE(env->allocator, sender_resource_pack);
-}
-
-/* Library Exports */
-
-AXIS2_EXPORT int
-#ifndef AXIS2_STATIC_DEPLOY
-axis2_get_instance(
-#else
- axis2_amqp_sender_get_instance(
-#endif
- struct axis2_transport_sender** inst,
- const axutil_env_t* env)
-{
- int status = AXIS2_SUCCESS;
-
- *inst = axis2_amqp_sender_create(env);
- if(!(*inst))
- {
- status = AXIS2_FAILURE;
- }
-
- return status;
-}
-
-AXIS2_EXPORT int
-#ifndef AXIS2_STATIC_DEPLOY
-axis2_remove_instance(
-#else
- axis2_amqp_sender_remove_instance(
-#endif
- axis2_transport_sender_t* inst,
- const axutil_env_t* env)
-{
- if(inst)
- {
- axis2_transport_sender_free(inst, env);
- }
-
- return AXIS2_SUCCESS;
-}
-
+/*
+ * 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.
+ */
+
+#include <axiom_soap.h>
+#include <axis2_transport_in_desc.h>
+#include <axis2_amqp_defines.h>
+#include <axis2_amqp_util.h>
+#include <axis2_amqp_receiver.h>
+#include <axis2_amqp_sender.h>
+
+static const axis2_transport_sender_ops_t amqp_sender_ops =
+{
+ axis2_amqp_sender_init,
+ axis2_amqp_sender_invoke,
+ axis2_amqp_sender_clean_up,
+ axis2_amqp_sender_free
+};
+
+AXIS2_EXTERN axis2_transport_sender_t* AXIS2_CALL
+axis2_amqp_sender_create(
+ const axutil_env_t* env)
+{
+ AXIS2_ENV_CHECK(env, NULL);
+
+ axis2_amqp_sender_resource_pack_t* sender_resource_pack = NULL;
+
+ sender_resource_pack = (axis2_amqp_sender_resource_pack_t*)AXIS2_MALLOC(env->allocator,
+ sizeof(axis2_amqp_sender_resource_pack_t));
+
+ if(!sender_resource_pack)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ sender_resource_pack->sender.ops = &amqp_sender_ops;
+ sender_resource_pack->conf_ctx = NULL;
+
+ return &(sender_resource_pack->sender);
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_amqp_sender_init(
+ axis2_transport_sender_t* sender,
+ const axutil_env_t* env,
+ axis2_conf_ctx_t* conf_ctx,
+ axis2_transport_out_desc_t* out_desc)
+{
+ axis2_amqp_sender_resource_pack_t* sender_resource_pack = NULL;
+ axutil_property_t* property = NULL;
+ int* request_timeout = (int*)AXIS2_MALLOC(env->allocator, sizeof(int));
+ *request_timeout = AXIS2_QPID_NULL_CONF_INT;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ sender_resource_pack = AXIS2_AMQP_SENDER_TO_RESOURCE_PACK(sender);
+ sender_resource_pack->conf_ctx = conf_ctx;
+
+ /* Set request timeout */
+ *request_timeout = axis2_amqp_util_get_out_desc_conf_value_int(out_desc, env,
+ AXIS2_AMQP_CONF_QPID_REQUEST_TIMEOUT);
+ if(*request_timeout == AXIS2_QPID_NULL_CONF_INT)
+ {
+ *request_timeout = AXIS2_QPID_DEFAULT_REQUEST_TIMEOUT;
+ }
+ property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0,
+ (void*)request_timeout);
+ axis2_conf_ctx_set_property(sender_resource_pack->conf_ctx, env,
+ AXIS2_AMQP_CONF_CTX_PROPERTY_REQUEST_TIMEOUT, property);
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_amqp_sender_invoke(
+ axis2_transport_sender_t* sender,
+ const axutil_env_t* env,
+ axis2_msg_ctx_t* msg_ctx)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ axiom_soap_envelope_t* request_soap_envelope = NULL;
+ axiom_xml_writer_t* xml_writer = NULL;
+ axiom_output_t* request_om_output = NULL;
+ axis2_char_t* request_content = NULL;
+ axis2_bool_t is_server = AXIS2_TRUE;
+ axis2_bool_t is_soap_11 = AXIS2_FALSE;
+ axutil_string_t* content_type = NULL;
+ const axis2_char_t* soap_action = NULL;
+ axis2_bool_t do_mtom = AXIS2_FALSE;
+ axis2_bool_t status = AXIS2_FAILURE;
+
+ request_soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
+
+ xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0,
+ AXIS2_XML_PARSER_TYPE_BUFFER);
+ if(!xml_writer)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Writer");
+ return AXIS2_FAILURE;
+ }
+
+ request_om_output = axiom_output_create(env, xml_writer);
+ if(!request_om_output)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create OM Output");
+ axiom_xml_writer_free(xml_writer, env);
+ xml_writer = NULL;
+ return AXIS2_FAILURE;
+ }
+
+ is_soap_11 = axis2_msg_ctx_get_is_soap_11(msg_ctx, env);
+
+ /* Set SOAP version */
+ axiom_output_set_soap11(request_om_output, env, is_soap_11);
+
+ /* Content-Type */
+ if(AXIS2_TRUE == is_soap_11)
+ {
+ /* SOAP1.1 */
+ content_type = axutil_string_create(env, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML);
+ }
+ else
+ {
+ /* SOAP1.2 */
+ content_type = axutil_string_create(env, AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP);
+ }
+
+ /* SOAP action */
+ soap_action = axutil_string_get_buffer(axis2_msg_ctx_get_soap_action(msg_ctx, env), env);
+
+ if(!soap_action)
+ soap_action = "";
+
+ /* Handle MTOM */
+ do_mtom = axis2_msg_ctx_get_doing_mtom(msg_ctx, env);
+
+ axiom_output_set_do_optimize(request_om_output, env, do_mtom);
+ axiom_soap_envelope_serialize(request_soap_envelope, env, request_om_output, AXIS2_FALSE);
+
+ if(do_mtom)
+ {
+ axis2_status_t mtom_status = AXIS2_FAILURE;
+ axutil_array_list_t* mime_parts = NULL;
+
+ mtom_status = axiom_output_flush(request_om_output, env);
+
+ if(mtom_status == AXIS2_SUCCESS)
+ {
+ mime_parts = axiom_output_get_mime_parts(request_om_output, env);
+ if(!mime_parts)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Unable to create the mime part list from request_om_output");
+
+ return AXIS2_FAILURE;
+ }
+ else
+ {
+ axis2_msg_ctx_set_mime_parts(msg_ctx, env, mime_parts);
+ }
+ }
+
+ content_type = axutil_string_create(env, axiom_output_get_content_type(request_om_output,
+ env));
+ }
+
+ request_content = (axis2_char_t*)axiom_xml_writer_get_xml(xml_writer, env);
+ if(!request_content)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Serialize the SOAP Envelope");
+ return AXIS2_FAILURE;
+ }
+
+ is_server = axis2_amqp_util_msg_ctx_get_server_side(msg_ctx, env);
+
+ if(is_server)
+ {
+ status = axis2_qpid_send(request_content, env, axutil_string_get_buffer(content_type, env),
+ soap_action, msg_ctx);
+ }
+ else
+ {
+ if(AXIS2_TRUE == axis2_amqp_util_msg_ctx_get_use_separate_listener(msg_ctx, env)) /* Dual Channel */
+ {
+ status = axis2_qpid_send(request_content, env, axutil_string_get_buffer(content_type,
+ env), soap_action, msg_ctx);
+ }
+ else
+ {
+ axis2_op_t* op = NULL;
+ const axis2_char_t* mep = NULL;
+
+ op = axis2_msg_ctx_get_op(msg_ctx, env);
+
+ if(op)
+ {
+ mep = axis2_op_get_msg_exchange_pattern(op, env);
+ }
+
+ axis2_amqp_response_t* response = NULL;
+ response = axis2_qpid_send_receive(request_content, env, axutil_string_get_buffer(
+ content_type, env), soap_action, msg_ctx);
+
+ if(response)
+ {
+ /* Create in stream */
+ if(response->data)
+ {
+ axutil_stream_t* in_stream = NULL;
+ axutil_property_t* property = NULL;
+
+ in_stream = axutil_stream_create_basic(env);
+ axutil_stream_write(in_stream, env, response->data, response->length);
+
+ property = axutil_property_create(env);
+ axutil_property_set_scope(property, env, AXIS2_SCOPE_REQUEST);
+ axutil_property_set_free_func(property, env, axutil_stream_free_void_arg);
+ axutil_property_set_value(property, env, in_stream);
+
+ axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_TRANSPORT_IN, property);
+ }
+
+ if(mep)
+ {
+ if(0 == axutil_strcmp(mep, AXIS2_MEP_URI_OUT_IN)) /* Out-In */
+ {
+ axiom_soap_envelope_t* response_soap_envelope = NULL;
+
+ response_soap_envelope = axis2_amqp_util_get_soap_envelope(response, env,
+ msg_ctx);
+ if(response_soap_envelope)
+ {
+ axis2_msg_ctx_set_response_soap_envelope(msg_ctx, env,
+ response_soap_envelope);
+ }
+ }
+ }
+
+ status = AXIS2_SUCCESS;
+
+ axis2_msg_ctx_set_status_code(msg_ctx, env, status);
+
+ axis2_amqp_response_free(response, env);
+ }
+ else
+ {
+ if(mep)
+ {
+ if(axutil_strcmp(mep, AXIS2_MEP_URI_OUT_ONLY) == 0 || axutil_strcmp(mep,
+ AXIS2_MEP_URI_ROBUST_OUT_ONLY) == 0) /* One-way */
+ {
+ status = AXIS2_SUCCESS;
+
+ /* Set status code in msg_ctx */
+ axis2_msg_ctx_set_status_code(msg_ctx, env, status);
+ }
+ }
+ }
+ }
+ }
+
+ if(content_type)
+ axutil_string_free(content_type, env);
+
+ return status;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_amqp_sender_clean_up(
+ axis2_transport_sender_t* sender,
+ const axutil_env_t* env,
+ axis2_msg_ctx_t* msg_ctx)
+{
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_amqp_sender_free(
+ axis2_transport_sender_t* sender,
+ const axutil_env_t* env)
+{
+ AXIS2_ENV_CHECK(env, void);
+
+ axis2_amqp_sender_resource_pack_t* sender_resource_pack = NULL;
+ sender_resource_pack = AXIS2_AMQP_SENDER_TO_RESOURCE_PACK(sender);
+
+ AXIS2_FREE(env->allocator, sender_resource_pack);
+}
+
+/* Library Exports */
+
+AXIS2_EXPORT int
+#ifndef AXIS2_STATIC_DEPLOY
+axis2_get_instance(
+#else
+ axis2_amqp_sender_get_instance(
+#endif
+ struct axis2_transport_sender** inst,
+ const axutil_env_t* env)
+{
+ int status = AXIS2_SUCCESS;
+
+ *inst = axis2_amqp_sender_create(env);
+ if(!(*inst))
+ {
+ status = AXIS2_FAILURE;
+ }
+
+ return status;
+}
+
+AXIS2_EXPORT int
+#ifndef AXIS2_STATIC_DEPLOY
+axis2_remove_instance(
+#else
+ axis2_amqp_sender_remove_instance(
+#endif
+ axis2_transport_sender_t* inst,
+ const axutil_env_t* env)
+{
+ if(inst)
+ {
+ axis2_transport_sender_free(inst, env);
+ }
+
+ return AXIS2_SUCCESS;
+}
+
diff --git a/src/core/transport/amqp/sender/axis2_amqp_sender.h b/src/core/transport/amqp/sender/axis2_amqp_sender.h
index b523347..2aa3055 100644
--- a/src/core/transport/amqp/sender/axis2_amqp_sender.h
+++ b/src/core/transport/amqp/sender/axis2_amqp_sender.h
@@ -1,63 +1,63 @@
-/*
- * 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 AXIS2_AMQP_SENDER_H
-#define AXIS2_AMQP_SENDER_H
-
-#include <axutil_env.h>
-#include <axis2_conf_ctx.h>
-#include <axis2_transport_sender.h>
-#include <axis2_qpid_sender_interface.h>
-
-typedef struct axis2_amqp_sender_resource_pack
-{
- axis2_transport_sender_t sender;
- axis2_conf_ctx_t* conf_ctx;
-}
-axis2_amqp_sender_resource_pack_t;
-
-#define AXIS2_AMQP_SENDER_TO_RESOURCE_PACK(amqp_sender) \
- ((axis2_amqp_sender_resource_pack_t*)(amqp_sender))
-
-AXIS2_EXTERN axis2_transport_sender_t* AXIS2_CALL
-axis2_amqp_sender_create(const axutil_env_t* env);
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_amqp_sender_init(
- axis2_transport_sender_t* sender,
- const axutil_env_t* env,
- axis2_conf_ctx_t* conf_ctx,
- axis2_transport_out_desc_t* out_desc);
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_amqp_sender_invoke(
- axis2_transport_sender_t* sender,
- const axutil_env_t* env,
- axis2_msg_ctx_t* msg_ctx);
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_amqp_sender_clean_up(
- axis2_transport_sender_t* sender,
- const axutil_env_t* env,
- axis2_msg_ctx_t* msg_ctx);
-
-AXIS2_EXTERN void AXIS2_CALL
-axis2_amqp_sender_free(
- axis2_transport_sender_t* sender,
- const axutil_env_t* env);
-
-#endif
+/*
+ * 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 AXIS2_AMQP_SENDER_H
+#define AXIS2_AMQP_SENDER_H
+
+#include <axutil_env.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_transport_sender.h>
+#include <axis2_qpid_sender_interface.h>
+
+typedef struct axis2_amqp_sender_resource_pack
+{
+ axis2_transport_sender_t sender;
+ axis2_conf_ctx_t* conf_ctx;
+}
+axis2_amqp_sender_resource_pack_t;
+
+#define AXIS2_AMQP_SENDER_TO_RESOURCE_PACK(amqp_sender) \
+ ((axis2_amqp_sender_resource_pack_t*)(amqp_sender))
+
+AXIS2_EXTERN axis2_transport_sender_t* AXIS2_CALL
+axis2_amqp_sender_create(const axutil_env_t* env);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_amqp_sender_init(
+ axis2_transport_sender_t* sender,
+ const axutil_env_t* env,
+ axis2_conf_ctx_t* conf_ctx,
+ axis2_transport_out_desc_t* out_desc);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_amqp_sender_invoke(
+ axis2_transport_sender_t* sender,
+ const axutil_env_t* env,
+ axis2_msg_ctx_t* msg_ctx);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_amqp_sender_clean_up(
+ axis2_transport_sender_t* sender,
+ const axutil_env_t* env,
+ axis2_msg_ctx_t* msg_ctx);
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_amqp_sender_free(
+ axis2_transport_sender_t* sender,
+ const axutil_env_t* env);
+
+#endif
diff --git a/src/core/transport/amqp/sender/qpid_sender/axis2_qpid_sender.h b/src/core/transport/amqp/sender/qpid_sender/axis2_qpid_sender.h
index 8c94cfa..e797c71 100644
--- a/src/core/transport/amqp/sender/qpid_sender/axis2_qpid_sender.h
+++ b/src/core/transport/amqp/sender/qpid_sender/axis2_qpid_sender.h
@@ -1,49 +1,49 @@
-/*
- * 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
- *
- * tcp://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 AXIS2_QPID_SENDER_H
-#define AXIS2_QPID_SENDER_H
-
-#include <axis2_util.h>
-#include <sstream>
-#include <string>
-
-using std::string;
-
-class Axis2QpidSender
-{
- public:
- Axis2QpidSender(string qpidBrokerIP, int qpidBrokerPort, const axutil_env_t* env);
- ~Axis2QpidSender(void);
-
- bool SendReceive(string messageContent, string toQueueName, bool isSOAP11,
- string contentType, string soapAction, axutil_array_list_t* mime_parts, int timeout);
- bool Send(string messageContent, string toQueueName, string replyToQueueName, bool isSOAP11,
- string contentType, string soapAction, axutil_array_list_t* mime_parts);
-
- string responseContent;
- string responseContentType;
-
- private:
- void GetMimeBody(axutil_array_list_t* mime_parts, string& mimeBody);
-
- string qpidBrokerIP;
- int qpidBrokerPort;
- const axutil_env_t* env;
-};
-
-#endif
+/*
+ * 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
+ *
+ * tcp://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 AXIS2_QPID_SENDER_H
+#define AXIS2_QPID_SENDER_H
+
+#include <axis2_util.h>
+#include <sstream>
+#include <string>
+
+using std::string;
+
+class Axis2QpidSender
+{
+ public:
+ Axis2QpidSender(string qpidBrokerIP, int qpidBrokerPort, const axutil_env_t* env);
+ ~Axis2QpidSender(void);
+
+ bool SendReceive(string messageContent, string toQueueName, bool isSOAP11,
+ string contentType, string soapAction, axutil_array_list_t* mime_parts, int timeout);
+ bool Send(string messageContent, string toQueueName, string replyToQueueName, bool isSOAP11,
+ string contentType, string soapAction, axutil_array_list_t* mime_parts);
+
+ string responseContent;
+ string responseContentType;
+
+ private:
+ void GetMimeBody(axutil_array_list_t* mime_parts, string& mimeBody);
+
+ string qpidBrokerIP;
+ int qpidBrokerPort;
+ const axutil_env_t* env;
+};
+
+#endif
diff --git a/src/core/transport/amqp/sender/qpid_sender/axis2_qpid_sender_interface.h b/src/core/transport/amqp/sender/qpid_sender/axis2_qpid_sender_interface.h
index 94e232f..5e7a368 100644
--- a/src/core/transport/amqp/sender/qpid_sender/axis2_qpid_sender_interface.h
+++ b/src/core/transport/amqp/sender/qpid_sender/axis2_qpid_sender_interface.h
@@ -1,50 +1,50 @@
-/*
-* 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 AXIS2_QPID_SENDER_INTERFACE_H
-#define AXIS2_QPID_SENDER_INTERFACE_H
-
-#include <axis2_util.h>
-#include <axis2_conf_init.h>
-#include <axis2_amqp_util.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-AXIS2_EXTERN axis2_amqp_response_t* AXIS2_CALL
-axis2_qpid_send_receive(
- const axis2_char_t* request_content,
- const axutil_env_t* env,
- const axis2_char_t* content_type,
- const axis2_char_t* soap_action,
- axis2_msg_ctx_t* msg_ctx);
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axis2_qpid_send(
- const axis2_char_t* request_content,
- const axutil_env_t* env,
- const axis2_char_t* content_type,
- const axis2_char_t* soap_action,
- axis2_msg_ctx_t* msg_ctx);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+/*
+* 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 AXIS2_QPID_SENDER_INTERFACE_H
+#define AXIS2_QPID_SENDER_INTERFACE_H
+
+#include <axis2_util.h>
+#include <axis2_conf_init.h>
+#include <axis2_amqp_util.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+AXIS2_EXTERN axis2_amqp_response_t* AXIS2_CALL
+axis2_qpid_send_receive(
+ const axis2_char_t* request_content,
+ const axutil_env_t* env,
+ const axis2_char_t* content_type,
+ const axis2_char_t* soap_action,
+ axis2_msg_ctx_t* msg_ctx);
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_qpid_send(
+ const axis2_char_t* request_content,
+ const axutil_env_t* env,
+ const axis2_char_t* content_type,
+ const axis2_char_t* soap_action,
+ axis2_msg_ctx_t* msg_ctx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/core/transport/amqp/server/axis2_amqp_server/axis2_amqp_server.c b/src/core/transport/amqp/server/axis2_amqp_server/axis2_amqp_server.c
index 9f69283..76770bd 100644
--- a/src/core/transport/amqp/server/axis2_amqp_server/axis2_amqp_server.c
+++ b/src/core/transport/amqp/server/axis2_amqp_server/axis2_amqp_server.c
@@ -1,232 +1,232 @@
-/*
- * 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
- *
- * tcp://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.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <axutil_error_default.h>
-#include <axutil_log_default.h>
-#include <axutil_thread_pool.h>
-#include <signal.h>
-#include <axutil_types.h>
-#include <ctype.h>
-#include <axiom_xml_reader.h>
-#include <axis2_amqp_server.h>
-#include <axis2_amqp_receiver.h>
-#include <axis2_qpid_receiver_interface.h>
-
-axis2_transport_receiver_t* receiver = NULL;
-axutil_env_t* server_env = NULL;
-
-axutil_env_t*
-init_server_env(
- axutil_allocator_t* allocator,
- const axis2_char_t* log_file_name)
-{
- axutil_error_t* error = axutil_error_create(allocator);
- axutil_log_t* log = axutil_log_create(allocator, NULL, log_file_name);
- axutil_thread_pool_t* thread_pool = axutil_thread_pool_init(allocator);
- axutil_env_t* env = axutil_env_create_with_error_log_thread_pool(allocator, error, log,
- thread_pool);
-
- axiom_xml_reader_init();
-
- return env;
-}
-
-void
-server_exit(
- int status)
-{
- if(receiver)
- {
- axis2_transport_receiver_free(receiver, server_env);
- }
-
- if(server_env)
- {
- axutil_env_free(server_env);
- }
-
- axiom_xml_reader_cleanup();
-
- exit(status);
-}
-
-void
-show_usage(
- axis2_char_t* prog_name)
-{
- fprintf(stdout, "\n Usage : %s", prog_name);
- fprintf(stdout, " [-i QPID_BROKER_IP]");
- fprintf(stdout, " [-p QPID_BROKER_PORT]");
- fprintf(stdout, " [-r REPO_PATH]");
- fprintf(stdout, " [-l LOG_LEVEL]");
- fprintf(stdout, " [-f LOG_FILE]\n");
- fprintf(stdout, " [-s LOG_FILE_SIZE]\n");
- fprintf(stdout, " Options :\n");
- fprintf(stdout, "\t-i QPID_BROKER_IP \t Qpid broker IP, default is 127.0.0.1\n");
- fprintf(stdout,
- "\t-p QPID_BROKER_PORT \t the port on which the Qpid broker listens, default is 5672\n");
- fprintf(stdout, "\t-r REPO_PATH \t\t repository path, default is ../\n");
- fprintf(stdout, "\t-l LOG_LEVEL\t\t log level, available log levels:"
- "\n\t\t\t\t\t 0 - critical 1 - errors 2 - warnings"
- "\n\t\t\t\t\t 3 - information 4 - debug 5- user 6 - trace"
- "\n\t\t\t\t\t Default log level is 4(debug).\n");
-#ifndef WIN32
- fprintf(stdout, "\t-f LOG_FILE\t\t log file, default is $AXIS2C_HOME/logs/axis2.log"
- "\n\t\t\t\t or axis2.log in current folder if AXIS2C_HOME not set\n");
-#else
- fprintf(stdout,
- "\t-f LOG_FILE\t\t log file, default is %%AXIS2C_HOME%%\\logs\\axis2.log"
- "\n\t\t\t\t or axis2.log in current folder if AXIS2C_HOME not set\n");
-#endif
- fprintf(stdout,
- "\t-s LOG_FILE_SIZE\t Maximum log file size in mega bytes, default maximum size is 1MB.\n");
- fprintf(stdout, " Help :\n\t-h \t\t\t display this help screen.\n\n");
-}
-
-#ifndef WIN32
-
-void
-sig_handler(
- int signal)
-{
- switch(signal)
- {
- case SIGINT:
- AXIS2_LOG_INFO(server_env->log, "Received signal SIGINT.Server shutting down");
- axis2_amqp_receiver_stop(receiver, server_env);
- AXIS2_LOG_INFO(server_env->log, "Shutdown complete ...");
-
- server_exit(0);
-
- case SIGPIPE:
- AXIS2_LOG_INFO(server_env->log, "Received signal SIGPIPE.Client request serve aborted");
- return;
-
- case SIGSEGV:
- fprintf(stderr, "Received deadly signal SIGSEGV. Terminating ...\n");
- _exit(-1);
- }
-}
-
-#endif
-
-int
-main(
- int argc,
- char* argv[])
-{
- axutil_allocator_t* allocator = NULL;
- extern char* optarg;
- extern int optopt;
- int c;
- const axis2_char_t* qpid_broker_ip = NULL;
- int qpid_broker_port = AXIS2_QPID_NULL_CONF_INT;
- const axis2_char_t* repo_path = AXIS2_AMQP_SERVER_REPO_PATH;
- axutil_log_levels_t log_level = AXIS2_LOG_LEVEL_DEBUG;
- const axis2_char_t* log_file_name = AXIS2_AMQP_SERVER_LOG_FILE_NAME;
- int log_file_size = AXUTIL_LOG_FILE_SIZE;
-
- while((c = AXIS2_GETOPT(argc, argv, "i:p:r:l:f:s:h")) != -1)
- {
- switch(c)
- {
- case 'i':
- qpid_broker_ip = optarg;
- break;
-
- case 'p':
- qpid_broker_port = AXIS2_ATOI(optarg);
- break;
-
- case 'r':
- repo_path = optarg;
- break;
-
- case 'l':
- log_level = AXIS2_ATOI(optarg);
- if(log_level < AXIS2_LOG_LEVEL_CRITICAL)
- log_level = AXIS2_LOG_LEVEL_CRITICAL;
- if(log_level > AXIS2_LOG_LEVEL_TRACE)
- log_level = AXIS2_LOG_LEVEL_TRACE;
- break;
-
- case 'f':
- log_file_name = optarg;
- break;
-
- case 's':
- log_file_size = 1024 * 1024 * AXIS2_ATOI(optarg);
- break;
-
- case 'h':
- show_usage(argv[0]);
- return 0;
-
- case ':':
- fprintf(stderr, "\nOption -%c requires an operand\n", optopt);
- show_usage(argv[0]);
- return -1;
-
- case '?':
- if(isprint(optopt))
- fprintf(stderr, "\nUnknown option `-%c'.\n", optopt);
- show_usage(argv[0]);
- return -1;
- }
- }
-
- allocator = axutil_allocator_init(NULL);
- if(!allocator)
- {
- server_exit(-1);
- }
-
- server_env = init_server_env(allocator, log_file_name);
- server_env->log->level = log_level;
- server_env->log->size = log_file_size;
-
- axutil_error_init();
-
-#ifndef WIN32
- signal(SIGINT, sig_handler);
- signal(SIGPIPE, sig_handler);
-#endif
-
- AXIS2_LOG_INFO(server_env->log, "Starting Axis2 AMQP Server ...");
- AXIS2_LOG_INFO(server_env->log, "Repo Location : %s", repo_path);
-
- receiver = axis2_amqp_receiver_create(server_env, repo_path, qpid_broker_ip, qpid_broker_port);
- if(!receiver)
- {
- AXIS2_LOG_ERROR(server_env->log, AXIS2_LOG_SI,
- "Server creation failed: Error code:" " %d :: %s", server_env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(server_env->error));
- server_exit(-1);
- }
-
- if(axis2_amqp_receiver_start(receiver, server_env) == AXIS2_FAILURE)
- {
- AXIS2_LOG_ERROR(server_env->log, AXIS2_LOG_SI,
- "Server start failed: Error code:" " %d :: %s", server_env->error->error_number,
- AXIS2_ERROR_GET_MESSAGE(server_env->error));
- server_exit(-1);
- }
-
- return 0;
-}
+/*
+ * 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
+ *
+ * tcp://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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <axutil_error_default.h>
+#include <axutil_log_default.h>
+#include <axutil_thread_pool.h>
+#include <signal.h>
+#include <axutil_types.h>
+#include <ctype.h>
+#include <axiom_xml_reader.h>
+#include <axis2_amqp_server.h>
+#include <axis2_amqp_receiver.h>
+#include <axis2_qpid_receiver_interface.h>
+
+axis2_transport_receiver_t* receiver = NULL;
+axutil_env_t* server_env = NULL;
+
+axutil_env_t*
+init_server_env(
+ axutil_allocator_t* allocator,
+ const axis2_char_t* log_file_name)
+{
+ axutil_error_t* error = axutil_error_create(allocator);
+ axutil_log_t* log = axutil_log_create(allocator, NULL, log_file_name);
+ axutil_thread_pool_t* thread_pool = axutil_thread_pool_init(allocator);
+ axutil_env_t* env = axutil_env_create_with_error_log_thread_pool(allocator, error, log,
+ thread_pool);
+
+ axiom_xml_reader_init();
+
+ return env;
+}
+
+void
+server_exit(
+ int status)
+{
+ if(receiver)
+ {
+ axis2_transport_receiver_free(receiver, server_env);
+ }
+
+ if(server_env)
+ {
+ axutil_env_free(server_env);
+ }
+
+ axiom_xml_reader_cleanup();
+
+ exit(status);
+}
+
+void
+show_usage(
+ axis2_char_t* prog_name)
+{
+ fprintf(stdout, "\n Usage : %s", prog_name);
+ fprintf(stdout, " [-i QPID_BROKER_IP]");
+ fprintf(stdout, " [-p QPID_BROKER_PORT]");
+ fprintf(stdout, " [-r REPO_PATH]");
+ fprintf(stdout, " [-l LOG_LEVEL]");
+ fprintf(stdout, " [-f LOG_FILE]\n");
+ fprintf(stdout, " [-s LOG_FILE_SIZE]\n");
+ fprintf(stdout, " Options :\n");
+ fprintf(stdout, "\t-i QPID_BROKER_IP \t Qpid broker IP, default is 127.0.0.1\n");
+ fprintf(stdout,
+ "\t-p QPID_BROKER_PORT \t the port on which the Qpid broker listens, default is 5672\n");
+ fprintf(stdout, "\t-r REPO_PATH \t\t repository path, default is ../\n");
+ fprintf(stdout, "\t-l LOG_LEVEL\t\t log level, available log levels:"
+ "\n\t\t\t\t\t 0 - critical 1 - errors 2 - warnings"
+ "\n\t\t\t\t\t 3 - information 4 - debug 5- user 6 - trace"
+ "\n\t\t\t\t\t Default log level is 4(debug).\n");
+#ifndef WIN32
+ fprintf(stdout, "\t-f LOG_FILE\t\t log file, default is $AXIS2C_HOME/logs/axis2.log"
+ "\n\t\t\t\t or axis2.log in current folder if AXIS2C_HOME not set\n");
+#else
+ fprintf(stdout,
+ "\t-f LOG_FILE\t\t log file, default is %%AXIS2C_HOME%%\\logs\\axis2.log"
+ "\n\t\t\t\t or axis2.log in current folder if AXIS2C_HOME not set\n");
+#endif
+ fprintf(stdout,
+ "\t-s LOG_FILE_SIZE\t Maximum log file size in mega bytes, default maximum size is 1MB.\n");
+ fprintf(stdout, " Help :\n\t-h \t\t\t display this help screen.\n\n");
+}
+
+#ifndef WIN32
+
+void
+sig_handler(
+ int signal)
+{
+ switch(signal)
+ {
+ case SIGINT:
+ AXIS2_LOG_INFO(server_env->log, "Received signal SIGINT.Server shutting down");
+ axis2_amqp_receiver_stop(receiver, server_env);
+ AXIS2_LOG_INFO(server_env->log, "Shutdown complete ...");
+
+ server_exit(0);
+
+ case SIGPIPE:
+ AXIS2_LOG_INFO(server_env->log, "Received signal SIGPIPE.Client request serve aborted");
+ return;
+
+ case SIGSEGV:
+ fprintf(stderr, "Received deadly signal SIGSEGV. Terminating ...\n");
+ _exit(-1);
+ }
+}
+
+#endif
+
+int
+main(
+ int argc,
+ char* argv[])
+{
+ axutil_allocator_t* allocator = NULL;
+ extern char* optarg;
+ extern int optopt;
+ int c;
+ const axis2_char_t* qpid_broker_ip = NULL;
+ int qpid_broker_port = AXIS2_QPID_NULL_CONF_INT;
+ const axis2_char_t* repo_path = AXIS2_AMQP_SERVER_REPO_PATH;
+ axutil_log_levels_t log_level = AXIS2_LOG_LEVEL_DEBUG;
+ const axis2_char_t* log_file_name = AXIS2_AMQP_SERVER_LOG_FILE_NAME;
+ int log_file_size = AXUTIL_LOG_FILE_SIZE;
+
+ while((c = AXIS2_GETOPT(argc, argv, "i:p:r:l:f:s:h")) != -1)
+ {
+ switch(c)
+ {
+ case 'i':
+ qpid_broker_ip = optarg;
+ break;
+
+ case 'p':
+ qpid_broker_port = AXIS2_ATOI(optarg);
+ break;
+
+ case 'r':
+ repo_path = optarg;
+ break;
+
+ case 'l':
+ log_level = AXIS2_ATOI(optarg);
+ if(log_level < AXIS2_LOG_LEVEL_CRITICAL)
+ log_level = AXIS2_LOG_LEVEL_CRITICAL;
+ if(log_level > AXIS2_LOG_LEVEL_TRACE)
+ log_level = AXIS2_LOG_LEVEL_TRACE;
+ break;
+
+ case 'f':
+ log_file_name = optarg;
+ break;
+
+ case 's':
+ log_file_size = 1024 * 1024 * AXIS2_ATOI(optarg);
+ break;
+
+ case 'h':
+ show_usage(argv[0]);
+ return 0;
+
+ case ':':
+ fprintf(stderr, "\nOption -%c requires an operand\n", optopt);
+ show_usage(argv[0]);
+ return -1;
+
+ case '?':
+ if(isprint(optopt))
+ fprintf(stderr, "\nUnknown option `-%c'.\n", optopt);
+ show_usage(argv[0]);
+ return -1;
+ }
+ }
+
+ allocator = axutil_allocator_init(NULL);
+ if(!allocator)
+ {
+ server_exit(-1);
+ }
+
+ server_env = init_server_env(allocator, log_file_name);
+ server_env->log->level = log_level;
+ server_env->log->size = log_file_size;
+
+ axutil_error_init();
+
+#ifndef WIN32
+ signal(SIGINT, sig_handler);
+ signal(SIGPIPE, sig_handler);
+#endif
+
+ AXIS2_LOG_INFO(server_env->log, "Starting Axis2 AMQP Server ...");
+ AXIS2_LOG_INFO(server_env->log, "Repo Location : %s", repo_path);
+
+ receiver = axis2_amqp_receiver_create(server_env, repo_path, qpid_broker_ip, qpid_broker_port);
+ if(!receiver)
+ {
+ AXIS2_LOG_ERROR(server_env->log, AXIS2_LOG_SI,
+ "Server creation failed: Error code:" " %d :: %s", server_env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(server_env->error));
+ server_exit(-1);
+ }
+
+ if(axis2_amqp_receiver_start(receiver, server_env) == AXIS2_FAILURE)
+ {
+ AXIS2_LOG_ERROR(server_env->log, AXIS2_LOG_SI,
+ "Server start failed: Error code:" " %d :: %s", server_env->error->error_number,
+ AXIS2_ERROR_GET_MESSAGE(server_env->error));
+ server_exit(-1);
+ }
+
+ return 0;
+}
diff --git a/src/core/transport/amqp/server/axis2_amqp_server/axis2_amqp_server.h b/src/core/transport/amqp/server/axis2_amqp_server/axis2_amqp_server.h
index 82a200e..43cee6c 100644
--- a/src/core/transport/amqp/server/axis2_amqp_server/axis2_amqp_server.h
+++ b/src/core/transport/amqp/server/axis2_amqp_server/axis2_amqp_server.h
@@ -1,41 +1,41 @@
-/*
- * 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
- *
- * tcp://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 AXIS2_AMQP_SERVER_H
-#define AXIS2_AMQP_SERVER_H
-
-#include <axis2_amqp_defines.h>
-#include <platforms/axutil_platform_auto_sense.h>
-
-axutil_env_t*
-init_server_env(axutil_allocator_t* allocator,
- const axis2_char_t* log_file_name);
-
-void
-server_exit(int status);
-
-void
-show_usage(axis2_char_t* prog_name);
-
-#ifndef WIN32
-
-void
-sig_handler(int signal);
-
-#endif
-
-#endif
+/*
+ * 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
+ *
+ * tcp://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 AXIS2_AMQP_SERVER_H
+#define AXIS2_AMQP_SERVER_H
+
+#include <axis2_amqp_defines.h>
+#include <platforms/axutil_platform_auto_sense.h>
+
+axutil_env_t*
+init_server_env(axutil_allocator_t* allocator,
+ const axis2_char_t* log_file_name);
+
+void
+server_exit(int status);
+
+void
+show_usage(axis2_char_t* prog_name);
+
+#ifndef WIN32
+
+void
+sig_handler(int signal);
+
+#endif
+
+#endif
diff --git a/src/core/transport/amqp/util/axis2_amqp_defines.h b/src/core/transport/amqp/util/axis2_amqp_defines.h
index a892e9e..57384ef 100644
--- a/src/core/transport/amqp/util/axis2_amqp_defines.h
+++ b/src/core/transport/amqp/util/axis2_amqp_defines.h
@@ -1,65 +1,65 @@
-/*
- * 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 AXIS2_AMQP_DEFINES_H
-#define AXIS2_AMQP_DEFINES_H
-
-#include <axiom_mime_const.h>
-
-#define AXIS2_AMQP_EXCHANGE_DIRECT "amq.direct"
-
-#define AXIS2_AMQP_CONF_QPID_BROKER_IP "qpid_broker_ip"
-#define AXIS2_AMQP_CONF_QPID_BROKER_PORT "qpid_broker_port"
-#define AXIS2_AMQP_CONF_QPID_REQUEST_TIMEOUT "request_timeout"
-
-#define AXIS2_QPID_DEFAULT_BROKER_IP "127.0.0.1"
-#define AXIS2_QPID_DEFAULT_BROKER_PORT 5672
-#define AXIS2_QPID_DEFAULT_REQUEST_TIMEOUT 500
-#define AXIS2_QPID_NULL_CONF_INT -1
-
-#define AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP "qpid_broker_ip"
-#define AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT "qpid_broker_port"
-#define AXIS2_AMQP_CONF_CTX_PROPERTY_REQUEST_TIMEOUT "request_timeout"
-#define AXIS2_AMQP_CONF_CTX_PROPERTY_QUEUE_NAME "queue_name"
-
-#define AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO "qpid_reply_to"
-
-#define AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML "text/xml"
-#define AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP "application/soap+xml"
-#define AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED AXIOM_MIME_TYPE_MULTIPART_RELATED
-#define AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY "boundary"
-#define AXIS2_AMQP_HEADER_SOAP_ACTION "SOAPAction"
-#define AXIS2_AMQP_HEADER_CONTENT_TYPE "Content-Type"
-
-#define AXIS2_AMQP_TEMP_QUEUE_NAME_PREFIX "TempQueue"
-
-#define AXIS2_AMQP_SERVER_LOG_FILE_NAME "axis2_amqp_server.log"
-#define AXIS2_AMQP_SERVER_REPO_PATH "../"
-
-#define AXIS2_AMQP_EPR_PREFIX "amqp:"
-#define AXIS2_AMQP_EPR_SERVICE_PREFIX "services"
-#define AXIS2_AMQP_EPR_ANON_SERVICE_NAME "__ANONYMOUS_SERVICE__"
-
-#define AXIS2_AMQP_EQ '='
-#define AXIS2_AMQP_SEMI_COLON ';'
-#define AXIS2_AMQP_ESC_NULL '\0'
-#define AXIS2_AMQP_DOUBLE_QUOTE '"'
-#define AXIS2_AMQP_B_SLASH '\\'
-
-#define AXIS2_AMQP_NANOSEC_PER_MILLISEC 1000*1000
-
-#endif
+/*
+ * 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 AXIS2_AMQP_DEFINES_H
+#define AXIS2_AMQP_DEFINES_H
+
+#include <axiom_mime_const.h>
+
+#define AXIS2_AMQP_EXCHANGE_DIRECT "amq.direct"
+
+#define AXIS2_AMQP_CONF_QPID_BROKER_IP "qpid_broker_ip"
+#define AXIS2_AMQP_CONF_QPID_BROKER_PORT "qpid_broker_port"
+#define AXIS2_AMQP_CONF_QPID_REQUEST_TIMEOUT "request_timeout"
+
+#define AXIS2_QPID_DEFAULT_BROKER_IP "127.0.0.1"
+#define AXIS2_QPID_DEFAULT_BROKER_PORT 5672
+#define AXIS2_QPID_DEFAULT_REQUEST_TIMEOUT 500
+#define AXIS2_QPID_NULL_CONF_INT -1
+
+#define AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP "qpid_broker_ip"
+#define AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT "qpid_broker_port"
+#define AXIS2_AMQP_CONF_CTX_PROPERTY_REQUEST_TIMEOUT "request_timeout"
+#define AXIS2_AMQP_CONF_CTX_PROPERTY_QUEUE_NAME "queue_name"
+
+#define AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO "qpid_reply_to"
+
+#define AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML "text/xml"
+#define AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP "application/soap+xml"
+#define AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED AXIOM_MIME_TYPE_MULTIPART_RELATED
+#define AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY "boundary"
+#define AXIS2_AMQP_HEADER_SOAP_ACTION "SOAPAction"
+#define AXIS2_AMQP_HEADER_CONTENT_TYPE "Content-Type"
+
+#define AXIS2_AMQP_TEMP_QUEUE_NAME_PREFIX "TempQueue"
+
+#define AXIS2_AMQP_SERVER_LOG_FILE_NAME "axis2_amqp_server.log"
+#define AXIS2_AMQP_SERVER_REPO_PATH "../"
+
+#define AXIS2_AMQP_EPR_PREFIX "amqp:"
+#define AXIS2_AMQP_EPR_SERVICE_PREFIX "services"
+#define AXIS2_AMQP_EPR_ANON_SERVICE_NAME "__ANONYMOUS_SERVICE__"
+
+#define AXIS2_AMQP_EQ '='
+#define AXIS2_AMQP_SEMI_COLON ';'
+#define AXIS2_AMQP_ESC_NULL '\0'
+#define AXIS2_AMQP_DOUBLE_QUOTE '"'
+#define AXIS2_AMQP_B_SLASH '\\'
+
+#define AXIS2_AMQP_NANOSEC_PER_MILLISEC 1000*1000
+
+#endif
diff --git a/src/core/transport/amqp/util/axis2_amqp_util.c b/src/core/transport/amqp/util/axis2_amqp_util.c
index 91d346a..7249ccc 100644
--- a/src/core/transport/amqp/util/axis2_amqp_util.c
+++ b/src/core/transport/amqp/util/axis2_amqp_util.c
@@ -1,811 +1,811 @@
-/*
- * 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.
- */
-
-#include <axiom.h>
-#include <axiom_mime_parser.h>
-#include <axis2_util.h>
-#include <axis2_addr.h>
-#include <axutil_http_chunked_stream.h>
-#include <axis2_amqp_defines.h>
-#include <axis2_amqp_util.h>
-
-AXIS2_EXTERN axis2_char_t* AXIS2_CALL
-axis2_amqp_util_get_in_desc_conf_value_string(
- axis2_transport_in_desc_t* in_desc,
- const axutil_env_t* env,
- const axis2_char_t* param_name)
-{
- axutil_param_t* param = NULL;
- axis2_char_t* value = NULL;
-
- param = (axutil_param_t*)axutil_param_container_get_param(
- axis2_transport_in_desc_param_container(in_desc, env), env, param_name);
- if(param)
- {
- value = axutil_param_get_value(param, env);
- }
-
- return value;
-}
-
-AXIS2_EXTERN int AXIS2_CALL
-axis2_amqp_util_get_in_desc_conf_value_int(
- axis2_transport_in_desc_t* in_desc,
- const axutil_env_t* env,
- const axis2_char_t* param_name)
-{
- axis2_char_t* value_str = NULL;
- int value = AXIS2_QPID_NULL_CONF_INT;
-
- value_str = axis2_amqp_util_get_in_desc_conf_value_string(in_desc, env, param_name);
- if(value_str)
- {
- value = atoi(value_str);
- }
-
- return value;
-}
-
-AXIS2_EXTERN axis2_char_t* AXIS2_CALL
-axis2_amqp_util_get_out_desc_conf_value_string(
- axis2_transport_out_desc_t* out_desc,
- const axutil_env_t* env,
- const axis2_char_t* param_name)
-{
- axutil_param_t* param = NULL;
- axis2_char_t* value = NULL;
-
- param = (axutil_param_t*)axutil_param_container_get_param(
- axis2_transport_out_desc_param_container(out_desc, env), env, param_name);
- if(param)
- {
- value = axutil_param_get_value(param, env);
- }
-
- return value;
-}
-
-AXIS2_EXTERN int AXIS2_CALL
-axis2_amqp_util_get_out_desc_conf_value_int(
- axis2_transport_out_desc_t* out_desc,
- const axutil_env_t* env,
- const axis2_char_t* param_name)
-{
- axis2_char_t* value_str = NULL;
- int value = AXIS2_QPID_NULL_CONF_INT;
-
- value_str = axis2_amqp_util_get_out_desc_conf_value_string(out_desc, env, param_name);
- if(value_str)
- {
- value = atoi(value_str);
- }
-
- return value;
-}
-
-AXIS2_EXTERN axiom_soap_envelope_t* AXIS2_CALL
-axis2_amqp_util_get_soap_envelope(
- axis2_amqp_response_t* response,
- const axutil_env_t* env,
- axis2_msg_ctx_t* msg_ctx)
-{
- axiom_xml_reader_t* xml_reader = NULL;
- axiom_stax_builder_t* stax_builder = NULL;
- axiom_soap_builder_t* soap_builder = NULL;
- axiom_soap_envelope_t* soap_envelope = NULL;
- const axis2_char_t* soap_ns_uri = NULL;
- axis2_char_t *soap_body_str = NULL;
- int soap_body_len = 0;
- axis2_bool_t is_mtom = AXIS2_FALSE;
- axutil_hash_t *binary_data_map = NULL;
- axis2_bool_t is_soap_11 = AXIS2_FALSE;
-
- if(!response || !response->data || !response->content_type)
- {
- return NULL;
- }
-
- is_soap_11 = axis2_msg_ctx_get_is_soap_11(msg_ctx, env);
-
- /* Handle MTOM */
- if(strstr(response->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED))
- {
- axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env,
- response->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY);
-
- if(mime_boundary)
- {
- axiom_mime_parser_t *mime_parser = NULL;
- int soap_body_len = 0;
- axutil_param_t *buffer_size_param = NULL;
- axutil_param_t *max_buffers_param = NULL;
- axutil_param_t *attachment_dir_param = NULL;
- axis2_char_t *value_size = NULL;
- axis2_char_t *value_num = NULL;
- axis2_char_t *value_dir = NULL;
- int size = 0;
- int num = 0;
-
- mime_parser = axiom_mime_parser_create(env);
-
- buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE);
-
- if(buffer_size_param)
- {
- value_size = (axis2_char_t *)axutil_param_get_value(buffer_size_param, env);
-
- if(value_size)
- {
- size = atoi(value_size);
- axiom_mime_parser_set_buffer_size(mime_parser, env, size);
- }
- }
-
- max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS);
-
- if(max_buffers_param)
- {
- value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env);
-
- if(value_num)
- {
- num = atoi(value_num);
- axiom_mime_parser_set_max_buffers(mime_parser, env, num);
- }
- }
-
- attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR);
-
- if(attachment_dir_param)
- {
- value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env);
-
- if(value_dir)
- {
- axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir);
- }
- }
-
- if(mime_parser)
- {
- axis2_callback_info_t* callback_ctx = NULL;
- axutil_stream_t* stream = NULL;
-
- callback_ctx = (axis2_callback_info_t*)AXIS2_MALLOC(env->allocator,
- sizeof(axis2_callback_info_t));
-
- stream = axutil_stream_create_basic(env);
-
- if(stream)
- {
- axutil_stream_write(stream, env, response->data, response->length);
- callback_ctx->env = env;
- callback_ctx->in_stream = stream;
- callback_ctx->content_length = response->length;
- callback_ctx->unread_len = response->length;
- callback_ctx->chunked_stream = NULL;
- }
-
- /*binary_data_map =
- axiom_mime_parser_parse(mime_parser, env,
- axis2_amqp_util_on_data_request,
- (void*)callback_ctx,
- mime_boundary);*/
-
- if(!binary_data_map)
- {
- return AXIS2_FAILURE;
- }
-
- soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env);
-
- soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env);
-
- axutil_stream_free(stream, env);
- AXIS2_FREE(env->allocator, callback_ctx);
- axiom_mime_parser_free(mime_parser, env);
- }
-
- AXIS2_FREE(env->allocator, mime_boundary);
- }
-
- is_mtom = AXIS2_TRUE;
- }
- else
- {
- soap_body_str = response->data;
- soap_body_len = axutil_strlen(response->data);
- }
-
- soap_body_len = axutil_strlen(soap_body_str);
-
- xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL,
- AXIS2_XML_PARSER_TYPE_BUFFER);
- if(!xml_reader)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader");
- return NULL;
- }
-
- stax_builder = axiom_stax_builder_create(env, xml_reader);
- if(!stax_builder)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder");
- return NULL;
- }
-
- soap_ns_uri = is_soap_11 ? AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI
- : AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
-
- soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri);
- if(!soap_builder)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder");
- return NULL;
- }
-
- if(binary_data_map)
- {
- axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map);
- }
-
- soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env);
- return soap_envelope;
-}
-
-AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-axis2_amqp_util_conf_ctx_get_server_side(
- axis2_conf_ctx_t* conf_ctx,
- const axutil_env_t* env)
-{
- axutil_property_t* property = NULL;
- axis2_char_t* value = NULL;
-
- property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_IS_SVR_SIDE);
- if(!property)
- return AXIS2_TRUE;
-
- value = (axis2_char_t*)axutil_property_get_value(property, env);
- if(!value)
- return AXIS2_TRUE;
-
- return (axutil_strcmp(value, AXIS2_VALUE_TRUE) == 0) ? AXIS2_TRUE : AXIS2_FALSE;
-}
-
-AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-axis2_amqp_util_get_value_from_content_type(
- const axutil_env_t * env,
- const axis2_char_t * content_type,
- const axis2_char_t * key)
-{
- axis2_char_t *tmp = NULL;
- axis2_char_t *tmp_content_type = NULL;
- axis2_char_t *tmp2 = NULL;
-
- AXIS2_PARAM_CHECK(env->error, content_type, NULL);
- AXIS2_PARAM_CHECK(env->error, key, NULL);
-
- tmp_content_type = axutil_strdup(env, content_type);
-
- if(!tmp_content_type)
- {
- return NULL;
- }
-
- tmp = strstr(tmp_content_type, key);
-
- if(!tmp)
- {
- AXIS2_FREE(env->allocator, tmp_content_type);
- return NULL;
- }
-
- tmp = strchr(tmp, AXIS2_AMQP_EQ);
- tmp2 = strchr(tmp, AXIS2_AMQP_SEMI_COLON);
-
- if(tmp2)
- {
- *tmp2 = AXIS2_AMQP_ESC_NULL;
- }
-
- if(!tmp)
- {
- AXIS2_FREE(env->allocator, tmp_content_type);
- return NULL;
- }
-
- tmp2 = axutil_strdup(env, tmp + 1);
-
- AXIS2_FREE(env->allocator, tmp_content_type);
-
- if(*tmp2 == AXIS2_AMQP_DOUBLE_QUOTE)
- {
- tmp = tmp2;
- tmp2 = axutil_strdup(env, tmp + 1);
- tmp2[strlen(tmp2) - 1] = AXIS2_AMQP_ESC_NULL;
-
- if(tmp)
- {
- AXIS2_FREE(env->allocator, tmp);
- tmp = NULL;
- }
- }
-
- /* handle XOP */
- if(*tmp2 == AXIS2_AMQP_B_SLASH && *(tmp2 + 1) == '\"')
- {
- tmp = tmp2;
- tmp2 = axutil_strdup(env, tmp + 2);
- tmp2[strlen(tmp2) - 3] = AXIS2_AMQP_ESC_NULL;
-
- if(tmp)
- {
- AXIS2_FREE(env->allocator, tmp);
- tmp = NULL;
- }
- }
-
- return tmp2;
-}
-
-AXIS2_EXTERN int AXIS2_CALL
-axis2_amqp_util_on_data_request(
- char* buffer,
- int size,
- void* ctx)
-{
- const axutil_env_t* env = NULL;
- int len = -1;
- axis2_callback_info_t* cb_ctx = (axis2_callback_info_t*)ctx;
- axutil_stream_t* in_stream = NULL;
-
- if(!buffer || !ctx)
- {
- return 0;
- }
-
- if(cb_ctx->unread_len <= 0 && -1 != cb_ctx->content_length)
- {
- return 0;
- }
-
- env = ((axis2_callback_info_t*)ctx)->env;
-
- in_stream = (axutil_stream_t*)((axis2_callback_info_t *)ctx)->in_stream;
- --size; /* reserve space to insert trailing null */
-
- len = axutil_stream_read(in_stream, env, buffer, size);
-
- if(len > 0)
- {
- buffer[len] = AXIS2_AMQP_ESC_NULL;
- ((axis2_callback_info_t*)ctx)->unread_len -= len;
- }
- else if(len == 0)
- {
- ((axis2_callback_info_t*)ctx)->unread_len = 0;
- }
-
- return len;
-}
-
-AXIS2_EXTERN axis2_char_t* AXIS2_CALL
-axis2_amqp_util_conf_ctx_get_dual_channel_queue_name(
- axis2_conf_ctx_t* conf_ctx,
- const axutil_env_t* env)
-{
- axutil_property_t* property = NULL;
- axis2_char_t* queue_name = NULL;
- axis2_char_t* value = NULL;
-
- /* Get property */
- property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_QUEUE_NAME);
- if(!property) /* Very first call */
- {
- property = axutil_property_create(env);
-
- axis2_conf_ctx_set_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_QUEUE_NAME,
- property);
- }
-
- /* Get queue name */
- value = (axis2_char_t*)axutil_property_get_value(property, env);
-
- /* AMQP listener and the sender are the two parties that are
- * interested in the queue. Either party can create the queue.
- * If the queue is already created by one party, "value" is
- * not NULL. If "value" is NULL, that mean the caller of
- * this method is supposed to create the queue */
- if(value)
- {
- queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator, axutil_strlen(value) + 1);
- strcpy(queue_name, value);
-
- /*axutil_property_set_value(property, env, NULL);*/
- }
- else
- {
- /* Create new queue name */
- queue_name = axutil_stracat(env, AXIS2_AMQP_TEMP_QUEUE_NAME_PREFIX, axutil_uuid_gen(env));
-
- /* Put queue name in the conf_ctx so that the sender will know */
- axutil_property_set_value(property, env, (void*)queue_name);
- }
-
- return queue_name;
-}
-
-AXIS2_EXTERN axis2_char_t* AXIS2_CALL
-axis2_amqp_util_conf_ctx_get_qpid_broker_ip(
- axis2_conf_ctx_t* conf_ctx,
- const axutil_env_t* env)
-{
- axutil_property_t* property = NULL;
- void* value = NULL;
- axis2_char_t* broker_ip = AXIS2_QPID_DEFAULT_BROKER_IP;
-
- property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP);
-
- if(property)
- {
- value = axutil_property_get_value(property, env);
-
- if(value)
- {
- broker_ip = (axis2_char_t*)value;
- }
- }
-
- return broker_ip;
-}
-
-AXIS2_EXTERN int AXIS2_CALL
-axis2_amqp_util_conf_ctx_get_qpid_broker_port(
- axis2_conf_ctx_t* conf_ctx,
- const axutil_env_t* env)
-{
- axutil_property_t* property = NULL;
- void* value = NULL;
- int broker_port = AXIS2_QPID_DEFAULT_BROKER_PORT;
-
- property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT);
-
- if(property)
- {
- value = axutil_property_get_value(property, env);
-
- if(value)
- {
- broker_port = *(int*)value;
- }
- }
-
- return broker_port;
-}
-
-AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-axis2_amqp_util_msg_ctx_get_use_separate_listener(
- axis2_msg_ctx_t* msg_ctx,
- const axutil_env_t* env)
-{
- axutil_property_t* property = NULL;
- axis2_char_t* value = NULL;
- axis2_bool_t use_separate_listener = AXIS2_FALSE;
-
- property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_USE_SEPARATE_LISTENER);
-
- if(property)
- {
- value = (axis2_char_t*)axutil_property_get_value(property, env);
-
- if(value && (axutil_strcmp(AXIS2_VALUE_TRUE, value) == 0))
- {
- use_separate_listener = AXIS2_TRUE;
- }
- }
-
- return use_separate_listener;
-}
-
-AXIS2_EXTERN axis2_amqp_destination_info_t* AXIS2_CALL
-axis2_amqp_util_msg_ctx_get_destination_info(
- axis2_msg_ctx_t* msg_ctx,
- const axutil_env_t* env)
-{
- /* The destination URI that is expected by this method
- * should be of one of the following formats
- * 1. amqp://IP:PORT/services/SERVICE_NAME
- * 2. jms:/SERVICE_NAME?java.naming.provider.url=tcp://IP:PORT...
- * 3. TempQueue... */
-
- axis2_endpoint_ref_t* endpoint_ref = NULL;
- axis2_amqp_destination_info_t* destination_info = NULL;
-
- destination_info = (axis2_amqp_destination_info_t*)AXIS2_MALLOC(env->allocator,
- sizeof(axis2_amqp_destination_info_t));
-
- destination_info->broker_ip = NULL;
- destination_info->broker_port = AXIS2_QPID_NULL_CONF_INT;
- destination_info->queue_name = NULL;
-
- endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);
-
- if(endpoint_ref)
- {
- const axis2_char_t* endpoint_address_original = NULL;
- axis2_char_t* endpoint_address = NULL;
- char* substr = NULL;
- char* token = NULL;
- endpoint_address_original = axis2_endpoint_ref_get_address(endpoint_ref, env);
-
- if(!endpoint_address_original)
- return NULL;
-
- endpoint_address = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t)
- * axutil_strlen(endpoint_address_original)) + 1);
- strcpy((char*)endpoint_address, (char*)endpoint_address_original);
-
- if((substr = strstr(endpoint_address, AXIS2_AMQP_EPR_PREFIX))) /* Start with amqp: */
- {
- if(strstr(endpoint_address, AXIS2_AMQP_EPR_ANON_SERVICE_NAME))
- {
- /* Server reply to dual-channel client */
- axutil_property_t* property = NULL;
- property = axis2_msg_ctx_get_property(msg_ctx, env,
- AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO);
-
- if(property)
- {
- axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property,
- env);
-
- if(queue_name)
- {
- destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
- (sizeof(axis2_char_t) * strlen(queue_name)) + 1);
- strcpy(destination_info->queue_name, queue_name);
- }
- }
- }
- else
- {
- substr += strlen(AXIS2_AMQP_EPR_PREFIX) + 2; /* 2 -> "//" */
- if(substr) /* IP:PORT/services/SERVICE_NAME */
- {
- token = strtok(substr, ":");
- if(token) /* IP */
- {
- axis2_char_t* broker_ip = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
- (sizeof(axis2_char_t) * strlen(token)) + 1);
- strcpy(broker_ip, token);
- destination_info->broker_ip = broker_ip;
-
- token = strtok(NULL, "/"); /* PORT */
- if(token)
- {
- destination_info->broker_port = atoi(token);
-
- token = strtok(NULL, "#"); /* ... services/SERVICE_NAME */
- if(token)
- {
- if((substr = strstr(token, AXIS2_AMQP_EPR_SERVICE_PREFIX)))
- {
- substr += strlen(AXIS2_AMQP_EPR_SERVICE_PREFIX) + 1; /* 1 -> "/" */
- if(substr)
- {
- axis2_char_t* queue_name = (axis2_char_t*)AXIS2_MALLOC(
- env->allocator, (sizeof(axis2_char_t) * strlen(substr))
- + 1);
- strcpy(queue_name, substr);
- destination_info->queue_name = queue_name;
- }
- }
- }
- }
- }
- }
- }
- }
- else if(0 == strcmp(endpoint_address, AXIS2_WSA_ANONYMOUS_URL)) /* Required to work with Sandesha2 */
- {
- axutil_property_t* property = NULL;
- property = axis2_msg_ctx_get_property(msg_ctx, env,
- AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO);
-
- if(property)
- {
- axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property, env);
-
- if(queue_name)
- {
- destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
- (sizeof(axis2_char_t) * strlen(queue_name)) + 1);
- strcpy(destination_info->queue_name, queue_name);
- }
- }
- }
- else if((substr = strstr(endpoint_address, "jms:/")) && (substr == endpoint_address))
- {
-
- }
-
- AXIS2_FREE(env->allocator, endpoint_address);
- }
- else
- {
- /* Single-channel blocking */
- axutil_property_t* property = NULL;
- property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO);
-
- if(property)
- {
- axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property, env);
-
- if(queue_name)
- {
- destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
- (sizeof(axis2_char_t) * strlen(queue_name)) + 1);
- strcpy(destination_info->queue_name, queue_name);
- }
- }
- }
-
- /* Get broker IP/Port from conf_ctx if they are not
- * found in the destination URI */
- if(!destination_info->broker_ip)
- {
- axis2_conf_ctx_t* conf_ctx = NULL;
-
- conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
- if(conf_ctx)
- {
- axutil_property_t* property = NULL;
- property = axis2_conf_ctx_get_property(conf_ctx, env,
- AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP);
-
- if(property)
- {
- axis2_char_t* broker_ip = (axis2_char_t*)axutil_property_get_value(property, env);
-
- if(broker_ip)
- {
- destination_info->broker_ip = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
- (sizeof(axis2_char_t) * strlen(broker_ip)) + 1);
- strcpy(destination_info->broker_ip, broker_ip);
- }
- }
-
- }
- }
-
- if(AXIS2_QPID_NULL_CONF_INT == destination_info->broker_port)
- {
- axis2_conf_ctx_t* conf_ctx = NULL;
-
- conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
- if(conf_ctx)
- {
- axutil_property_t* property = NULL;
- property = axis2_conf_ctx_get_property(conf_ctx, env,
- AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT);
-
- if(property)
- {
- void* value = axutil_property_get_value(property, env);
-
- if(value)
- {
- destination_info->broker_port = *(int*)value;
- }
- }
- }
- }
-
- return destination_info;
-}
-
-AXIS2_EXTERN int AXIS2_CALL
-axis2_amqp_util_msg_ctx_get_request_timeout(
- axis2_msg_ctx_t* msg_ctx,
- const axutil_env_t* env)
-{
- axis2_conf_ctx_t* conf_ctx = NULL;
- axutil_property_t* property = NULL;
- void* value = NULL;
- int request_timeout = AXIS2_QPID_DEFAULT_REQUEST_TIMEOUT;
-
- conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
-
- if(conf_ctx)
- {
- property = axis2_conf_ctx_get_property(conf_ctx, env,
- AXIS2_AMQP_CONF_CTX_PROPERTY_REQUEST_TIMEOUT);
-
- if(property)
- {
- value = axutil_property_get_value(property, env);
-
- if(value)
- {
- request_timeout = *(int*)value;
- }
- }
- }
-
- return request_timeout;
-}
-
-AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-axis2_amqp_util_msg_ctx_get_server_side(
- axis2_msg_ctx_t* msg_ctx,
- const axutil_env_t* env)
-{
- axis2_conf_ctx_t* conf_ctx = NULL;
- axis2_bool_t is_server = AXIS2_FALSE;
-
- conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
-
- if(conf_ctx)
- {
- is_server = axis2_amqp_util_conf_ctx_get_server_side(conf_ctx, env);
- }
-
- return is_server;
-}
-
-AXIS2_EXTERN void AXIS2_CALL
-axis2_amqp_response_free(
- axis2_amqp_response_t* response,
- const axutil_env_t* env)
-{
- if(response)
- {
- if(response->data)
- {
- AXIS2_FREE(env->allocator, response->data);
- }
-
- if(response->content_type)
- {
- AXIS2_FREE(env->allocator, response->content_type);
- }
-
- AXIS2_FREE(env->allocator, response);
- }
-}
-
-AXIS2_EXTERN void AXIS2_CALL
-axis2_amqp_destination_info_free(
- axis2_amqp_destination_info_t* destination_info,
- const axutil_env_t* env)
-{
- if(destination_info)
- {
- if(destination_info->broker_ip)
- {
- AXIS2_FREE(env->allocator, destination_info->broker_ip);
- }
-
- if(destination_info->queue_name)
- {
- AXIS2_FREE(env->allocator, destination_info->queue_name);
- }
-
- AXIS2_FREE(env->allocator, destination_info);
- }
-}
-
+/*
+ * 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.
+ */
+
+#include <axiom.h>
+#include <axiom_mime_parser.h>
+#include <axis2_util.h>
+#include <axis2_addr.h>
+#include <axutil_http_chunked_stream.h>
+#include <axis2_amqp_defines.h>
+#include <axis2_amqp_util.h>
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+axis2_amqp_util_get_in_desc_conf_value_string(
+ axis2_transport_in_desc_t* in_desc,
+ const axutil_env_t* env,
+ const axis2_char_t* param_name)
+{
+ axutil_param_t* param = NULL;
+ axis2_char_t* value = NULL;
+
+ param = (axutil_param_t*)axutil_param_container_get_param(
+ axis2_transport_in_desc_param_container(in_desc, env), env, param_name);
+ if(param)
+ {
+ value = axutil_param_get_value(param, env);
+ }
+
+ return value;
+}
+
+AXIS2_EXTERN int AXIS2_CALL
+axis2_amqp_util_get_in_desc_conf_value_int(
+ axis2_transport_in_desc_t* in_desc,
+ const axutil_env_t* env,
+ const axis2_char_t* param_name)
+{
+ axis2_char_t* value_str = NULL;
+ int value = AXIS2_QPID_NULL_CONF_INT;
+
+ value_str = axis2_amqp_util_get_in_desc_conf_value_string(in_desc, env, param_name);
+ if(value_str)
+ {
+ value = atoi(value_str);
+ }
+
+ return value;
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+axis2_amqp_util_get_out_desc_conf_value_string(
+ axis2_transport_out_desc_t* out_desc,
+ const axutil_env_t* env,
+ const axis2_char_t* param_name)
+{
+ axutil_param_t* param = NULL;
+ axis2_char_t* value = NULL;
+
+ param = (axutil_param_t*)axutil_param_container_get_param(
+ axis2_transport_out_desc_param_container(out_desc, env), env, param_name);
+ if(param)
+ {
+ value = axutil_param_get_value(param, env);
+ }
+
+ return value;
+}
+
+AXIS2_EXTERN int AXIS2_CALL
+axis2_amqp_util_get_out_desc_conf_value_int(
+ axis2_transport_out_desc_t* out_desc,
+ const axutil_env_t* env,
+ const axis2_char_t* param_name)
+{
+ axis2_char_t* value_str = NULL;
+ int value = AXIS2_QPID_NULL_CONF_INT;
+
+ value_str = axis2_amqp_util_get_out_desc_conf_value_string(out_desc, env, param_name);
+ if(value_str)
+ {
+ value = atoi(value_str);
+ }
+
+ return value;
+}
+
+AXIS2_EXTERN axiom_soap_envelope_t* AXIS2_CALL
+axis2_amqp_util_get_soap_envelope(
+ axis2_amqp_response_t* response,
+ const axutil_env_t* env,
+ axis2_msg_ctx_t* msg_ctx)
+{
+ axiom_xml_reader_t* xml_reader = NULL;
+ axiom_stax_builder_t* stax_builder = NULL;
+ axiom_soap_builder_t* soap_builder = NULL;
+ axiom_soap_envelope_t* soap_envelope = NULL;
+ const axis2_char_t* soap_ns_uri = NULL;
+ axis2_char_t *soap_body_str = NULL;
+ int soap_body_len = 0;
+ axis2_bool_t is_mtom = AXIS2_FALSE;
+ axutil_hash_t *binary_data_map = NULL;
+ axis2_bool_t is_soap_11 = AXIS2_FALSE;
+
+ if(!response || !response->data || !response->content_type)
+ {
+ return NULL;
+ }
+
+ is_soap_11 = axis2_msg_ctx_get_is_soap_11(msg_ctx, env);
+
+ /* Handle MTOM */
+ if(strstr(response->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED))
+ {
+ axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env,
+ response->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY);
+
+ if(mime_boundary)
+ {
+ axiom_mime_parser_t *mime_parser = NULL;
+ int soap_body_len = 0;
+ axutil_param_t *buffer_size_param = NULL;
+ axutil_param_t *max_buffers_param = NULL;
+ axutil_param_t *attachment_dir_param = NULL;
+ axis2_char_t *value_size = NULL;
+ axis2_char_t *value_num = NULL;
+ axis2_char_t *value_dir = NULL;
+ int size = 0;
+ int num = 0;
+
+ mime_parser = axiom_mime_parser_create(env);
+
+ buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE);
+
+ if(buffer_size_param)
+ {
+ value_size = (axis2_char_t *)axutil_param_get_value(buffer_size_param, env);
+
+ if(value_size)
+ {
+ size = atoi(value_size);
+ axiom_mime_parser_set_buffer_size(mime_parser, env, size);
+ }
+ }
+
+ max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS);
+
+ if(max_buffers_param)
+ {
+ value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env);
+
+ if(value_num)
+ {
+ num = atoi(value_num);
+ axiom_mime_parser_set_max_buffers(mime_parser, env, num);
+ }
+ }
+
+ attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR);
+
+ if(attachment_dir_param)
+ {
+ value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env);
+
+ if(value_dir)
+ {
+ axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir);
+ }
+ }
+
+ if(mime_parser)
+ {
+ axis2_callback_info_t* callback_ctx = NULL;
+ axutil_stream_t* stream = NULL;
+
+ callback_ctx = (axis2_callback_info_t*)AXIS2_MALLOC(env->allocator,
+ sizeof(axis2_callback_info_t));
+
+ stream = axutil_stream_create_basic(env);
+
+ if(stream)
+ {
+ axutil_stream_write(stream, env, response->data, response->length);
+ callback_ctx->env = env;
+ callback_ctx->in_stream = stream;
+ callback_ctx->content_length = response->length;
+ callback_ctx->unread_len = response->length;
+ callback_ctx->chunked_stream = NULL;
+ }
+
+ /*binary_data_map =
+ axiom_mime_parser_parse(mime_parser, env,
+ axis2_amqp_util_on_data_request,
+ (void*)callback_ctx,
+ mime_boundary);*/
+
+ if(!binary_data_map)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env);
+
+ soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env);
+
+ axutil_stream_free(stream, env);
+ AXIS2_FREE(env->allocator, callback_ctx);
+ axiom_mime_parser_free(mime_parser, env);
+ }
+
+ AXIS2_FREE(env->allocator, mime_boundary);
+ }
+
+ is_mtom = AXIS2_TRUE;
+ }
+ else
+ {
+ soap_body_str = response->data;
+ soap_body_len = axutil_strlen(response->data);
+ }
+
+ soap_body_len = axutil_strlen(soap_body_str);
+
+ xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL,
+ AXIS2_XML_PARSER_TYPE_BUFFER);
+ if(!xml_reader)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader");
+ return NULL;
+ }
+
+ stax_builder = axiom_stax_builder_create(env, xml_reader);
+ if(!stax_builder)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder");
+ return NULL;
+ }
+
+ soap_ns_uri = is_soap_11 ? AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI
+ : AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
+
+ soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri);
+ if(!soap_builder)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder");
+ return NULL;
+ }
+
+ if(binary_data_map)
+ {
+ axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map);
+ }
+
+ soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env);
+ return soap_envelope;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_amqp_util_conf_ctx_get_server_side(
+ axis2_conf_ctx_t* conf_ctx,
+ const axutil_env_t* env)
+{
+ axutil_property_t* property = NULL;
+ axis2_char_t* value = NULL;
+
+ property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_IS_SVR_SIDE);
+ if(!property)
+ return AXIS2_TRUE;
+
+ value = (axis2_char_t*)axutil_property_get_value(property, env);
+ if(!value)
+ return AXIS2_TRUE;
+
+ return (axutil_strcmp(value, AXIS2_VALUE_TRUE) == 0) ? AXIS2_TRUE : AXIS2_FALSE;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+axis2_amqp_util_get_value_from_content_type(
+ const axutil_env_t * env,
+ const axis2_char_t * content_type,
+ const axis2_char_t * key)
+{
+ axis2_char_t *tmp = NULL;
+ axis2_char_t *tmp_content_type = NULL;
+ axis2_char_t *tmp2 = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, content_type, NULL);
+ AXIS2_PARAM_CHECK(env->error, key, NULL);
+
+ tmp_content_type = axutil_strdup(env, content_type);
+
+ if(!tmp_content_type)
+ {
+ return NULL;
+ }
+
+ tmp = strstr(tmp_content_type, key);
+
+ if(!tmp)
+ {
+ AXIS2_FREE(env->allocator, tmp_content_type);
+ return NULL;
+ }
+
+ tmp = strchr(tmp, AXIS2_AMQP_EQ);
+ tmp2 = strchr(tmp, AXIS2_AMQP_SEMI_COLON);
+
+ if(tmp2)
+ {
+ *tmp2 = AXIS2_AMQP_ESC_NULL;
+ }
+
+ if(!tmp)
+ {
+ AXIS2_FREE(env->allocator, tmp_content_type);
+ return NULL;
+ }
+
+ tmp2 = axutil_strdup(env, tmp + 1);
+
+ AXIS2_FREE(env->allocator, tmp_content_type);
+
+ if(*tmp2 == AXIS2_AMQP_DOUBLE_QUOTE)
+ {
+ tmp = tmp2;
+ tmp2 = axutil_strdup(env, tmp + 1);
+ tmp2[strlen(tmp2) - 1] = AXIS2_AMQP_ESC_NULL;
+
+ if(tmp)
+ {
+ AXIS2_FREE(env->allocator, tmp);
+ tmp = NULL;
+ }
+ }
+
+ /* handle XOP */
+ if(*tmp2 == AXIS2_AMQP_B_SLASH && *(tmp2 + 1) == '\"')
+ {
+ tmp = tmp2;
+ tmp2 = axutil_strdup(env, tmp + 2);
+ tmp2[strlen(tmp2) - 3] = AXIS2_AMQP_ESC_NULL;
+
+ if(tmp)
+ {
+ AXIS2_FREE(env->allocator, tmp);
+ tmp = NULL;
+ }
+ }
+
+ return tmp2;
+}
+
+AXIS2_EXTERN int AXIS2_CALL
+axis2_amqp_util_on_data_request(
+ char* buffer,
+ int size,
+ void* ctx)
+{
+ const axutil_env_t* env = NULL;
+ int len = -1;
+ axis2_callback_info_t* cb_ctx = (axis2_callback_info_t*)ctx;
+ axutil_stream_t* in_stream = NULL;
+
+ if(!buffer || !ctx)
+ {
+ return 0;
+ }
+
+ if(cb_ctx->unread_len <= 0 && -1 != cb_ctx->content_length)
+ {
+ return 0;
+ }
+
+ env = ((axis2_callback_info_t*)ctx)->env;
+
+ in_stream = (axutil_stream_t*)((axis2_callback_info_t *)ctx)->in_stream;
+ --size; /* reserve space to insert trailing null */
+
+ len = axutil_stream_read(in_stream, env, buffer, size);
+
+ if(len > 0)
+ {
+ buffer[len] = AXIS2_AMQP_ESC_NULL;
+ ((axis2_callback_info_t*)ctx)->unread_len -= len;
+ }
+ else if(len == 0)
+ {
+ ((axis2_callback_info_t*)ctx)->unread_len = 0;
+ }
+
+ return len;
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+axis2_amqp_util_conf_ctx_get_dual_channel_queue_name(
+ axis2_conf_ctx_t* conf_ctx,
+ const axutil_env_t* env)
+{
+ axutil_property_t* property = NULL;
+ axis2_char_t* queue_name = NULL;
+ axis2_char_t* value = NULL;
+
+ /* Get property */
+ property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_QUEUE_NAME);
+ if(!property) /* Very first call */
+ {
+ property = axutil_property_create(env);
+
+ axis2_conf_ctx_set_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_QUEUE_NAME,
+ property);
+ }
+
+ /* Get queue name */
+ value = (axis2_char_t*)axutil_property_get_value(property, env);
+
+ /* AMQP listener and the sender are the two parties that are
+ * interested in the queue. Either party can create the queue.
+ * If the queue is already created by one party, "value" is
+ * not NULL. If "value" is NULL, that mean the caller of
+ * this method is supposed to create the queue */
+ if(value)
+ {
+ queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator, axutil_strlen(value) + 1);
+ strcpy(queue_name, value);
+
+ /*axutil_property_set_value(property, env, NULL);*/
+ }
+ else
+ {
+ /* Create new queue name */
+ queue_name = axutil_stracat(env, AXIS2_AMQP_TEMP_QUEUE_NAME_PREFIX, axutil_uuid_gen(env));
+
+ /* Put queue name in the conf_ctx so that the sender will know */
+ axutil_property_set_value(property, env, (void*)queue_name);
+ }
+
+ return queue_name;
+}
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+axis2_amqp_util_conf_ctx_get_qpid_broker_ip(
+ axis2_conf_ctx_t* conf_ctx,
+ const axutil_env_t* env)
+{
+ axutil_property_t* property = NULL;
+ void* value = NULL;
+ axis2_char_t* broker_ip = AXIS2_QPID_DEFAULT_BROKER_IP;
+
+ property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP);
+
+ if(property)
+ {
+ value = axutil_property_get_value(property, env);
+
+ if(value)
+ {
+ broker_ip = (axis2_char_t*)value;
+ }
+ }
+
+ return broker_ip;
+}
+
+AXIS2_EXTERN int AXIS2_CALL
+axis2_amqp_util_conf_ctx_get_qpid_broker_port(
+ axis2_conf_ctx_t* conf_ctx,
+ const axutil_env_t* env)
+{
+ axutil_property_t* property = NULL;
+ void* value = NULL;
+ int broker_port = AXIS2_QPID_DEFAULT_BROKER_PORT;
+
+ property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT);
+
+ if(property)
+ {
+ value = axutil_property_get_value(property, env);
+
+ if(value)
+ {
+ broker_port = *(int*)value;
+ }
+ }
+
+ return broker_port;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_amqp_util_msg_ctx_get_use_separate_listener(
+ axis2_msg_ctx_t* msg_ctx,
+ const axutil_env_t* env)
+{
+ axutil_property_t* property = NULL;
+ axis2_char_t* value = NULL;
+ axis2_bool_t use_separate_listener = AXIS2_FALSE;
+
+ property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_USE_SEPARATE_LISTENER);
+
+ if(property)
+ {
+ value = (axis2_char_t*)axutil_property_get_value(property, env);
+
+ if(value && (axutil_strcmp(AXIS2_VALUE_TRUE, value) == 0))
+ {
+ use_separate_listener = AXIS2_TRUE;
+ }
+ }
+
+ return use_separate_listener;
+}
+
+AXIS2_EXTERN axis2_amqp_destination_info_t* AXIS2_CALL
+axis2_amqp_util_msg_ctx_get_destination_info(
+ axis2_msg_ctx_t* msg_ctx,
+ const axutil_env_t* env)
+{
+ /* The destination URI that is expected by this method
+ * should be of one of the following formats
+ * 1. amqp://IP:PORT/services/SERVICE_NAME
+ * 2. jms:/SERVICE_NAME?java.naming.provider.url=tcp://IP:PORT...
+ * 3. TempQueue... */
+
+ axis2_endpoint_ref_t* endpoint_ref = NULL;
+ axis2_amqp_destination_info_t* destination_info = NULL;
+
+ destination_info = (axis2_amqp_destination_info_t*)AXIS2_MALLOC(env->allocator,
+ sizeof(axis2_amqp_destination_info_t));
+
+ destination_info->broker_ip = NULL;
+ destination_info->broker_port = AXIS2_QPID_NULL_CONF_INT;
+ destination_info->queue_name = NULL;
+
+ endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);
+
+ if(endpoint_ref)
+ {
+ const axis2_char_t* endpoint_address_original = NULL;
+ axis2_char_t* endpoint_address = NULL;
+ char* substr = NULL;
+ char* token = NULL;
+ endpoint_address_original = axis2_endpoint_ref_get_address(endpoint_ref, env);
+
+ if(!endpoint_address_original)
+ return NULL;
+
+ endpoint_address = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t)
+ * axutil_strlen(endpoint_address_original)) + 1);
+ strcpy((char*)endpoint_address, (char*)endpoint_address_original);
+
+ if((substr = strstr(endpoint_address, AXIS2_AMQP_EPR_PREFIX))) /* Start with amqp: */
+ {
+ if(strstr(endpoint_address, AXIS2_AMQP_EPR_ANON_SERVICE_NAME))
+ {
+ /* Server reply to dual-channel client */
+ axutil_property_t* property = NULL;
+ property = axis2_msg_ctx_get_property(msg_ctx, env,
+ AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO);
+
+ if(property)
+ {
+ axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property,
+ env);
+
+ if(queue_name)
+ {
+ destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
+ (sizeof(axis2_char_t) * strlen(queue_name)) + 1);
+ strcpy(destination_info->queue_name, queue_name);
+ }
+ }
+ }
+ else
+ {
+ substr += strlen(AXIS2_AMQP_EPR_PREFIX) + 2; /* 2 -> "//" */
+ if(substr) /* IP:PORT/services/SERVICE_NAME */
+ {
+ token = strtok(substr, ":");
+ if(token) /* IP */
+ {
+ axis2_char_t* broker_ip = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
+ (sizeof(axis2_char_t) * strlen(token)) + 1);
+ strcpy(broker_ip, token);
+ destination_info->broker_ip = broker_ip;
+
+ token = strtok(NULL, "/"); /* PORT */
+ if(token)
+ {
+ destination_info->broker_port = atoi(token);
+
+ token = strtok(NULL, "#"); /* ... services/SERVICE_NAME */
+ if(token)
+ {
+ if((substr = strstr(token, AXIS2_AMQP_EPR_SERVICE_PREFIX)))
+ {
+ substr += strlen(AXIS2_AMQP_EPR_SERVICE_PREFIX) + 1; /* 1 -> "/" */
+ if(substr)
+ {
+ axis2_char_t* queue_name = (axis2_char_t*)AXIS2_MALLOC(
+ env->allocator, (sizeof(axis2_char_t) * strlen(substr))
+ + 1);
+ strcpy(queue_name, substr);
+ destination_info->queue_name = queue_name;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if(0 == strcmp(endpoint_address, AXIS2_WSA_ANONYMOUS_URL)) /* Required to work with Sandesha2 */
+ {
+ axutil_property_t* property = NULL;
+ property = axis2_msg_ctx_get_property(msg_ctx, env,
+ AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO);
+
+ if(property)
+ {
+ axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property, env);
+
+ if(queue_name)
+ {
+ destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
+ (sizeof(axis2_char_t) * strlen(queue_name)) + 1);
+ strcpy(destination_info->queue_name, queue_name);
+ }
+ }
+ }
+ else if((substr = strstr(endpoint_address, "jms:/")) && (substr == endpoint_address))
+ {
+
+ }
+
+ AXIS2_FREE(env->allocator, endpoint_address);
+ }
+ else
+ {
+ /* Single-channel blocking */
+ axutil_property_t* property = NULL;
+ property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO);
+
+ if(property)
+ {
+ axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property, env);
+
+ if(queue_name)
+ {
+ destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
+ (sizeof(axis2_char_t) * strlen(queue_name)) + 1);
+ strcpy(destination_info->queue_name, queue_name);
+ }
+ }
+ }
+
+ /* Get broker IP/Port from conf_ctx if they are not
+ * found in the destination URI */
+ if(!destination_info->broker_ip)
+ {
+ axis2_conf_ctx_t* conf_ctx = NULL;
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if(conf_ctx)
+ {
+ axutil_property_t* property = NULL;
+ property = axis2_conf_ctx_get_property(conf_ctx, env,
+ AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP);
+
+ if(property)
+ {
+ axis2_char_t* broker_ip = (axis2_char_t*)axutil_property_get_value(property, env);
+
+ if(broker_ip)
+ {
+ destination_info->broker_ip = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
+ (sizeof(axis2_char_t) * strlen(broker_ip)) + 1);
+ strcpy(destination_info->broker_ip, broker_ip);
+ }
+ }
+
+ }
+ }
+
+ if(AXIS2_QPID_NULL_CONF_INT == destination_info->broker_port)
+ {
+ axis2_conf_ctx_t* conf_ctx = NULL;
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if(conf_ctx)
+ {
+ axutil_property_t* property = NULL;
+ property = axis2_conf_ctx_get_property(conf_ctx, env,
+ AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT);
+
+ if(property)
+ {
+ void* value = axutil_property_get_value(property, env);
+
+ if(value)
+ {
+ destination_info->broker_port = *(int*)value;
+ }
+ }
+ }
+ }
+
+ return destination_info;
+}
+
+AXIS2_EXTERN int AXIS2_CALL
+axis2_amqp_util_msg_ctx_get_request_timeout(
+ axis2_msg_ctx_t* msg_ctx,
+ const axutil_env_t* env)
+{
+ axis2_conf_ctx_t* conf_ctx = NULL;
+ axutil_property_t* property = NULL;
+ void* value = NULL;
+ int request_timeout = AXIS2_QPID_DEFAULT_REQUEST_TIMEOUT;
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+
+ if(conf_ctx)
+ {
+ property = axis2_conf_ctx_get_property(conf_ctx, env,
+ AXIS2_AMQP_CONF_CTX_PROPERTY_REQUEST_TIMEOUT);
+
+ if(property)
+ {
+ value = axutil_property_get_value(property, env);
+
+ if(value)
+ {
+ request_timeout = *(int*)value;
+ }
+ }
+ }
+
+ return request_timeout;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_amqp_util_msg_ctx_get_server_side(
+ axis2_msg_ctx_t* msg_ctx,
+ const axutil_env_t* env)
+{
+ axis2_conf_ctx_t* conf_ctx = NULL;
+ axis2_bool_t is_server = AXIS2_FALSE;
+
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+
+ if(conf_ctx)
+ {
+ is_server = axis2_amqp_util_conf_ctx_get_server_side(conf_ctx, env);
+ }
+
+ return is_server;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_amqp_response_free(
+ axis2_amqp_response_t* response,
+ const axutil_env_t* env)
+{
+ if(response)
+ {
+ if(response->data)
+ {
+ AXIS2_FREE(env->allocator, response->data);
+ }
+
+ if(response->content_type)
+ {
+ AXIS2_FREE(env->allocator, response->content_type);
+ }
+
+ AXIS2_FREE(env->allocator, response);
+ }
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_amqp_destination_info_free(
+ axis2_amqp_destination_info_t* destination_info,
+ const axutil_env_t* env)
+{
+ if(destination_info)
+ {
+ if(destination_info->broker_ip)
+ {
+ AXIS2_FREE(env->allocator, destination_info->broker_ip);
+ }
+
+ if(destination_info->queue_name)
+ {
+ AXIS2_FREE(env->allocator, destination_info->queue_name);
+ }
+
+ AXIS2_FREE(env->allocator, destination_info);
+ }
+}
+
diff --git a/src/core/transport/amqp/util/axis2_amqp_util.h b/src/core/transport/amqp/util/axis2_amqp_util.h
index 0b3abbb..1a19c31 100644
--- a/src/core/transport/amqp/util/axis2_amqp_util.h
+++ b/src/core/transport/amqp/util/axis2_amqp_util.h
@@ -1,143 +1,143 @@
-/*
- * 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 AXIS2_AMQP_UTIL_H
-#define AXIS2_AMQP_UTIL_H
-
-#include <axis2_transport_in_desc.h>
-#include <axutil_param_container.h>
-#include <axiom_soap.h>
-#include <axis2_conf_ctx.h>
-#include <axutil_stream.h>
-#include <axis2_amqp_defines.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- typedef struct axis2_amqp_response
- {
- void* data;
- int length;
- axis2_char_t* content_type;
- } axis2_amqp_response_t;
-
- typedef struct axis2_amqp_destination_info
- {
- axis2_char_t* broker_ip;
- int broker_port;
- axis2_char_t* queue_name;
- } axis2_amqp_destination_info_t;
-
- AXIS2_EXTERN axis2_char_t* AXIS2_CALL
- axis2_amqp_util_get_in_desc_conf_value_string(
- axis2_transport_in_desc_t* in_desc,
- const axutil_env_t* env,
- const axis2_char_t* param_name);
-
- AXIS2_EXTERN int AXIS2_CALL
- axis2_amqp_util_get_in_desc_conf_value_int(
- axis2_transport_in_desc_t* in_desc,
- const axutil_env_t* env,
- const axis2_char_t* param_name);
-
- AXIS2_EXTERN axis2_char_t* AXIS2_CALL
- axis2_amqp_util_get_out_desc_conf_value_string(
- axis2_transport_out_desc_t* out_desc,
- const axutil_env_t* env,
- const axis2_char_t* param_name);
-
- AXIS2_EXTERN int AXIS2_CALL
- axis2_amqp_util_get_out_desc_conf_value_int(
- axis2_transport_out_desc_t* out_desc,
- const axutil_env_t* env,
- const axis2_char_t* param_name);
-
- AXIS2_EXTERN axiom_soap_envelope_t* AXIS2_CALL
- axis2_amqp_util_get_soap_envelope(
- axis2_amqp_response_t* response,
- const axutil_env_t* env,
- axis2_msg_ctx_t* msg_ctx);
-
- AXIS2_EXTERN axis2_bool_t AXIS2_CALL
- axis2_amqp_util_conf_ctx_get_server_side(
- axis2_conf_ctx_t* conf_ctx,
- const axutil_env_t* env);
-
- AXIS2_EXTERN axis2_char_t* AXIS2_CALL
- axis2_amqp_util_get_value_from_content_type(
- const axutil_env_t * env,
- const axis2_char_t * content_type,
- const axis2_char_t * key);
-
- AXIS2_EXTERN int AXIS2_CALL
- axis2_amqp_util_on_data_request(
- char *buffer,
- int size,
- void *ctx);
-
- AXIS2_EXTERN axis2_char_t* AXIS2_CALL
- axis2_amqp_util_conf_ctx_get_dual_channel_queue_name(
- axis2_conf_ctx_t* conf_ctx,
- const axutil_env_t* env);
-
- AXIS2_EXTERN axis2_char_t* AXIS2_CALL
- axis2_amqp_util_conf_ctx_get_qpid_broker_ip(
- axis2_conf_ctx_t* conf_ctx,
- const axutil_env_t* env);
-
- AXIS2_EXTERN int AXIS2_CALL
- axis2_amqp_util_conf_ctx_get_qpid_broker_port(
- axis2_conf_ctx_t* conf_ctx,
- const axutil_env_t* env);
-
- AXIS2_EXTERN axis2_bool_t AXIS2_CALL
- axis2_amqp_util_msg_ctx_get_use_separate_listener(
- axis2_msg_ctx_t* msg_ctx,
- const axutil_env_t* env);
-
- AXIS2_EXTERN axis2_amqp_destination_info_t* AXIS2_CALL
- axis2_amqp_util_msg_ctx_get_destination_info(
- axis2_msg_ctx_t* msg_ctx,
- const axutil_env_t* env);
-
- AXIS2_EXTERN int AXIS2_CALL
- axis2_amqp_util_msg_ctx_get_request_timeout(
- axis2_msg_ctx_t* msg_ctx,
- const axutil_env_t* env);
-
- AXIS2_EXTERN axis2_bool_t AXIS2_CALL
- axis2_amqp_util_msg_ctx_get_server_side(
- axis2_msg_ctx_t* msg_ctx,
- const axutil_env_t* env);
-
- AXIS2_EXTERN void AXIS2_CALL
- axis2_amqp_response_free(
- axis2_amqp_response_t* response,
- const axutil_env_t* env);
-
- AXIS2_EXTERN void AXIS2_CALL
- axis2_amqp_destination_info_free(
- axis2_amqp_destination_info_t* destination_info,
- const axutil_env_t* env);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+/*
+ * 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 AXIS2_AMQP_UTIL_H
+#define AXIS2_AMQP_UTIL_H
+
+#include <axis2_transport_in_desc.h>
+#include <axutil_param_container.h>
+#include <axiom_soap.h>
+#include <axis2_conf_ctx.h>
+#include <axutil_stream.h>
+#include <axis2_amqp_defines.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct axis2_amqp_response
+ {
+ void* data;
+ int length;
+ axis2_char_t* content_type;
+ } axis2_amqp_response_t;
+
+ typedef struct axis2_amqp_destination_info
+ {
+ axis2_char_t* broker_ip;
+ int broker_port;
+ axis2_char_t* queue_name;
+ } axis2_amqp_destination_info_t;
+
+ AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+ axis2_amqp_util_get_in_desc_conf_value_string(
+ axis2_transport_in_desc_t* in_desc,
+ const axutil_env_t* env,
+ const axis2_char_t* param_name);
+
+ AXIS2_EXTERN int AXIS2_CALL
+ axis2_amqp_util_get_in_desc_conf_value_int(
+ axis2_transport_in_desc_t* in_desc,
+ const axutil_env_t* env,
+ const axis2_char_t* param_name);
+
+ AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+ axis2_amqp_util_get_out_desc_conf_value_string(
+ axis2_transport_out_desc_t* out_desc,
+ const axutil_env_t* env,
+ const axis2_char_t* param_name);
+
+ AXIS2_EXTERN int AXIS2_CALL
+ axis2_amqp_util_get_out_desc_conf_value_int(
+ axis2_transport_out_desc_t* out_desc,
+ const axutil_env_t* env,
+ const axis2_char_t* param_name);
+
+ AXIS2_EXTERN axiom_soap_envelope_t* AXIS2_CALL
+ axis2_amqp_util_get_soap_envelope(
+ axis2_amqp_response_t* response,
+ const axutil_env_t* env,
+ axis2_msg_ctx_t* msg_ctx);
+
+ AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+ axis2_amqp_util_conf_ctx_get_server_side(
+ axis2_conf_ctx_t* conf_ctx,
+ const axutil_env_t* env);
+
+ AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+ axis2_amqp_util_get_value_from_content_type(
+ const axutil_env_t * env,
+ const axis2_char_t * content_type,
+ const axis2_char_t * key);
+
+ AXIS2_EXTERN int AXIS2_CALL
+ axis2_amqp_util_on_data_request(
+ char *buffer,
+ int size,
+ void *ctx);
+
+ AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+ axis2_amqp_util_conf_ctx_get_dual_channel_queue_name(
+ axis2_conf_ctx_t* conf_ctx,
+ const axutil_env_t* env);
+
+ AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+ axis2_amqp_util_conf_ctx_get_qpid_broker_ip(
+ axis2_conf_ctx_t* conf_ctx,
+ const axutil_env_t* env);
+
+ AXIS2_EXTERN int AXIS2_CALL
+ axis2_amqp_util_conf_ctx_get_qpid_broker_port(
+ axis2_conf_ctx_t* conf_ctx,
+ const axutil_env_t* env);
+
+ AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+ axis2_amqp_util_msg_ctx_get_use_separate_listener(
+ axis2_msg_ctx_t* msg_ctx,
+ const axutil_env_t* env);
+
+ AXIS2_EXTERN axis2_amqp_destination_info_t* AXIS2_CALL
+ axis2_amqp_util_msg_ctx_get_destination_info(
+ axis2_msg_ctx_t* msg_ctx,
+ const axutil_env_t* env);
+
+ AXIS2_EXTERN int AXIS2_CALL
+ axis2_amqp_util_msg_ctx_get_request_timeout(
+ axis2_msg_ctx_t* msg_ctx,
+ const axutil_env_t* env);
+
+ AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+ axis2_amqp_util_msg_ctx_get_server_side(
+ axis2_msg_ctx_t* msg_ctx,
+ const axutil_env_t* env);
+
+ AXIS2_EXTERN void AXIS2_CALL
+ axis2_amqp_response_free(
+ axis2_amqp_response_t* response,
+ const axutil_env_t* env);
+
+ AXIS2_EXTERN void AXIS2_CALL
+ axis2_amqp_destination_info_free(
+ axis2_amqp_destination_info_t* destination_info,
+ const axutil_env_t* env);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/core/transport/http/receiver/http_receiver.c b/src/core/transport/http/receiver/http_receiver.c
index 5c071e5..e2cbec2 100644
--- a/src/core/transport/http/receiver/http_receiver.c
+++ b/src/core/transport/http/receiver/http_receiver.c
@@ -149,8 +149,8 @@ axis2_http_server_create(
if(repo)
{
- axis2_transport_in_desc_t *transport_in = NULL;
- axis2_conf_t *conf = NULL;
+ axis2_transport_in_desc_t *transport_in = NULL;
+ axis2_conf_t *conf = NULL;
axis2_transport_receiver_t *receiver = NULL;
/**
* We first create a private conf ctx which is owned by this server
@@ -204,8 +204,8 @@ axis2_http_server_create_with_file(
if(file)
{
- axis2_transport_in_desc_t *transport_in = NULL;
- axis2_conf_t *conf = NULL;
+ axis2_transport_in_desc_t *transport_in = NULL;
+ axis2_conf_t *conf = NULL;
axis2_transport_receiver_t *receiver = NULL;
/**
* We first create a private conf ctx which is owned by this server
@@ -329,8 +329,8 @@ axis2_http_server_start(
server_impl->is_application_client_side);
axis2_http_worker_set_svr_port(worker, env, server_impl->port);
{/** Obtain server IP and set it
- axis2_transport_in_desc_t *transport_in = NULL;
- axis2_conf_t *conf = NULL;
+ axis2_transport_in_desc_t *transport_in = NULL;
+ axis2_conf_t *conf = NULL;
axis2_transport_receiver_t *receiver = NULL;
conf = axis2_conf_ctx_get_conf(server_impl->conf_ctx_private, env);
transport_in = axis2_conf_get_transport_in(conf, env, AXIS2_TRANSPORT_ENUM_HTTP);
diff --git a/src/core/transport/http/server/IIS/axis2_iis_worker.h b/src/core/transport/http/server/IIS/axis2_iis_worker.h
index f9b6292..aa56567 100644
--- a/src/core/transport/http/server/IIS/axis2_iis_worker.h
+++ b/src/core/transport/http/server/IIS/axis2_iis_worker.h
@@ -1,62 +1,62 @@
-
-/*
- * 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 AXIS2_APACHE2_WORKER_H
-#define AXIS2_APACHE2_WORKER_H
-
-#include <axis2_const.h>
-#include <axis2_defines.h>
-#include <axutil_env.h>
-#include <axis2_conf_ctx.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-
-#endif /*
- */
-
-typedef struct axis2_iis_worker axis2_iis_worker_t;
-
-int server_version;
-
-int AXIS2_CALL
- axis2_iis_worker_process_request(
- axis2_iis_worker_t * iis_worker,
- const axutil_env_t * env,
- void *r);
-
-
-void AXIS2_CALL
- axis2_iis_worker_free(
- axis2_iis_worker_t * iis_worker,
- const axutil_env_t * env);
-
-
-axis2_iis_worker_t * AXIS2_CALL
- axis2_iis_worker_create(
- const axutil_env_t * env,
- axis2_char_t * repo_path);
-
-
-#ifdef __cplusplus
-}
-#endif /*
- */
-
-#endif /* AXIS2_IIS_WORKER_H */
+
+/*
+ * 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 AXIS2_APACHE2_WORKER_H
+#define AXIS2_APACHE2_WORKER_H
+
+#include <axis2_const.h>
+#include <axis2_defines.h>
+#include <axutil_env.h>
+#include <axis2_conf_ctx.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+
+#endif /*
+ */
+
+typedef struct axis2_iis_worker axis2_iis_worker_t;
+
+int server_version;
+
+int AXIS2_CALL
+ axis2_iis_worker_process_request(
+ axis2_iis_worker_t * iis_worker,
+ const axutil_env_t * env,
+ void *r);
+
+
+void AXIS2_CALL
+ axis2_iis_worker_free(
+ axis2_iis_worker_t * iis_worker,
+ const axutil_env_t * env);
+
+
+axis2_iis_worker_t * AXIS2_CALL
+ axis2_iis_worker_create(
+ const axutil_env_t * env,
+ axis2_char_t * repo_path);
+
+
+#ifdef __cplusplus
+}
+#endif /*
+ */
+
+#endif /* AXIS2_IIS_WORKER_H */
diff --git a/src/core/transport/http/server/IIS/axis2_isapi_plugin.c b/src/core/transport/http/server/IIS/axis2_isapi_plugin.c
index eccfd1c..e647f28 100644
--- a/src/core/transport/http/server/IIS/axis2_isapi_plugin.c
+++ b/src/core/transport/http/server/IIS/axis2_isapi_plugin.c
@@ -1,42 +1,42 @@
-
-/*
- * 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.
- */
-
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <httpfilt.h>
-#include <httpext.h>
-
-#include "axis2_iis_constants.h"
-#include "axis2_iis_worker.h"
-
+
+/*
+ * 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.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <httpfilt.h>
+#include <httpext.h>
+
+#include "axis2_iis_constants.h"
+#include "axis2_iis_worker.h"
+
/* Axis headers */
#include <axutil_error_default.h>
#include <axutil_log_default.h>
#include <axutil_thread_pool.h>
#include <axiom_xml_reader.h>
-#include <axutil_log.h>
-
-#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0500
-#endif
-
+#include <axutil_log.h>
+
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0500
+#endif
+
#define AXIS2_IIS_LOG_FILE_TAG "log_file"
#define AXIS2_IIS_LOG_LEVEL_TAG "log_level"
#define AXIS2_IIS_REPO_PATH_TAG "axis2c_home"
@@ -68,19 +68,19 @@ static axis2_char_t log_file[MAX_FILE_PATH];
static axutil_log_levels_t log_level = AXIS2_LOG_LEVEL_CRITICAL;
/* Path variables */
-static char szOriginalPath[_MAX_PATH + 1];
+static char szOriginalPath[_MAX_PATH + 1];
static char szPath[_MAX_PATH + 1];
-axis2_char_t general_error[] = "<html>\r\n"
- "<head><title> An IIS server error occurred. </title></head>\r\n"
- "<h1> An IIS server error occurred </h1>\r\n"
- "<hr>\r\n"
+axis2_char_t general_error[] = "<html>\r\n"
+ "<head><title> An IIS server error occurred. </title></head>\r\n"
+ "<h1> An IIS server error occurred </h1>\r\n"
+ "<hr>\r\n"
"An error occurred in IIS while processing this request.</hr></html>";
-axis2_char_t initializing_error[] = "<html>\r\n"
- "<head><title> An IIS server error occurred. </title></head>\r\n"
- "<h1> An IIS server error occurred </h1>\r\n"
- "<hr>\r\n"
+axis2_char_t initializing_error[] = "<html>\r\n"
+ "<head><title> An IIS server error occurred. </title></head>\r\n"
+ "<h1> An IIS server error occurred </h1>\r\n"
+ "<hr>\r\n"
"An error occurred while initilizing Axis2/C.</hr></html>";
@@ -103,243 +103,243 @@ static axis2_status_t AXIS2_CALL get_registry_config_parameter(
* Parse the given string and return the corresponding log_level
*/
axutil_log_levels_t AXIS2_CALL axis2_iis_parse_log_level(char level[]);
-
-/*
- * Initialize axis. This function is called in the begining of the module loading.
- * It initializes the axis by reading values from the configuration and creating the
- * required structures for the axis2c
-*/
-axis2_status_t AXIS2_CALL init_axis2();
-
-/*
- * This is the function to be called after the processing
- * is over for non Axis2 requets
- */
-VOID
-WINAPI
-ExecUrlCompletion (
- EXTENSION_CONTROL_BLOCK * pecb,
- PVOID pContext,
- DWORD cbIO,
- DWORD dwError
- );
-
-/*
- * If somethign went wrong in the IIS server when
- * we are proccessing we send this
- */
-BOOL
-send_error(
- EXTENSION_CONTROL_BLOCK * pecb,
- CHAR error[]);
-
-axis2_status_t AXIS2_CALL init_axis2();
-
-BOOL
-WINAPI
-GetExtensionVersion(HSE_VERSION_INFO * pVer)
-{
- pVer->dwExtensionVersion = MAKELONG( HSE_VERSION_MINOR,
- HSE_VERSION_MAJOR);
- strncpy( pVer->lpszExtensionDesc,
- "WildCardMap Sample ISAPI Extension", HSE_MAX_EXT_DLL_NAME_LEN );
-
- pVer->lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN-1] = '\0';
- server_version = 5;
- return TRUE;
-}
-
-DWORD
-WINAPI
-HttpExtensionProc(EXTENSION_CONTROL_BLOCK * pecb)
-
-{
- HSE_EXEC_URL_INFO ExecUrlInfo;
- DWORD cbData = INTERNET_MAX_URL_LENGTH;
- char url[INTERNET_MAX_URL_LENGTH];
- axis2_bool_t is_for_us = AXIS2_TRUE;
-
- /* Get the URL */
- if ( pecb->GetServerVariable( pecb->ConnID,
- "URL",
- url,
- &cbData ) == FALSE )
- {
- return HSE_STATUS_ERROR;
- }
-
- if (!is_inited)
- {
- DWORD dwBufferSize = 0;
- axis2_char_t server_software[256];
- axis2_char_t *version = NULL;
-
- ZeroMemory(szOriginalPath, sizeof szOriginalPath);
- dwBufferSize = sizeof szOriginalPath;
-
-#if _WIN32_WINNT >= 0x0502
- GetDllDirectory( dwBufferSize, szOriginalPath );
-#else
- GetCurrentDirectory( dwBufferSize, szOriginalPath );
-#endif
- ZeroMemory(szPath, sizeof szPath);
- dwBufferSize = sizeof szPath;
- /* Get the current physical paht */
- if (pecb->GetServerVariable(pecb->ConnID, "APPL_PHYSICAL_PATH", szPath, &dwBufferSize) == FALSE)
- {
- send_error(pecb, initializing_error);
- return HSE_STATUS_ERROR;
- }
- /* Retrieve the server version */
- dwBufferSize = 32;
- if (pecb->GetServerVariable(pecb->ConnID, "SERVER_SOFTWARE", server_software, &dwBufferSize) == FALSE)
- {
- send_error(pecb, initializing_error);
- return HSE_STATUS_ERROR;
- }
- version = axutil_strchr(server_software, '/');
- if (version)
- {
- server_version = atoi(version + 1);
- }
-#if _WIN32_WINNT >= 0x0502
- SetDllDirectory( szPath );
-#else
- SetCurrentDirectory( szPath );
-#endif
- /* If we haven't initialized axis2/c before initialization failed */
- if (AXIS2_FAILURE == init_axis2())
- {
- send_error(pecb, initializing_error);
- return HSE_STATUS_ERROR;
- }
-#if _WIN32_WINNT >= 0x0502
- SetDllDirectory( szOriginalPath );
-#else
- SetCurrentDirectory( szOriginalPath );
-#endif
- }
-
- /* Check weather we have a request for Axis2/C */
- if (server_version >= 6 && strlen(url) >= strlen(axis2_location))
- {
- int i = 0;
- is_for_us = AXIS2_TRUE;
- while (axis2_location[i] != '\0')
- {
- if (axis2_location[i] != (url)[i]) {
- is_for_us = AXIS2_FALSE;
- break;
- }
- i++;
- }
- if (url[i] != '/' && url[i] != '\0')
- {
- is_for_us = AXIS2_FALSE;
- }
- }
-
- if (is_for_us)
- {
- /* Windows cannot find the correct dlls unless the path is set*/
-#if _WIN32_WINNT >= 0x0502
- SetDllDirectory( szPath );
-#else
- SetCurrentDirectory( szPath );
-#endif
- pecb->dwHttpStatusCode = HTTP_INTERNAL_SERVER_ERROR;
- /* We are sure that worker is not NULL since it is NULL init_axis2 would have failed */
- axis2_iis_worker_process_request(axis2_worker, axutil_env, pecb);
-
- /* Windows cannot find the correct dlls unless the dir is set
- but we want to reset to previous dir after the load */
-#if _WIN32_WINNT >= 0x0502
- SetDllDirectory( szOriginalPath );
-#else
- SetCurrentDirectory( szOriginalPath );
-#endif
- return HSE_STATUS_SUCCESS;
- }
- else if (server_version >= 6)
- {
- /* For IIS 5.1 or earlier this code is never executed. Since the URL is
- redirected to Axis2/C by the Filter */
-
- /* If not for Axis2/C let the request go to who ever wants it */
- ExecUrlInfo.pszUrl = NULL; /* Use original request URL */
- ExecUrlInfo.pszMethod = NULL; /* Use original request method */
- ExecUrlInfo.pszChildHeaders = NULL; /* Use original request headers */
- ExecUrlInfo.pUserInfo = NULL; /* Use original request user info */
- ExecUrlInfo.pEntity = NULL; /* Use original request entity */
-
- /* Provent recursion */
- ExecUrlInfo.dwExecUrlFlags = HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR;
-
- /* Associate the completion routine and the current URL with this request. */
- if ( pecb->ServerSupportFunction( pecb->ConnID,
- HSE_REQ_IO_COMPLETION,
- ExecUrlCompletion,
- NULL,
- NULL) == FALSE )
- {
- return HSE_STATUS_ERROR;
- }
-
- /* Ok, now that everything is set up, let's call the child request */
- if ( pecb->ServerSupportFunction( pecb->ConnID,
- HSE_REQ_EXEC_URL,
- &ExecUrlInfo,
- NULL,
- NULL ) == FALSE )
- {
- return HSE_STATUS_ERROR;
- }
- /* Return pending and let the completion clean up */
- return HSE_STATUS_PENDING;
- }
- return HSE_STATUS_ERROR;
-}
-
-VOID
-WINAPI
-ExecUrlCompletion (
- EXTENSION_CONTROL_BLOCK * pecb,
- PVOID pContext,
- DWORD cbIO,
- DWORD dwError
- )
-{
- /* We are done so notify */
- pecb->ServerSupportFunction(
- pecb->ConnID,
- HSE_REQ_DONE_WITH_SESSION,
- NULL,
- NULL,
- NULL);
-}
-
-
-BOOL
-send_error(
- EXTENSION_CONTROL_BLOCK * pecb,
- axis2_char_t error[])
-{
- DWORD cbData;
- pecb->dwHttpStatusCode = 500;
- /* Send headers and response */
- pecb->ServerSupportFunction( pecb->ConnID,
- HSE_REQ_SEND_RESPONSE_HEADER,
- "500 Server Error",
- NULL,
- (LPDWORD)"Content-Type: text/html\r\n\r\n" );
-
- cbData = axutil_strlen( error );
- return pecb->WriteClient( pecb->ConnID,
- error,
- &cbData,
- HSE_IO_SYNC );
-}
-
+
+/*
+ * Initialize axis. This function is called in the begining of the module loading.
+ * It initializes the axis by reading values from the configuration and creating the
+ * required structures for the axis2c
+*/
+axis2_status_t AXIS2_CALL init_axis2();
+
+/*
+ * This is the function to be called after the processing
+ * is over for non Axis2 requets
+ */
+VOID
+WINAPI
+ExecUrlCompletion (
+ EXTENSION_CONTROL_BLOCK * pecb,
+ PVOID pContext,
+ DWORD cbIO,
+ DWORD dwError
+ );
+
+/*
+ * If somethign went wrong in the IIS server when
+ * we are proccessing we send this
+ */
+BOOL
+send_error(
+ EXTENSION_CONTROL_BLOCK * pecb,
+ CHAR error[]);
+
+axis2_status_t AXIS2_CALL init_axis2();
+
+BOOL
+WINAPI
+GetExtensionVersion(HSE_VERSION_INFO * pVer)
+{
+ pVer->dwExtensionVersion = MAKELONG( HSE_VERSION_MINOR,
+ HSE_VERSION_MAJOR);
+ strncpy( pVer->lpszExtensionDesc,
+ "WildCardMap Sample ISAPI Extension", HSE_MAX_EXT_DLL_NAME_LEN );
+
+ pVer->lpszExtensionDesc[HSE_MAX_EXT_DLL_NAME_LEN-1] = '\0';
+ server_version = 5;
+ return TRUE;
+}
+
+DWORD
+WINAPI
+HttpExtensionProc(EXTENSION_CONTROL_BLOCK * pecb)
+
+{
+ HSE_EXEC_URL_INFO ExecUrlInfo;
+ DWORD cbData = INTERNET_MAX_URL_LENGTH;
+ char url[INTERNET_MAX_URL_LENGTH];
+ axis2_bool_t is_for_us = AXIS2_TRUE;
+
+ /* Get the URL */
+ if ( pecb->GetServerVariable( pecb->ConnID,
+ "URL",
+ url,
+ &cbData ) == FALSE )
+ {
+ return HSE_STATUS_ERROR;
+ }
+
+ if (!is_inited)
+ {
+ DWORD dwBufferSize = 0;
+ axis2_char_t server_software[256];
+ axis2_char_t *version = NULL;
+
+ ZeroMemory(szOriginalPath, sizeof szOriginalPath);
+ dwBufferSize = sizeof szOriginalPath;
+
+#if _WIN32_WINNT >= 0x0502
+ GetDllDirectory( dwBufferSize, szOriginalPath );
+#else
+ GetCurrentDirectory( dwBufferSize, szOriginalPath );
+#endif
+ ZeroMemory(szPath, sizeof szPath);
+ dwBufferSize = sizeof szPath;
+ /* Get the current physical paht */
+ if (pecb->GetServerVariable(pecb->ConnID, "APPL_PHYSICAL_PATH", szPath, &dwBufferSize) == FALSE)
+ {
+ send_error(pecb, initializing_error);
+ return HSE_STATUS_ERROR;
+ }
+ /* Retrieve the server version */
+ dwBufferSize = 32;
+ if (pecb->GetServerVariable(pecb->ConnID, "SERVER_SOFTWARE", server_software, &dwBufferSize) == FALSE)
+ {
+ send_error(pecb, initializing_error);
+ return HSE_STATUS_ERROR;
+ }
+ version = axutil_strchr(server_software, '/');
+ if (version)
+ {
+ server_version = atoi(version + 1);
+ }
+#if _WIN32_WINNT >= 0x0502
+ SetDllDirectory( szPath );
+#else
+ SetCurrentDirectory( szPath );
+#endif
+ /* If we haven't initialized axis2/c before initialization failed */
+ if (AXIS2_FAILURE == init_axis2())
+ {
+ send_error(pecb, initializing_error);
+ return HSE_STATUS_ERROR;
+ }
+#if _WIN32_WINNT >= 0x0502
+ SetDllDirectory( szOriginalPath );
+#else
+ SetCurrentDirectory( szOriginalPath );
+#endif
+ }
+
+ /* Check weather we have a request for Axis2/C */
+ if (server_version >= 6 && strlen(url) >= strlen(axis2_location))
+ {
+ int i = 0;
+ is_for_us = AXIS2_TRUE;
+ while (axis2_location[i] != '\0')
+ {
+ if (axis2_location[i] != (url)[i]) {
+ is_for_us = AXIS2_FALSE;
+ break;
+ }
+ i++;
+ }
+ if (url[i] != '/' && url[i] != '\0')
+ {
+ is_for_us = AXIS2_FALSE;
+ }
+ }
+
+ if (is_for_us)
+ {
+ /* Windows cannot find the correct dlls unless the path is set*/
+#if _WIN32_WINNT >= 0x0502
+ SetDllDirectory( szPath );
+#else
+ SetCurrentDirectory( szPath );
+#endif
+ pecb->dwHttpStatusCode = HTTP_INTERNAL_SERVER_ERROR;
+ /* We are sure that worker is not NULL since it is NULL init_axis2 would have failed */
+ axis2_iis_worker_process_request(axis2_worker, axutil_env, pecb);
+
+ /* Windows cannot find the correct dlls unless the dir is set
+ but we want to reset to previous dir after the load */
+#if _WIN32_WINNT >= 0x0502
+ SetDllDirectory( szOriginalPath );
+#else
+ SetCurrentDirectory( szOriginalPath );
+#endif
+ return HSE_STATUS_SUCCESS;
+ }
+ else if (server_version >= 6)
+ {
+ /* For IIS 5.1 or earlier this code is never executed. Since the URL is
+ redirected to Axis2/C by the Filter */
+
+ /* If not for Axis2/C let the request go to who ever wants it */
+ ExecUrlInfo.pszUrl = NULL; /* Use original request URL */
+ ExecUrlInfo.pszMethod = NULL; /* Use original request method */
+ ExecUrlInfo.pszChildHeaders = NULL; /* Use original request headers */
+ ExecUrlInfo.pUserInfo = NULL; /* Use original request user info */
+ ExecUrlInfo.pEntity = NULL; /* Use original request entity */
+
+ /* Provent recursion */
+ ExecUrlInfo.dwExecUrlFlags = HSE_EXEC_URL_IGNORE_CURRENT_INTERCEPTOR;
+
+ /* Associate the completion routine and the current URL with this request. */
+ if ( pecb->ServerSupportFunction( pecb->ConnID,
+ HSE_REQ_IO_COMPLETION,
+ ExecUrlCompletion,
+ NULL,
+ NULL) == FALSE )
+ {
+ return HSE_STATUS_ERROR;
+ }
+
+ /* Ok, now that everything is set up, let's call the child request */
+ if ( pecb->ServerSupportFunction( pecb->ConnID,
+ HSE_REQ_EXEC_URL,
+ &ExecUrlInfo,
+ NULL,
+ NULL ) == FALSE )
+ {
+ return HSE_STATUS_ERROR;
+ }
+ /* Return pending and let the completion clean up */
+ return HSE_STATUS_PENDING;
+ }
+ return HSE_STATUS_ERROR;
+}
+
+VOID
+WINAPI
+ExecUrlCompletion (
+ EXTENSION_CONTROL_BLOCK * pecb,
+ PVOID pContext,
+ DWORD cbIO,
+ DWORD dwError
+ )
+{
+ /* We are done so notify */
+ pecb->ServerSupportFunction(
+ pecb->ConnID,
+ HSE_REQ_DONE_WITH_SESSION,
+ NULL,
+ NULL,
+ NULL);
+}
+
+
+BOOL
+send_error(
+ EXTENSION_CONTROL_BLOCK * pecb,
+ axis2_char_t error[])
+{
+ DWORD cbData;
+ pecb->dwHttpStatusCode = 500;
+ /* Send headers and response */
+ pecb->ServerSupportFunction( pecb->ConnID,
+ HSE_REQ_SEND_RESPONSE_HEADER,
+ "500 Server Error",
+ NULL,
+ (LPDWORD)"Content-Type: text/html\r\n\r\n" );
+
+ cbData = axutil_strlen( error );
+ return pecb->WriteClient( pecb->ConnID,
+ error,
+ &cbData,
+ HSE_IO_SYNC );
+}
+
axis2_status_t AXIS2_CALL read_registery_init_data()
{
long rc = 0;
diff --git a/src/core/transport/http/server/IIS/iis_iaspi_plugin_51/axis2_isapi_51.c b/src/core/transport/http/server/IIS/iis_iaspi_plugin_51/axis2_isapi_51.c
index 49cd6d9..d2c8f09 100644
--- a/src/core/transport/http/server/IIS/iis_iaspi_plugin_51/axis2_isapi_51.c
+++ b/src/core/transport/http/server/IIS/iis_iaspi_plugin_51/axis2_isapi_51.c
@@ -1,153 +1,153 @@
-/*
- * 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.
- */
-
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <httpfilt.h>
-
-#include <axis2_const.h>
-#include <axis2_defines.h>
-#include <axutil_env.h>
-#include <axutil_stream.h>
-
-#include "..\\axis2_iis_constants.h"
-
-#define REGISTRY_LOC "Software\\Apache Axis2c\\IIS ISAPI Redirector"
-#define AXIS2_IIS_AXIS2_LOC "axis2_location"
-static char *axis2_loc = "/axis2";
-
-static axis2_char_t redirect_word[INTERNET_MAX_URL_LENGTH] = "/axis2/mod_axis2_IIS.dll\?";
-/*
- * Search a given uri to find weather it matches a uri for the axis2
- * The uri format for axis2 is of the form
- * scheme://server:port/axis2/other_parts
- * This function search a give uri for the /axis2/. If a match
- * is found it will replace the /axis2 part of the url with /axis2/mod_iis.dll?
- */
-axis2_bool_t AXIS2_CALL
-get_extension_url(
- char url[],
- char ret_url[]);
-
-/*
- * This function is called by the IIS server at the server
- * initialization. So this is the ideal plcae for initializing
- * axis2c.
- */
-BOOL WINAPI
-GetFilterVersion(
- PHTTP_FILTER_VERSION pVer)
-{
- DWORD type = 0, size = 0;
- LONG lrc = 0;
- char tmpbuf[INTERNET_MAX_URL_LENGTH];
- HKEY hkey;
- ULONG http_filter_revision = HTTP_FILTER_REVISION;
- pVer->dwFilterVersion = pVer->dwServerFilterVersion;
- if(pVer->dwFilterVersion > http_filter_revision)
- {
- pVer->dwFilterVersion = http_filter_revision;
- }
-
- /*
- Receive notifictions when
- 1. Server preprocessed the headers.
- 2. Log
- 3. All the request coming in secure and none secure ports.
- */
- pVer->dwFlags = (SF_NOTIFY_ORDER_HIGH | SF_NOTIFY_PREPROC_HEADERS | SF_NOTIFY_SECURE_PORT
- | SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_AUTH_COMPLETE);
-
- /* Give a short discription about the module.*/
- strcpy(pVer->lpszFilterDesc, "axis2c filter");
- /* Get the axis2 location from the registry configuration */
- lrc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGISTRY_LOC, (DWORD)0, KEY_READ, &hkey);
- if(ERROR_SUCCESS != lrc)
- {
- return FALSE;
- }
- size = INTERNET_MAX_URL_LENGTH;
- lrc = RegQueryValueEx(hkey, AXIS2_IIS_AXIS2_LOC, (LPDWORD)0, &type, (LPBYTE)tmpbuf, &size);
- if((ERROR_SUCCESS == lrc) && (type == REG_SZ))
- {
- tmpbuf[size] = '\0';
- axis2_loc = _strdup(tmpbuf);
- }
- RegCloseKey(hkey);
- return TRUE;
-}
-
-/*
- When a notification happens this function is called by the IIS.
- */
-DWORD WINAPI
-HttpFilterProc(
- PHTTP_FILTER_CONTEXT pfc,
- DWORD notificationType,
- LPVOID pvNotification)
-{
- DWORD bufferLength = INTERNET_MAX_URL_LENGTH;
- char url[INTERNET_MAX_URL_LENGTH];
- char modified_url[INTERNET_MAX_URL_LENGTH];
-
- if(notificationType == SF_NOTIFY_PREPROC_HEADERS)
- {
- pfc->GetServerVariable(pfc, "HTTP_URL", url, &bufferLength);
- if(get_extension_url(url, modified_url))
- {
- ((PHTTP_FILTER_PREPROC_HEADERS)pvNotification)->SetHeader(pfc, "url", modified_url);
- return SF_STATUS_REQ_HANDLED_NOTIFICATION;
- }
- }
- return SF_STATUS_REQ_NEXT_NOTIFICATION;
-}
-
-axis2_bool_t AXIS2_CALL
-get_extension_url(
- char url[],
- char ret_url[])
-{
- axis2_bool_t is_for_us = AXIS2_FALSE;
- int i = 0;
- /* Should contain "/axis2/"*/
- ret_url[0] = '\0';
- if(strlen(url) >= strlen(axis2_loc))
- {
- is_for_us = AXIS2_TRUE;
- while(axis2_loc[i] != '\0')
- {
- if(axis2_loc[i] != (url)[i])
- {
- is_for_us = AXIS2_FALSE;
- break;
- }
- i++;
- }
- if(url[i] != '/' && url[i] != '\0')
- {
- is_for_us = AXIS2_FALSE;
- }
- }
- if(is_for_us)
- {
- strcpy(ret_url, redirect_word);
- strcat(ret_url, &url[i]);
- }
- return is_for_us;
-}
+/*
+ * 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.
+ */
+
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <httpfilt.h>
+
+#include <axis2_const.h>
+#include <axis2_defines.h>
+#include <axutil_env.h>
+#include <axutil_stream.h>
+
+#include "..\\axis2_iis_constants.h"
+
+#define REGISTRY_LOC "Software\\Apache Axis2c\\IIS ISAPI Redirector"
+#define AXIS2_IIS_AXIS2_LOC "axis2_location"
+static char *axis2_loc = "/axis2";
+
+static axis2_char_t redirect_word[INTERNET_MAX_URL_LENGTH] = "/axis2/mod_axis2_IIS.dll\?";
+/*
+ * Search a given uri to find weather it matches a uri for the axis2
+ * The uri format for axis2 is of the form
+ * scheme://server:port/axis2/other_parts
+ * This function search a give uri for the /axis2/. If a match
+ * is found it will replace the /axis2 part of the url with /axis2/mod_iis.dll?
+ */
+axis2_bool_t AXIS2_CALL
+get_extension_url(
+ char url[],
+ char ret_url[]);
+
+/*
+ * This function is called by the IIS server at the server
+ * initialization. So this is the ideal plcae for initializing
+ * axis2c.
+ */
+BOOL WINAPI
+GetFilterVersion(
+ PHTTP_FILTER_VERSION pVer)
+{
+ DWORD type = 0, size = 0;
+ LONG lrc = 0;
+ char tmpbuf[INTERNET_MAX_URL_LENGTH];
+ HKEY hkey;
+ ULONG http_filter_revision = HTTP_FILTER_REVISION;
+ pVer->dwFilterVersion = pVer->dwServerFilterVersion;
+ if(pVer->dwFilterVersion > http_filter_revision)
+ {
+ pVer->dwFilterVersion = http_filter_revision;
+ }
+
+ /*
+ Receive notifictions when
+ 1. Server preprocessed the headers.
+ 2. Log
+ 3. All the request coming in secure and none secure ports.
+ */
+ pVer->dwFlags = (SF_NOTIFY_ORDER_HIGH | SF_NOTIFY_PREPROC_HEADERS | SF_NOTIFY_SECURE_PORT
+ | SF_NOTIFY_NONSECURE_PORT | SF_NOTIFY_AUTH_COMPLETE);
+
+ /* Give a short discription about the module.*/
+ strcpy(pVer->lpszFilterDesc, "axis2c filter");
+ /* Get the axis2 location from the registry configuration */
+ lrc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, REGISTRY_LOC, (DWORD)0, KEY_READ, &hkey);
+ if(ERROR_SUCCESS != lrc)
+ {
+ return FALSE;
+ }
+ size = INTERNET_MAX_URL_LENGTH;
+ lrc = RegQueryValueEx(hkey, AXIS2_IIS_AXIS2_LOC, (LPDWORD)0, &type, (LPBYTE)tmpbuf, &size);
+ if((ERROR_SUCCESS == lrc) && (type == REG_SZ))
+ {
+ tmpbuf[size] = '\0';
+ axis2_loc = _strdup(tmpbuf);
+ }
+ RegCloseKey(hkey);
+ return TRUE;
+}
+
+/*
+ When a notification happens this function is called by the IIS.
+ */
+DWORD WINAPI
+HttpFilterProc(
+ PHTTP_FILTER_CONTEXT pfc,
+ DWORD notificationType,
+ LPVOID pvNotification)
+{
+ DWORD bufferLength = INTERNET_MAX_URL_LENGTH;
+ char url[INTERNET_MAX_URL_LENGTH];
+ char modified_url[INTERNET_MAX_URL_LENGTH];
+
+ if(notificationType == SF_NOTIFY_PREPROC_HEADERS)
+ {
+ pfc->GetServerVariable(pfc, "HTTP_URL", url, &bufferLength);
+ if(get_extension_url(url, modified_url))
+ {
+ ((PHTTP_FILTER_PREPROC_HEADERS)pvNotification)->SetHeader(pfc, "url", modified_url);
+ return SF_STATUS_REQ_HANDLED_NOTIFICATION;
+ }
+ }
+ return SF_STATUS_REQ_NEXT_NOTIFICATION;
+}
+
+axis2_bool_t AXIS2_CALL
+get_extension_url(
+ char url[],
+ char ret_url[])
+{
+ axis2_bool_t is_for_us = AXIS2_FALSE;
+ int i = 0;
+ /* Should contain "/axis2/"*/
+ ret_url[0] = '\0';
+ if(strlen(url) >= strlen(axis2_loc))
+ {
+ is_for_us = AXIS2_TRUE;
+ while(axis2_loc[i] != '\0')
+ {
+ if(axis2_loc[i] != (url)[i])
+ {
+ is_for_us = AXIS2_FALSE;
+ break;
+ }
+ i++;
+ }
+ if(url[i] != '/' && url[i] != '\0')
+ {
+ is_for_us = AXIS2_FALSE;
+ }
+ }
+ if(is_for_us)
+ {
+ strcpy(ret_url, redirect_word);
+ strcat(ret_url, &url[i]);
+ }
+ return is_for_us;
+}
diff --git a/src/core/transport/http/server/apache2/apache2_worker.c b/src/core/transport/http/server/apache2/apache2_worker.c
index a13e64a..0a38541 100644
--- a/src/core/transport/http/server/apache2/apache2_worker.c
+++ b/src/core/transport/http/server/apache2/apache2_worker.c
@@ -1,1687 +1,1687 @@
-/*
- * 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.
- */
-
-#include "axis2_apache2_worker.h"
-#include <axis2_http_transport.h>
-#include <axis2_conf.h>
-#include <axutil_string.h>
-#include <axis2_msg_ctx.h>
-#include <axis2_http_out_transport_info.h>
-#include <axis2_http_transport_utils.h>
-#include <axis2_http_accept_record.h>
-#include <axis2_op_ctx.h>
-#include <axis2_engine.h>
-#include <axutil_uuid_gen.h>
-#include <axis2_conf_init.h>
-#include "axis2_apache2_out_transport_info.h"
-#include <axutil_url.h>
-#include <http_core.h>
-#include <http_protocol.h>
-#include <axiom_soap.h>
-#include <axutil_class_loader.h>
-#include <axutil_string_util.h>
-#include <axiom_mime_part.h>
-#include <axiom_mtom_sending_callback.h>
-
-#define READ_SIZE 2048
-
-static axis2_status_t
-apache2_worker_send_mtom_message(
- request_rec *request,
- const axutil_env_t * env,
- axutil_array_list_t *mime_parts,
- axis2_char_t *mtom_sending_callback_name);
-
-static axis2_status_t
-apache2_worker_send_attachment_using_file(
- const axutil_env_t * env,
- request_rec *request,
- FILE *fp,
- axis2_byte_t *buffer,
- int buffer_size);
-
-static axis2_status_t
-apache2_worker_send_attachment_using_callback(
- const axutil_env_t * env,
- request_rec *request,
- axiom_mtom_sending_callback_t *callback,
- void *handler,
- void *user_param);
-
-static axutil_hash_t*
-axis2_apache_worker_get_headers(
- const axutil_env_t *env,
- request_rec *request);
-
-
-struct axis2_apache2_worker
-{
- axis2_conf_ctx_t *conf_ctx;
-};
-
-AXIS2_EXTERN axis2_apache2_worker_t *AXIS2_CALL
-axis2_apache2_worker_create(
- const axutil_env_t * env,
- axis2_char_t * repo_path)
-{
- axis2_apache2_worker_t *apache2_worker = NULL;
- axutil_hash_t* svc_map = NULL;
- axis2_conf_t* conf = NULL;
- axutil_hash_index_t *hi = NULL;
- void* svc = NULL;
- AXIS2_ENV_CHECK(env, NULL);
- AXIS2_LOG_INFO(env->log, "[Axis2] Axis2 worker created");
- apache2_worker = (axis2_apache2_worker_t *)AXIS2_MALLOC(env->allocator,
- sizeof(axis2_apache2_worker_t));
-
- if(!apache2_worker)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- return NULL;
- }
- apache2_worker->conf_ctx = axis2_build_conf_ctx(env, repo_path);
-
- if(!apache2_worker->conf_ctx)
- {
- axis2_apache2_worker_free((axis2_apache2_worker_t *)apache2_worker, env);
- return NULL;
- }
-
- /*
- * we have to load all the services. This is because, before the fork (in linux)
- * we should have a full code segment. Otherwise, we can't share function pointers of services
- * between processed. In fork, the code segment will be duplicated across processes
- */
- conf = axis2_conf_ctx_get_conf(apache2_worker->conf_ctx, env);
- if(!conf)
- {
- axis2_apache2_worker_free((axis2_apache2_worker_t *)apache2_worker, env);
- return NULL;
- }
-
- svc_map = axis2_conf_get_all_svcs(conf, env);
- if(!svc_map)
- {
- axis2_apache2_worker_free((axis2_apache2_worker_t *)apache2_worker, env);
- return NULL;
- }
-
- for(hi = axutil_hash_first(svc_map, env); hi; hi = axutil_hash_next(env, hi))
- {
- void *impl_class = NULL;
- axis2_msg_recv_t *msg_recv = NULL;
- axutil_hash_t *ops_hash = NULL;
-
- axutil_hash_this(hi, NULL, NULL, &svc);
- if(!svc)
- continue;
- impl_class = axis2_svc_get_impl_class(svc, env);
- if(impl_class)
- continue;
- ops_hash = axis2_svc_get_all_ops(svc, env);
- if(ops_hash)
- {
- axutil_hash_index_t *op_hi = NULL;
- void *op = NULL;
- op_hi = axutil_hash_first(ops_hash, env);
- if(op_hi)
- {
- axutil_hash_this(op_hi, NULL, NULL, &op);
- if(op)
- {
- msg_recv = axis2_op_get_msg_recv(op, env);
- if(msg_recv)
- {
- axis2_msg_recv_set_conf_ctx(msg_recv, env, apache2_worker->conf_ctx);
- axis2_msg_recv_load_and_init_svc(msg_recv, env, svc);
- }
- }
- }
-
- }
- }
-
- AXIS2_LOG_INFO(env->log, "[Axis2] Axis2 worker created");
-
- return apache2_worker;
-}
-
-AXIS2_EXTERN void AXIS2_CALL
-axis2_apache2_worker_free(
- axis2_apache2_worker_t * apache2_worker,
- const axutil_env_t * env)
-{
- AXIS2_ENV_CHECK(env, void);
-
- if(apache2_worker->conf_ctx)
- {
- axis2_conf_ctx_free(apache2_worker->conf_ctx, env);
- apache2_worker->conf_ctx = NULL;
- }
-
- AXIS2_FREE(env->allocator, apache2_worker);
-
- return;
-}
-
-AXIS2_EXTERN int AXIS2_CALL
-axis2_apache2_worker_process_request(
- axis2_apache2_worker_t * apache2_worker,
- const axutil_env_t * env,
- request_rec * request)
-{
- axis2_conf_ctx_t *conf_ctx = NULL;
- axis2_msg_ctx_t *msg_ctx = NULL;
- axutil_stream_t *request_body = NULL;
- axutil_stream_t *out_stream = NULL;
- axis2_transport_out_desc_t *out_desc = NULL;
- axis2_transport_in_desc_t *in_desc = NULL;
- axis2_char_t *http_version = NULL;
- axutil_string_t *soap_action = NULL;
- axis2_char_t *soap_action_header_txt = NULL;
- axis2_bool_t processed = AXIS2_FALSE;
- int content_length = -1;
- axis2_char_t *url_external_form = NULL;
- axis2_char_t *body_string = NULL;
- unsigned int body_string_len = 0;
- int send_status = DECLINED;
- axis2_char_t *content_type = NULL;
- axis2_http_out_transport_info_t *apache2_out_transport_info = NULL;
- axis2_char_t *ctx_uuid = NULL;
- axis2_op_ctx_t *op_ctx = NULL;
- axis2_char_t *peer_ip = NULL;
- axutil_property_t *peer_property = NULL;
- axutil_url_t *request_url = NULL;
- axis2_char_t *accept_header_value = NULL;
- axis2_char_t *accept_charset_header_value = NULL;
- axis2_char_t *accept_language_header_value = NULL;
- axis2_char_t *content_language_header_value = NULL;
- axis2_bool_t do_mtom = AXIS2_FALSE;
- axutil_array_list_t *mime_parts = NULL;
- axutil_param_t *callback_name_param = NULL;
- axis2_char_t *mtom_sending_callback_name = NULL;
- axis2_char_t *cookie = NULL;
- axis2_char_t *header_value = NULL;
- axis2_status_t status = AXIS2_FAILURE;
- axutil_hash_t *headers = NULL;
-
- AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
- AXIS2_PARAM_CHECK(env->error, request, AXIS2_CRITICAL_FAILURE);
-
- conf_ctx = apache2_worker->conf_ctx;
-
- if(!conf_ctx)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NULL_CONFIGURATION_CONTEXT, AXIS2_FAILURE);
- return AXIS2_CRITICAL_FAILURE;
- }
- content_length = (int)request->remaining;
- /* We are sure that the difference lies within the int range */
- http_version = request->protocol;
-
- request_url = axutil_url_create(env, "http", request->hostname, request->parsed_uri.port,
- request->unparsed_uri);
- if(request_url)
- {
- url_external_form = axutil_url_to_external_form(request_url, env);
- AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, url_external_form);
- axutil_url_free(request_url, env);
- request_url = NULL;
- }
- else
- {
- send_status = OK;
- request->status = HTTP_BAD_REQUEST;
- return send_status;
- }
-
- content_type = (axis2_char_t *)apr_table_get(request->headers_in,
- AXIS2_HTTP_HEADER_CONTENT_TYPE);
- if(!content_type)
- {
- content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_PLAIN;
- }
- request->content_type = content_type;
-
- out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(apache2_worker->conf_ctx, env),
- env, AXIS2_TRANSPORT_ENUM_HTTP);
- in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(apache2_worker->conf_ctx, env),
- env, AXIS2_TRANSPORT_ENUM_HTTP);
- {
- axis2_transport_receiver_t *receiver = NULL;
- receiver = axis2_transport_in_desc_get_recv(in_desc, env);
- if(receiver)
- axis2_transport_receiver_set_server_ip(receiver, env, request->connection->local_ip);
- }
-
- msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc);
- axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);
-
- cookie = (axis2_char_t *)apr_table_get(request->headers_in,
- AXIS2_HTTP_HEADER_COOKIE);
- if(cookie)
- {
- char *session_str = NULL;
- axis2_char_t *session_id = NULL;
-
- session_id = axis2_http_transport_utils_get_session_id_from_cookie(env, cookie);
- if(session_id)
- session_str = env->get_session_fn((void *) request, session_id);
- if(session_str)
- axis2_http_transport_utils_set_session(env, msg_ctx, session_str);
- }
-
- if(request->read_chunked == AXIS2_TRUE && 0 == content_length)
- {
- content_length = -1;
- request->chunked = 1;
- }
- if(!http_version)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NULL_HTTP_VERSION, AXIS2_FAILURE);
- return AXIS2_CRITICAL_FAILURE;
- }
- out_stream = axutil_stream_create_basic(env);
- AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Client HTTP version %s", http_version);
-
- peer_ip = request->connection->remote_ip;
-
- if(peer_ip)
- {
- peer_property = axutil_property_create(env);
- axutil_property_set_value(peer_property, env, axutil_strdup(env, peer_ip));
- axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_SVR_PEER_IP_ADDR, peer_property);
- }
-
- axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, out_stream);
-
- ctx_uuid = axutil_uuid_gen(env);
- if(ctx_uuid)
- {
- axutil_string_t *uuid_str = axutil_string_create_assume_ownership(env, &ctx_uuid);
- axis2_msg_ctx_set_svc_grp_ctx_id(msg_ctx, env, uuid_str);
- axutil_string_free(uuid_str, env);
- }
-
- apache2_out_transport_info = axis2_apache2_out_transport_info_create(env, request);
- axis2_msg_ctx_set_out_transport_info(msg_ctx, env, &(apache2_out_transport_info->out_transport));
-
- accept_header_value = (axis2_char_t *)apr_table_get(request->headers_in,
- AXIS2_HTTP_HEADER_ACCEPT);
- if(accept_header_value)
- {
- axutil_array_list_t *accept_header_field_list = NULL;
- axutil_array_list_t *accept_record_list = NULL;
- accept_header_field_list = axutil_tokenize(env, accept_header_value, ',');
- if(accept_header_field_list && axutil_array_list_size(accept_header_field_list, env) > 0)
- {
- axis2_char_t *token = NULL;
- accept_record_list = axutil_array_list_create(env, axutil_array_list_size(
- accept_header_field_list, env));
- do
- {
- if(token)
- {
- axis2_http_accept_record_t *rec = NULL;
- rec = axis2_http_accept_record_create(env, token);
- if(rec)
- {
- axutil_array_list_add(accept_record_list, env, rec);
- }
- AXIS2_FREE(env->allocator, token);
- }
- token = (axis2_char_t *)axutil_array_list_remove(accept_header_field_list, env, 0);
- }
- while(token);
- }
- if(accept_record_list && axutil_array_list_size(accept_record_list, env) > 0)
- {
- axis2_msg_ctx_set_http_accept_record_list(msg_ctx, env, accept_record_list);
- }
- }
-
- accept_charset_header_value = (axis2_char_t *)apr_table_get(request->headers_in,
- AXIS2_HTTP_HEADER_ACCEPT_CHARSET);
- if(accept_charset_header_value)
- {
- axutil_array_list_t *accept_charset_header_field_list = NULL;
- axutil_array_list_t *accept_charset_record_list = NULL;
- accept_charset_header_field_list = axutil_tokenize(env, accept_charset_header_value, ',');
- if(accept_charset_header_field_list && axutil_array_list_size(
- accept_charset_header_field_list, env) > 0)
- {
- axis2_char_t *token = NULL;
- accept_charset_record_list = axutil_array_list_create(env, axutil_array_list_size(
- accept_charset_header_field_list, env));
- do
- {
- if(token)
- {
- axis2_http_accept_record_t *rec = NULL;
- rec = axis2_http_accept_record_create(env, token);
- if(rec)
- {
- axutil_array_list_add(accept_charset_record_list, env, rec);
- }
- AXIS2_FREE(env->allocator, token);
- }
- token = (axis2_char_t *)axutil_array_list_remove(accept_charset_header_field_list,
- env, 0);
- }
- while(token);
- }
- if(accept_charset_record_list && axutil_array_list_size(accept_charset_record_list, env)
- > 0)
- {
- axis2_msg_ctx_set_http_accept_charset_record_list(msg_ctx, env,
- accept_charset_record_list);
- }
- }
-
- accept_language_header_value = (axis2_char_t *)apr_table_get(request->headers_in,
- AXIS2_HTTP_HEADER_ACCEPT_LANGUAGE);
- if(accept_language_header_value)
- {
- axutil_array_list_t *accept_language_header_field_list = NULL;
- axutil_array_list_t *accept_language_record_list = NULL;
- accept_language_header_field_list = axutil_tokenize(env, accept_language_header_value, ',');
- if(accept_language_header_field_list && axutil_array_list_size(
- accept_language_header_field_list, env) > 0)
- {
- axis2_char_t *token = NULL;
- accept_language_record_list = axutil_array_list_create(env, axutil_array_list_size(
- accept_language_header_field_list, env));
- do
- {
- if(token)
- {
- axis2_http_accept_record_t *rec = NULL;
- rec = axis2_http_accept_record_create(env, token);
- if(rec)
- {
- axutil_array_list_add(accept_language_record_list, env, rec);
- }
- AXIS2_FREE(env->allocator, token);
- }
- token = (axis2_char_t *)axutil_array_list_remove(accept_language_header_field_list,
- env, 0);
- }
- while(token);
- }
- if(accept_language_record_list && axutil_array_list_size(accept_language_record_list, env)
- > 0)
- {
- axis2_msg_ctx_set_http_accept_language_record_list(msg_ctx, env,
- accept_language_record_list);
- }
- }
-
- soap_action_header_txt = (axis2_char_t *)apr_table_get(request->headers_in,
- AXIS2_HTTP_HEADER_SOAP_ACTION);
-
- if(soap_action_header_txt)
- {
- soap_action = axutil_string_create(env, soap_action_header_txt);
- }
-
- headers = axis2_apache_worker_get_headers(env, request);
- axis2_msg_ctx_set_transport_headers(msg_ctx, env, headers);
-
- request_body = axutil_stream_create_apache2(env, request);
- if(!request_body)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error occured in"
- " creating input stream.");
- return AXIS2_CRITICAL_FAILURE;
- }
- if(M_GET == request->method_number || M_DELETE == request->method_number)
- {
- if(M_DELETE == request->method_number)
- {
- processed = axis2_http_transport_utils_process_http_delete_request(env, msg_ctx,
- request_body, out_stream, content_type, soap_action, url_external_form, conf_ctx,
- axis2_http_transport_utils_get_request_params(env,
- (axis2_char_t *)url_external_form));
- }
- else if(request->header_only)
- {
- processed = axis2_http_transport_utils_process_http_head_request(env, msg_ctx,
- request_body, out_stream, content_type, soap_action, url_external_form, conf_ctx,
- axis2_http_transport_utils_get_request_params(env,
- (axis2_char_t *)url_external_form));
- }
- else
- {
- processed = axis2_http_transport_utils_process_http_get_request(env, msg_ctx,
- request_body, out_stream, content_type, soap_action, url_external_form, conf_ctx,
- axis2_http_transport_utils_get_request_params(env,
- (axis2_char_t *)url_external_form));
- }
- if(AXIS2_FALSE == processed)
- {
- axis2_char_t *wsdl = NULL;
- axis2_bool_t is_services_path = AXIS2_FALSE;
- if(M_DELETE != request->method_number)
- {
- axis2_char_t *temp = NULL;
- temp = strstr(url_external_form, AXIS2_REQUEST_URL_PREFIX);
- if(temp)
- {
- temp += strlen(AXIS2_REQUEST_URL_PREFIX);
- if(*temp == '/')
- {
- temp++;
- }
- if(!*temp || *temp == '?' || *temp == '#')
- {
- is_services_path = AXIS2_TRUE;
- }
- }
- }
- wsdl = strstr(url_external_form, AXIS2_REQUEST_WSDL);
- if(is_services_path)
- {
- body_string = axis2_http_transport_utils_get_services_html(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
- }
- else if(M_DELETE != request->method_number && wsdl)
- {
- body_string = axis2_http_transport_utils_get_services_static_wsdl(env, conf_ctx,
- (axis2_char_t *)url_external_form);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML;
-
- }
- else if(env->error->error_number == AXIS2_ERROR_SVC_OR_OP_NOT_FOUND)
- {
- axutil_array_list_t *method_list = NULL;
- int size = 0;
- method_list = axis2_msg_ctx_get_supported_rest_http_methods(msg_ctx, env);
- size = axutil_array_list_size(method_list, env);
- if(method_list && size)
- {
- axis2_char_t *method_list_str = NULL;
- axis2_char_t *temp;
- int i = 0;
- method_list_str = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 29);
- temp = method_list_str;
- request->allowed_methods->method_mask = 0;
- for(i = 0; i < size; i++)
- {
- if(i)
- {
- sprintf(temp, ", ");
- temp += 2;
- }
- sprintf(temp, "%s", (axis2_char_t *)axutil_array_list_get(method_list, env,
- i));
- temp += strlen(temp);
- /* Conditions below is to assist down-stream modules */
- if(!axutil_strcasecmp(AXIS2_HTTP_PUT, (axis2_char_t *)axutil_array_list_get(
- method_list, env, i)))
- {
- request->allowed_methods->method_mask |= AP_METHOD_BIT << M_PUT;
- }
- else if(!axutil_strcasecmp(AXIS2_HTTP_POST, (axis2_char_t *)axutil_array_list_get(
- method_list, env, i)))
- {
- request->allowed_methods->method_mask |= AP_METHOD_BIT << M_POST;
- }
- else if(!axutil_strcasecmp(AXIS2_HTTP_GET, (axis2_char_t *)axutil_array_list_get(
- method_list, env, i)))
- {
- request->allowed_methods->method_mask |= AP_METHOD_BIT << M_GET;
- }
- else if(!axutil_strcasecmp(AXIS2_HTTP_HEAD, (axis2_char_t *)axutil_array_list_get(
- method_list, env, i)))
- {
- /* Apache Can't differentiate between HEAD and GET */
- request->allowed_methods->method_mask |= AP_METHOD_BIT << M_GET;
- }
- else if(!axutil_strcasecmp(AXIS2_HTTP_DELETE,
- (axis2_char_t *)axutil_array_list_get(method_list, env, i)))
- {
- request->allowed_methods->method_mask |= AP_METHOD_BIT << M_DELETE;
- }
- }
- *temp = '\0';
- apr_table_set(request->err_headers_out, AXIS2_HTTP_HEADER_ALLOW,
- method_list_str);
- AXIS2_FREE(env->allocator, method_list_str);
- body_string = axis2_http_transport_utils_get_method_not_allowed(env, conf_ctx);
- request->status = HTTP_METHOD_NOT_ALLOWED;
- }
- else
- {
- body_string = axis2_http_transport_utils_get_not_found(env, conf_ctx);
- request->status = HTTP_NOT_FOUND;
- }
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
- }
- else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
- == AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_VAL)
- {
- body_string = axis2_http_transport_utils_get_bad_request(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
- request->status = HTTP_BAD_REQUEST;
- }
- else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
- == AXIS2_HTTP_RESPONSE_REQUEST_TIMEOUT_CODE_VAL)
- {
- body_string = axis2_http_transport_utils_get_request_timeout(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
- request->status = HTTP_REQUEST_TIME_OUT;
- }
- else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
- == AXIS2_HTTP_RESPONSE_CONFLICT_CODE_VAL)
- {
- body_string = axis2_http_transport_utils_get_conflict(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
- request->status = HTTP_CONFLICT;
- }
- else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
- == AXIS2_HTTP_RESPONSE_GONE_CODE_VAL)
- {
- body_string = axis2_http_transport_utils_get_gone(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
- request->status = HTTP_GONE;
- }
- else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
- == AXIS2_HTTP_RESPONSE_PRECONDITION_FAILED_CODE_VAL)
- {
- body_string = axis2_http_transport_utils_get_precondition_failed(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
- request->status = HTTP_PRECONDITION_FAILED;
- }
- else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
- == AXIS2_HTTP_RESPONSE_REQUEST_ENTITY_TOO_LARGE_CODE_VAL)
- {
- body_string = axis2_http_transport_utils_get_request_entity_too_large(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
- request->status = HTTP_REQUEST_ENTITY_TOO_LARGE;
- }
- else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
- == AXIS2_HTTP_RESPONSE_SERVICE_UNAVAILABLE_CODE_VAL)
- {
- body_string = axis2_http_transport_utils_get_service_unavailable(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
- request->status = HTTP_SERVICE_UNAVAILABLE;
- }
- else
- {
- body_string = axis2_http_transport_utils_get_internal_server_error(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
- request->status = HTTP_INTERNAL_SERVER_ERROR;
- }
-
- if(body_string)
- {
- body_string_len = axutil_strlen(body_string);
- }
- send_status = OK;
- }
- }
- else if(M_POST == request->method_number || M_PUT == request->method_number)
- {
- /*axis2_status_t status = AXIS2_FAILURE;*/
- if(M_POST == request->method_number)
- {
- status = axis2_http_transport_utils_process_http_post_request(env, msg_ctx,
- request_body, out_stream, content_type, content_length, soap_action,
- (axis2_char_t *)url_external_form);
- }
- else
- {
- status = axis2_http_transport_utils_process_http_put_request(env, msg_ctx,
- request_body, out_stream, content_type, content_length, soap_action,
- (axis2_char_t *)url_external_form);
- }
- if(AXIS2_FAILURE == status && (M_PUT == request->method_number
- || axis2_msg_ctx_get_doing_rest(msg_ctx, env)))
- {
- if(env->error->error_number == AXIS2_ERROR_SVC_OR_OP_NOT_FOUND)
- {
- axutil_array_list_t *method_list = NULL;
- int size = 0;
- method_list = axis2_msg_ctx_get_supported_rest_http_methods(msg_ctx, env);
- size = axutil_array_list_size(method_list, env);
- if(method_list && size)
- {
- axis2_char_t *method_list_str = NULL;
- axis2_char_t *temp;
- int i = 0;
- method_list_str = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 29);
- temp = method_list_str;
- request->allowed_methods->method_mask = 0;
- for(i = 0; i < size; i++)
- {
- if(i)
- {
- sprintf(temp, ", ");
- temp += 2;
- }
- sprintf(temp, "%s", (axis2_char_t *)axutil_array_list_get(method_list, env,
- i));
- temp += strlen(temp);
- /* Conditions below is to assist down-stream modules */
- if(!axutil_strcasecmp(AXIS2_HTTP_PUT, (axis2_char_t *)axutil_array_list_get(
- method_list, env, i)))
- {
- request->allowed_methods->method_mask |= AP_METHOD_BIT << M_PUT;
- }
- else if(!axutil_strcasecmp(AXIS2_HTTP_POST, (axis2_char_t *)axutil_array_list_get(
- method_list, env, i)))
- {
- request->allowed_methods->method_mask |= AP_METHOD_BIT << M_POST;
- }
- else if(!axutil_strcasecmp(AXIS2_HTTP_GET, (axis2_char_t *)axutil_array_list_get(
- method_list, env, i)))
- {
- request->allowed_methods->method_mask |= AP_METHOD_BIT << M_GET;
- }
- else if(!axutil_strcasecmp(AXIS2_HTTP_HEAD, (axis2_char_t *)axutil_array_list_get(
- method_list, env, i)))
- {
- /* Apache Can't differentiate between HEAD and GET */
- request->allowed_methods->method_mask |= AP_METHOD_BIT << M_GET;
- }
- else if(!axutil_strcasecmp(AXIS2_HTTP_DELETE,
- (axis2_char_t *)axutil_array_list_get(method_list, env, i)))
- {
- request->allowed_methods->method_mask |= AP_METHOD_BIT << M_DELETE;
- }
- }
- *temp = '\0';
- apr_table_set(request->err_headers_out, AXIS2_HTTP_HEADER_ALLOW,
- method_list_str);
- AXIS2_FREE(env->allocator, method_list_str);
- body_string = axis2_http_transport_utils_get_method_not_allowed(env, conf_ctx);
- request->status = HTTP_METHOD_NOT_ALLOWED;
- }
- else
- {
- body_string = axis2_http_transport_utils_get_not_found(env, conf_ctx);
- request->status = HTTP_NOT_FOUND;
- }
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
- }
- else
- {
- body_string = axis2_http_transport_utils_get_internal_server_error(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
- request->status = HTTP_INTERNAL_SERVER_ERROR;
- }
-
- if(body_string)
- {
- body_string_len = axutil_strlen(body_string);
- }
- send_status = OK;
- }
- else if(status == AXIS2_FAILURE)
- {
- axis2_msg_ctx_t *fault_ctx = NULL;
- axis2_char_t *fault_code = NULL;
- axis2_engine_t *engine = axis2_engine_create(env, conf_ctx);
- if(!engine)
- {
- /* Critical error, cannot proceed, Apache will send default
- document for 500
- */
- return AXIS2_CRITICAL_FAILURE;
- }
- if(axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
- {
- fault_code = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
- AXIOM_SOAP11_FAULT_CODE_SENDER;
- }
- else
- {
- fault_code = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
- AXIOM_SOAP12_SOAP_FAULT_VALUE_SENDER;
- }
- fault_ctx = axis2_engine_create_fault_msg_ctx(engine, env, msg_ctx,
- fault_code,
- axutil_error_get_message
- (env->error));
- axis2_engine_send_fault(engine, env, fault_ctx);
- if (out_stream)
- {
- body_string = axutil_stream_get_buffer(out_stream, env);
- body_string_len = axutil_stream_get_len(out_stream, env);
- }
-
- /* In case of a SOAP Fault, we have to set the status to 500,
- but still return OK because the module has handled the error
- */
- send_status = OK;
- request->status = HTTP_INTERNAL_SERVER_ERROR;
- }
- }
- else
- {
- body_string =
- axis2_http_transport_utils_get_not_implemented(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
-
- if (body_string)
- {
- body_string_len = axutil_strlen(body_string);
- }
- send_status = OK;
- request->status = HTTP_NOT_IMPLEMENTED;
- }
-
- op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
-
- if (op_ctx)
- {
- axis2_msg_ctx_t *out_msg_ctx = NULL;
- axis2_msg_ctx_t **msg_ctx_map = NULL;
-
- msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
- out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
- if (out_msg_ctx)
- {
- content_language_header_value = axis2_msg_ctx_get_content_language(out_msg_ctx, env);
- }
- }
-
- if (send_status == DECLINED)
- {
- axis2_bool_t do_rest = AXIS2_FALSE;
- if (M_POST != request->method_number ||
- axis2_msg_ctx_get_doing_rest(msg_ctx, env))
- {
- do_rest = AXIS2_TRUE;
- }
- if ((accept_header_value || accept_charset_header_value ||
- accept_language_header_value) && do_rest)
- {
- axis2_char_t *content_type_header_value = NULL;
- axis2_char_t *temp = NULL;
- axis2_char_t *language_header_value = NULL;
-
- content_type_header_value = (axis2_char_t *) request->content_type;
- language_header_value = content_language_header_value;
- if (content_type_header_value)
- {
- temp = axutil_strdup(env, content_type_header_value);
- }
- if (temp)
- {
- axis2_char_t *content_type = NULL;
- axis2_char_t *char_set = NULL;
- axis2_char_t *temp2 = NULL;
-
- temp2 = strchr(temp, ';');
- if (temp2)
- {
- *temp2 = '\0';
- temp2++;
- char_set = axutil_strcasestr(temp2, AXIS2_HTTP_CHAR_SET_ENCODING);
- }
- if (char_set)
- {
- char_set = axutil_strltrim(env, char_set, " \t=");
- }
- if (char_set)
- {
- temp2 = strchr(char_set, ';');
- }
- if (temp2)
- {
- *temp2 = '\0';
- }
- content_type = axutil_strtrim(env, temp, NULL);
-
- if (temp)
- {
- AXIS2_FREE(env->allocator, temp);
- temp = NULL;
- }
- if (content_type && accept_header_value &&
- !axutil_strcasestr(accept_header_value, content_type))
- {
- temp2 = strchr(content_type, '/');
- if (temp2)
- {
- *temp2 = '\0';
- temp = AXIS2_MALLOC(env->allocator,
- sizeof(axis2_char_t) * ((int)strlen(content_type) + 3));
- if (!temp)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- return AXIS2_FALSE;
- }
- sprintf(temp, "%s/*", content_type);
- if (!axutil_strcasestr(accept_header_value, temp) &&
- !strstr(accept_header_value, AXIS2_HTTP_HEADER_ACCEPT_ALL))
- {
- body_string =
- axis2_http_transport_utils_get_not_acceptable(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
-
- if (body_string)
- {
- body_string_len = axutil_strlen(body_string);
- }
- send_status = OK;
- request->status = HTTP_NOT_ACCEPTABLE;
- }
- AXIS2_FREE(env->allocator, temp);
- }
- }
- if (content_type)
- {
- AXIS2_FREE(env->allocator, content_type);
- }
- if (char_set && accept_charset_header_value &&
- !axutil_strcasestr(accept_charset_header_value, char_set))
- {
- body_string =
- axis2_http_transport_utils_get_not_acceptable(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
-
- if (body_string)
- {
- body_string_len = axutil_strlen(body_string);
- }
- send_status = OK;
- request->status = HTTP_NOT_ACCEPTABLE;
- }
- if (char_set)
- {
- AXIS2_FREE(env->allocator, char_set);
- }
- }
- if (language_header_value)
- {
- if (accept_language_header_value &&
- !axutil_strcasestr(accept_language_header_value, language_header_value))
- {
- body_string =
- axis2_http_transport_utils_get_not_acceptable(env, conf_ctx);
- request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
-
- if (body_string)
- {
- body_string_len = axutil_strlen(body_string);
- }
- send_status = OK;
- request->status = HTTP_NOT_ACCEPTABLE;
- }
- }
- }
- }
-
- header_value = axis2_http_transport_utils_get_session(env, msg_ctx);
- if(header_value)
- {
- axis2_http_out_transport_info_t *out_info = NULL;
- out_info = (axis2_http_out_transport_info_t *)axis2_msg_ctx_get_out_transport_info(msg_ctx, env);
- AXIS2_HTTP_OUT_TRANSPORT_INFO_SET_COOKIE_HEADER(out_info, env, header_value);
- }
- if (send_status == DECLINED)
- {
- axis2_bool_t do_rest = AXIS2_FALSE;
- if (M_POST != request->method_number ||
- axis2_msg_ctx_get_doing_rest(msg_ctx, env))
- {
- do_rest = AXIS2_TRUE;
- }
- if (op_ctx && axis2_op_ctx_get_response_written(op_ctx, env))
- {
- if (do_rest)
- {
- axis2_msg_ctx_t *out_msg_ctx = NULL;
- axis2_msg_ctx_t *in_msg_ctx = NULL;
- axis2_msg_ctx_t **msg_ctx_map = NULL;
-
- msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
- out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
- in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
- if (in_msg_ctx)
- {
- /* TODO: Add necessary handling */
- }
- if (out_msg_ctx)
- {
- int size = 0;
- axutil_array_list_t *output_header_list = NULL;
- output_header_list = axis2_msg_ctx_get_http_output_headers(out_msg_ctx, env);
- if (output_header_list)
- {
- size = axutil_array_list_size(output_header_list, env);
- }
- while (size)
- {
- axis2_http_header_t *output_header = NULL;
- size--;
- output_header = (axis2_http_header_t *)
- axutil_array_list_get(output_header_list, env, size);
- apr_table_set(request->err_headers_out,
- axis2_http_header_get_name(output_header, env),
- axis2_http_header_get_value(output_header, env));
- }
- if (axis2_msg_ctx_get_status_code(out_msg_ctx, env))
- {
- int status_code = axis2_msg_ctx_get_status_code(out_msg_ctx, env);
- switch (status_code)
- {
- case AXIS2_HTTP_RESPONSE_CONTINUE_CODE_VAL:
- request->status = HTTP_CONTINUE;
- break;
- case AXIS2_HTTP_RESPONSE_ACK_CODE_VAL:
- request->status = HTTP_ACCEPTED;
- break;
- case AXIS2_HTTP_RESPONSE_MULTIPLE_CHOICES_CODE_VAL:
- request->status = HTTP_MULTIPLE_CHOICES;
- break;
- case AXIS2_HTTP_RESPONSE_MOVED_PERMANENTLY_CODE_VAL:
- request->status = HTTP_MOVED_PERMANENTLY;
- break;
- case AXIS2_HTTP_RESPONSE_SEE_OTHER_CODE_VAL:
- request->status = HTTP_SEE_OTHER;
- break;
- case AXIS2_HTTP_RESPONSE_NOT_MODIFIED_CODE_VAL:
- request->status = HTTP_NOT_MODIFIED;
- break;
- case AXIS2_HTTP_RESPONSE_TEMPORARY_REDIRECT_CODE_VAL:
- request->status = HTTP_TEMPORARY_REDIRECT;
- break;
- case AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_VAL:
- request->status = HTTP_BAD_REQUEST;
- break;
- case AXIS2_HTTP_RESPONSE_REQUEST_TIMEOUT_CODE_VAL:
- request->status = HTTP_REQUEST_TIME_OUT;
- break;
- case AXIS2_HTTP_RESPONSE_CONFLICT_CODE_VAL:
- request->status = HTTP_CONFLICT;
- break;
- case AXIS2_HTTP_RESPONSE_GONE_CODE_VAL:
- request->status = HTTP_GONE;
- break;
- case AXIS2_HTTP_RESPONSE_PRECONDITION_FAILED_CODE_VAL:
- request->status = HTTP_PRECONDITION_FAILED;
- break;
- case AXIS2_HTTP_RESPONSE_REQUEST_ENTITY_TOO_LARGE_CODE_VAL:
- request->status = HTTP_REQUEST_ENTITY_TOO_LARGE;
- break;
- case AXIS2_HTTP_RESPONSE_SERVICE_UNAVAILABLE_CODE_VAL:
- request->status = HTTP_SERVICE_UNAVAILABLE;
- break;
- default:
- request->status = HTTP_OK;
- break;
- }
- send_status = DONE;
- }
- }
- }
- if (send_status == DECLINED)
- {
- send_status = OK;
- if (out_stream)
- {
- body_string = axutil_stream_get_buffer(out_stream, env);
- body_string_len = axutil_stream_get_len(out_stream, env);
- }
- }
- }
- else if (op_ctx)
- {
- if (do_rest)
- {
- axis2_msg_ctx_t *out_msg_ctx = NULL;
- axis2_msg_ctx_t *in_msg_ctx = NULL;
- axis2_msg_ctx_t **msg_ctx_map = NULL;
-
- msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
- out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
- in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
- if (in_msg_ctx)
- {
- /* TODO: Add necessary handling */
- }
- if (out_msg_ctx)
- {
- int size = 0;
- axutil_array_list_t *output_header_list = NULL;
- output_header_list = axis2_msg_ctx_get_http_output_headers(out_msg_ctx, env);
- if (output_header_list)
- {
- size = axutil_array_list_size(output_header_list, env);
- }
- while (size)
- {
- axis2_http_header_t *output_header = NULL;
- size--;
- output_header = (axis2_http_header_t *)
- axutil_array_list_get(output_header_list, env, size);
- apr_table_set(request->err_headers_out,
- axis2_http_header_get_name(output_header, env),
- axis2_http_header_get_value(output_header, env));
- }
- if (axis2_msg_ctx_get_no_content(out_msg_ctx, env))
- {
- if (axis2_msg_ctx_get_status_code(out_msg_ctx, env))
- {
- int status_code = axis2_msg_ctx_get_status_code(out_msg_ctx, env);
- switch (status_code)
- {
- case AXIS2_HTTP_RESPONSE_RESET_CONTENT_CODE_VAL:
- request->status = HTTP_RESET_CONTENT;
- break;
- case AXIS2_HTTP_RESPONSE_NOT_MODIFIED_CODE_VAL:
- request->status = HTTP_NOT_MODIFIED;
- break;
- default:
- request->status = HTTP_NO_CONTENT;
- break;
- }
- }
- else
- {
- request->status = HTTP_NO_CONTENT;
- }
- send_status = DONE;
- }
- else if (axis2_msg_ctx_get_status_code(out_msg_ctx, env))
- {
- int status_code = axis2_msg_ctx_get_status_code(out_msg_ctx, env);
- switch (status_code)
- {
- case AXIS2_HTTP_RESPONSE_CONTINUE_CODE_VAL:
- request->status = HTTP_CONTINUE;
- break;
- case AXIS2_HTTP_RESPONSE_OK_CODE_VAL:
- request->status = HTTP_OK;
- break;
- case AXIS2_HTTP_RESPONSE_MULTIPLE_CHOICES_CODE_VAL:
- request->status = HTTP_MULTIPLE_CHOICES;
- break;
- case AXIS2_HTTP_RESPONSE_MOVED_PERMANENTLY_CODE_VAL:
- request->status = HTTP_MOVED_PERMANENTLY;
- break;
- case AXIS2_HTTP_RESPONSE_SEE_OTHER_CODE_VAL:
- request->status = HTTP_SEE_OTHER;
- break;
- case AXIS2_HTTP_RESPONSE_NOT_MODIFIED_CODE_VAL:
- request->status = HTTP_NOT_MODIFIED;
- break;
- case AXIS2_HTTP_RESPONSE_TEMPORARY_REDIRECT_CODE_VAL:
- request->status = HTTP_TEMPORARY_REDIRECT;
- break;
- case AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_VAL:
- request->status = HTTP_BAD_REQUEST;
- break;
- case AXIS2_HTTP_RESPONSE_REQUEST_TIMEOUT_CODE_VAL:
- request->status = HTTP_REQUEST_TIME_OUT;
- break;
- case AXIS2_HTTP_RESPONSE_CONFLICT_CODE_VAL:
- request->status = HTTP_CONFLICT;
- break;
- case AXIS2_HTTP_RESPONSE_GONE_CODE_VAL:
- request->status = HTTP_GONE;
- break;
- case AXIS2_HTTP_RESPONSE_PRECONDITION_FAILED_CODE_VAL:
- request->status = HTTP_PRECONDITION_FAILED;
- break;
- case AXIS2_HTTP_RESPONSE_REQUEST_ENTITY_TOO_LARGE_CODE_VAL:
- request->status = HTTP_REQUEST_ENTITY_TOO_LARGE;
- break;
- case AXIS2_HTTP_RESPONSE_SERVICE_UNAVAILABLE_CODE_VAL:
- request->status = HTTP_SERVICE_UNAVAILABLE;
- break;
- default:
- request->status = HTTP_ACCEPTED;
- break;
- }
- send_status = DONE;
- }
- }
- }
- if (send_status == DECLINED)
- {
- if (msg_ctx)
- {
- int size = 0;
- int status_code;
- axutil_array_list_t *output_header_list = NULL;
- output_header_list = axis2_msg_ctx_get_http_output_headers(msg_ctx, env);
- if (output_header_list)
- {
- size = axutil_array_list_size(output_header_list, env);
- }
- while (size)
- {
- axis2_http_header_t *output_header = NULL;
- size--;
- output_header = (axis2_http_header_t *)
- axutil_array_list_get(output_header_list, env, size);
- apr_table_set(request->err_headers_out,
- axis2_http_header_get_name(output_header, env),
- axis2_http_header_get_value(output_header, env));
- }
-
- status_code = axis2_msg_ctx_get_status_code(msg_ctx, env);
- switch (status_code)
- {
- case AXIS2_HTTP_RESPONSE_CONTINUE_CODE_VAL:
- request->status = HTTP_CONTINUE;
- break;
- case AXIS2_HTTP_RESPONSE_OK_CODE_VAL:
- request->status = HTTP_OK;
- break;
- case AXIS2_HTTP_RESPONSE_MULTIPLE_CHOICES_CODE_VAL:
- request->status = HTTP_MULTIPLE_CHOICES;
- break;
- case AXIS2_HTTP_RESPONSE_MOVED_PERMANENTLY_CODE_VAL:
- request->status = HTTP_MOVED_PERMANENTLY;
- break;
- case AXIS2_HTTP_RESPONSE_SEE_OTHER_CODE_VAL:
- request->status = HTTP_SEE_OTHER;
- break;
- case AXIS2_HTTP_RESPONSE_NOT_MODIFIED_CODE_VAL:
- request->status = HTTP_NOT_MODIFIED;
- break;
- case AXIS2_HTTP_RESPONSE_TEMPORARY_REDIRECT_CODE_VAL:
- request->status = HTTP_TEMPORARY_REDIRECT;
- break;
- case AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_VAL:
- request->status = HTTP_BAD_REQUEST;
- break;
- case AXIS2_HTTP_RESPONSE_REQUEST_TIMEOUT_CODE_VAL:
- request->status = HTTP_REQUEST_TIME_OUT;
- break;
- case AXIS2_HTTP_RESPONSE_CONFLICT_CODE_VAL:
- request->status = HTTP_CONFLICT;
- break;
- case AXIS2_HTTP_RESPONSE_GONE_CODE_VAL:
- request->status = HTTP_GONE;
- break;
- case AXIS2_HTTP_RESPONSE_PRECONDITION_FAILED_CODE_VAL:
- request->status = HTTP_PRECONDITION_FAILED;
- break;
- case AXIS2_HTTP_RESPONSE_REQUEST_ENTITY_TOO_LARGE_CODE_VAL:
- request->status = HTTP_REQUEST_ENTITY_TOO_LARGE;
- break;
- case AXIS2_HTTP_RESPONSE_SERVICE_UNAVAILABLE_CODE_VAL:
- request->status = HTTP_SERVICE_UNAVAILABLE;
- break;
- case AXIS2_HTTP_RESPONSE_FORBIDDEN_CODE_VAL:
- request->status = HTTP_FORBIDDEN;
- break;
- case AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED_CODE_VAL:
- request->status = HTTP_UNAUTHORIZED;
- break;
- default:
- request->status = HTTP_ACCEPTED;
- break;
- }
-
- out_stream = axis2_msg_ctx_get_transport_out_stream(msg_ctx, env);
- if (out_stream)
- {
- body_string = axutil_stream_get_buffer(out_stream, env);
- body_string_len = axutil_stream_get_len(out_stream, env);
- }
- send_status = DONE;
- }
- else
- {
- request->status = HTTP_ACCEPTED;
- send_status = DONE;
- }
- }
- }
- else
- {
- send_status = DONE;
- request->status = HTTP_ACCEPTED;
- }
- }
-
- if (content_language_header_value)
- {
- apr_table_set(request->err_headers_out, AXIS2_HTTP_HEADER_CONTENT_LANGUAGE,
- content_language_header_value);
- }
-
- if (op_ctx)
- {
- axis2_msg_ctx_t *out_msg_ctx = NULL,
- *in_msg_ctx = NULL;
- axis2_msg_ctx_t **msg_ctx_map = NULL;
- axis2_char_t *msg_id = NULL;
- axis2_conf_ctx_t *conf_ctx = NULL;
- msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
-
- out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
- in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
-
- /* In mtom case we send the attachment differently */
-
- /* status = AXIS2_FAILURE means fault scenario. We are not
- * doing MTOM for fault cases. */
-
- if(status != AXIS2_FAILURE)
- {
- do_mtom = axis2_msg_ctx_get_doing_mtom(out_msg_ctx, env);
- if(do_mtom)
- {
- mime_parts = axis2_msg_ctx_get_mime_parts(out_msg_ctx, env);
- if(!mime_parts)
- {
- return AXIS2_FAILURE;
- }
- callback_name_param = axis2_msg_ctx_get_parameter(msg_ctx, env ,
- AXIS2_MTOM_SENDING_CALLBACK);
- if(callback_name_param)
- {
- mtom_sending_callback_name =
- (axis2_char_t *) axutil_param_get_value (callback_name_param, env);
- }
- }
- }
-
- if (out_msg_ctx)
- {
- axis2_msg_ctx_free(out_msg_ctx, env);
- out_msg_ctx = NULL;
- msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT] = NULL;
- }
-
- if (in_msg_ctx)
- {
- msg_id =
- axutil_strdup(env, axis2_msg_ctx_get_msg_id(in_msg_ctx, env));
- conf_ctx = axis2_msg_ctx_get_conf_ctx(in_msg_ctx, env);
- axis2_msg_ctx_reset_out_transport_info(in_msg_ctx, env);
- axis2_msg_ctx_free(in_msg_ctx, env);
- in_msg_ctx = NULL;
- msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN] = NULL;
- }
-
- if (!axis2_op_ctx_is_in_use(op_ctx, env))
- {
- axis2_op_ctx_destroy_mutex(op_ctx, env);
- if (conf_ctx && msg_id)
- {
- axis2_conf_ctx_register_op_ctx(conf_ctx, env, msg_id, NULL);
- AXIS2_FREE(env->allocator, msg_id);
- }
- axis2_op_ctx_free(op_ctx, env);
- }
-
- } /* Done freeing message contexts */
-
- /* We send the message in parts when doing MTOM */
-
- if(do_mtom)
- {
- axis2_status_t mtom_status = AXIS2_FAILURE;
-
- if(!mtom_sending_callback_name)
- {
- /* If the callback name is not there, then we will check whether there
- * is any mime_parts which has type callback. If we found then no point
- * of continuing we should return a failure */
-
- if(!mtom_sending_callback_name)
- {
- if(axis2_http_transport_utils_is_callback_required(
- env, mime_parts))
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Sender callback not specified");
- return AXIS2_FAILURE;
- }
- }
- }
-
- mtom_status = apache2_worker_send_mtom_message(request, env, mime_parts,
- mtom_sending_callback_name);
- if(mtom_status == AXIS2_SUCCESS)
- {
- send_status = DONE;
- }
- else
- {
- send_status = DECLINED;
- }
-
- axis2_http_transport_utils_destroy_mime_parts(mime_parts, env);
- mime_parts = NULL;
- }
-
- else if (body_string)
- {
- ap_rwrite(body_string, body_string_len, request);
- body_string = NULL;
- }
-
- if (request_body)
- {
- axutil_stream_free(request_body, env);
- request_body = NULL;
- }
-
- axutil_string_free(soap_action, env);
-
- msg_ctx = NULL;
- return send_status;
-}
-
-AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-axis2_apache2_worker_get_bytes(
- const axutil_env_t * env,
- axutil_stream_t * stream)
-{
-
- axutil_stream_t *tmp_stream = NULL;
- int return_size = -1;
- axis2_char_t *buffer = NULL;
- axis2_bool_t loop_status = AXIS2_TRUE;
-
- AXIS2_ENV_CHECK(env, NULL);
- AXIS2_PARAM_CHECK(env->error, stream, NULL);
-
- tmp_stream = axutil_stream_create_basic(env);
- while(loop_status)
- {
- int read = 0;
- int write = 0;
-
- char buf[READ_SIZE];
- read = axutil_stream_read(stream, env, buf, READ_SIZE);
- if(read < 0)
- {
- break;
- }
- write = axutil_stream_write(tmp_stream, env, buf, read);
- if(read < (READ_SIZE - 1))
- {
- break;
- }
- }
- return_size = axutil_stream_get_len(tmp_stream, env);
-
- if(return_size > 0)
- {
- buffer = (char *)AXIS2_MALLOC(env->allocator, sizeof(char) * (return_size + 2));
- return_size = axutil_stream_read(tmp_stream, env, buffer, return_size + 1);
- buffer[return_size + 1] = '\0';
- }
- axutil_stream_free(tmp_stream, env);
- return buffer;
-}
-
-static axis2_status_t
-apache2_worker_send_mtom_message(
- request_rec *request,
- const axutil_env_t * env,
- axutil_array_list_t *mime_parts,
- axis2_char_t *mtom_sending_callback_name)
-{
- int i = 0;
- axiom_mime_part_t *mime_part = NULL;
- axis2_status_t status = AXIS2_SUCCESS;
- /*int written = 0;*/
- int len = 0;
-
- if(mime_parts)
- {
- for(i = 0; i < axutil_array_list_size(mime_parts, env); i++)
- {
- mime_part = (axiom_mime_part_t *)axutil_array_list_get(mime_parts, env, i);
- if((mime_part->type) == AXIOM_MIME_PART_BUFFER)
- {
- len = 0;
- len = ap_rwrite(mime_part->part, (int)mime_part->part_size, request);
- ap_rflush(request);
- if(len == -1)
- {
- status = AXIS2_FAILURE;
- break;
- }
- }
- else if((mime_part->type) == AXIOM_MIME_PART_FILE)
- {
- FILE *f = NULL;
- axis2_byte_t *output_buffer = NULL;
- int output_buffer_size = 0;
-
- f = fopen(mime_part->file_name, "rb");
- if(!f)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error opening file %s for reading",
- mime_part->file_name);
- return AXIS2_FAILURE;
- }
- if(mime_part->part_size > AXIS2_MTOM_OUTPUT_BUFFER_SIZE)
- {
- output_buffer_size = AXIS2_MTOM_OUTPUT_BUFFER_SIZE;
- }
- else
- {
- output_buffer_size = (int)mime_part->part_size;
- }
-
- output_buffer = AXIS2_MALLOC(env->allocator, (output_buffer_size + 1)
- * sizeof(axis2_char_t));
-
- status = apache2_worker_send_attachment_using_file(env, request, f, output_buffer,
- output_buffer_size);
- if(status == AXIS2_FAILURE)
- {
- return status;
- }
- }
- else if((mime_part->type) == AXIOM_MIME_PART_CALLBACK)
- {
- void *handler = NULL;
- axiom_mtom_sending_callback_t *callback = NULL;
-
- handler = axis2_http_transport_utils_initiate_callback(env,
- mtom_sending_callback_name, mime_part->user_param, &callback);
-
- if(handler)
- {
- status = apache2_worker_send_attachment_using_callback(env, request, callback,
- handler, mime_part->user_param);
- }
- else
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "MTOM Sending Callback loading failed");
- status = AXIS2_FAILURE;
- }
- if(callback)
- {
- axutil_param_t *param = NULL;
-
- param = callback->param;
-
- AXIOM_MTOM_SENDING_CALLBACK_FREE(callback, env);
- callback = NULL;
-
- if(param)
- {
- axutil_param_free(param, env);
- param = NULL;
- }
-
- }
-
- if(status == AXIS2_FAILURE)
- {
- return status;
- }
- }
- else
- {
- return AXIS2_FAILURE;
- }
- if(status == AXIS2_FAILURE)
- {
- break;
- }
- }
- return status;
- }
- else
- {
- return AXIS2_FAILURE;
- }
-}
-
-static axis2_status_t
-apache2_worker_send_attachment_using_file(
- const axutil_env_t * env,
- request_rec *request,
- FILE *fp,
- axis2_byte_t *buffer,
- int buffer_size)
-{
-
- int count = 0;
- int len = 0;
- /*int written = 0;*/
- axis2_status_t status = AXIS2_SUCCESS;
-
- do
- {
- count = (int)fread(buffer, 1, buffer_size + 1, fp);
- if(ferror(fp))
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in reading file containg the attachment");
- if(buffer)
- {
- AXIS2_FREE(env->allocator, buffer);
- buffer = NULL;
- }
- fclose(fp);
- return AXIS2_FAILURE;
- }
-
- if(count > 0)
- {
- len = 0;
- len = ap_rwrite(buffer, count, request);
- ap_rflush(request);
- if(len == -1)
- {
- status = AXIS2_FAILURE;
- break;
- }
- }
- else
- {
- if(buffer)
- {
- AXIS2_FREE(env->allocator, buffer);
- buffer = NULL;
- }
- fclose(fp);
- return AXIS2_FAILURE;
- }
- memset(buffer, 0, buffer_size);
- if(status == AXIS2_FAILURE)
- {
- if(buffer)
- {
- AXIS2_FREE(env->allocator, buffer);
- buffer = NULL;
- }
- fclose(fp);
- return AXIS2_FAILURE;
- }
- }
- while(!feof(fp));
-
- fclose(fp);
- AXIS2_FREE(env->allocator, buffer);
- buffer = NULL;
- return AXIS2_SUCCESS;
-}
-
-static axis2_status_t
-apache2_worker_send_attachment_using_callback(
- const axutil_env_t * env,
- request_rec *request,
- axiom_mtom_sending_callback_t *callback,
- void *handler,
- void *user_param)
-{
- int count = 0;
- int len = 0;
- axis2_status_t status = AXIS2_SUCCESS;
- axis2_char_t *buffer = NULL;
-
- /* Keep on loading the data in a loop until
- * all the data is sent */
-
- while((count = AXIOM_MTOM_SENDING_CALLBACK_LOAD_DATA(callback, env, handler, &buffer)) > 0)
- {
- len = 0;
- len = ap_rwrite(buffer, count, request);
- ap_rflush(request);
- if(len == -1)
- {
- status = AXIS2_FAILURE;
- break;
- }
- }
-
- if(status == AXIS2_FAILURE)
- {
- AXIOM_MTOM_SENDING_CALLBACK_CLOSE_HANDLER(callback, env, handler);
- return status;
- }
-
- status = AXIOM_MTOM_SENDING_CALLBACK_CLOSE_HANDLER(callback, env, handler);
- return status;
-}
-
-
-static axutil_hash_t*
-axis2_apache_worker_get_headers(
- const axutil_env_t *env,
- request_rec *request)
-{
- int i = 0;
- axutil_hash_t *header_map = NULL;
- const apr_array_header_t *tarr;
- const apr_table_entry_t *telts;
- axis2_http_header_t * tmp_http_header = NULL;
-
-
- header_map = axutil_hash_make(env);
- tarr = apr_table_elts(request->headers_in);
- telts = (const apr_table_entry_t*)tarr->elts;
-
- for (i = 0; i < tarr->nelts; i++)
- {
- axis2_char_t* tmp_key = (axis2_char_t*) telts[i].key;
- axis2_char_t* tmp_value = (axis2_char_t*) telts[i].val;
- tmp_http_header = axis2_http_header_create(env, tmp_key, tmp_value);
- axutil_hash_set(header_map, tmp_key, AXIS2_HASH_KEY_STRING, tmp_http_header);
- }
-
- return header_map;
-
-
-}
+/*
+ * 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.
+ */
+
+#include "axis2_apache2_worker.h"
+#include <axis2_http_transport.h>
+#include <axis2_conf.h>
+#include <axutil_string.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_http_out_transport_info.h>
+#include <axis2_http_transport_utils.h>
+#include <axis2_http_accept_record.h>
+#include <axis2_op_ctx.h>
+#include <axis2_engine.h>
+#include <axutil_uuid_gen.h>
+#include <axis2_conf_init.h>
+#include "axis2_apache2_out_transport_info.h"
+#include <axutil_url.h>
+#include <http_core.h>
+#include <http_protocol.h>
+#include <axiom_soap.h>
+#include <axutil_class_loader.h>
+#include <axutil_string_util.h>
+#include <axiom_mime_part.h>
+#include <axiom_mtom_sending_callback.h>
+
+#define READ_SIZE 2048
+
+static axis2_status_t
+apache2_worker_send_mtom_message(
+ request_rec *request,
+ const axutil_env_t * env,
+ axutil_array_list_t *mime_parts,
+ axis2_char_t *mtom_sending_callback_name);
+
+static axis2_status_t
+apache2_worker_send_attachment_using_file(
+ const axutil_env_t * env,
+ request_rec *request,
+ FILE *fp,
+ axis2_byte_t *buffer,
+ int buffer_size);
+
+static axis2_status_t
+apache2_worker_send_attachment_using_callback(
+ const axutil_env_t * env,
+ request_rec *request,
+ axiom_mtom_sending_callback_t *callback,
+ void *handler,
+ void *user_param);
+
+static axutil_hash_t*
+axis2_apache_worker_get_headers(
+ const axutil_env_t *env,
+ request_rec *request);
+
+
+struct axis2_apache2_worker
+{
+ axis2_conf_ctx_t *conf_ctx;
+};
+
+AXIS2_EXTERN axis2_apache2_worker_t *AXIS2_CALL
+axis2_apache2_worker_create(
+ const axutil_env_t * env,
+ axis2_char_t * repo_path)
+{
+ axis2_apache2_worker_t *apache2_worker = NULL;
+ axutil_hash_t* svc_map = NULL;
+ axis2_conf_t* conf = NULL;
+ axutil_hash_index_t *hi = NULL;
+ void* svc = NULL;
+ AXIS2_ENV_CHECK(env, NULL);
+ AXIS2_LOG_INFO(env->log, "[Axis2] Axis2 worker created");
+ apache2_worker = (axis2_apache2_worker_t *)AXIS2_MALLOC(env->allocator,
+ sizeof(axis2_apache2_worker_t));
+
+ if(!apache2_worker)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+ apache2_worker->conf_ctx = axis2_build_conf_ctx(env, repo_path);
+
+ if(!apache2_worker->conf_ctx)
+ {
+ axis2_apache2_worker_free((axis2_apache2_worker_t *)apache2_worker, env);
+ return NULL;
+ }
+
+ /*
+ * we have to load all the services. This is because, before the fork (in linux)
+ * we should have a full code segment. Otherwise, we can't share function pointers of services
+ * between processed. In fork, the code segment will be duplicated across processes
+ */
+ conf = axis2_conf_ctx_get_conf(apache2_worker->conf_ctx, env);
+ if(!conf)
+ {
+ axis2_apache2_worker_free((axis2_apache2_worker_t *)apache2_worker, env);
+ return NULL;
+ }
+
+ svc_map = axis2_conf_get_all_svcs(conf, env);
+ if(!svc_map)
+ {
+ axis2_apache2_worker_free((axis2_apache2_worker_t *)apache2_worker, env);
+ return NULL;
+ }
+
+ for(hi = axutil_hash_first(svc_map, env); hi; hi = axutil_hash_next(env, hi))
+ {
+ void *impl_class = NULL;
+ axis2_msg_recv_t *msg_recv = NULL;
+ axutil_hash_t *ops_hash = NULL;
+
+ axutil_hash_this(hi, NULL, NULL, &svc);
+ if(!svc)
+ continue;
+ impl_class = axis2_svc_get_impl_class(svc, env);
+ if(impl_class)
+ continue;
+ ops_hash = axis2_svc_get_all_ops(svc, env);
+ if(ops_hash)
+ {
+ axutil_hash_index_t *op_hi = NULL;
+ void *op = NULL;
+ op_hi = axutil_hash_first(ops_hash, env);
+ if(op_hi)
+ {
+ axutil_hash_this(op_hi, NULL, NULL, &op);
+ if(op)
+ {
+ msg_recv = axis2_op_get_msg_recv(op, env);
+ if(msg_recv)
+ {
+ axis2_msg_recv_set_conf_ctx(msg_recv, env, apache2_worker->conf_ctx);
+ axis2_msg_recv_load_and_init_svc(msg_recv, env, svc);
+ }
+ }
+ }
+
+ }
+ }
+
+ AXIS2_LOG_INFO(env->log, "[Axis2] Axis2 worker created");
+
+ return apache2_worker;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_apache2_worker_free(
+ axis2_apache2_worker_t * apache2_worker,
+ const axutil_env_t * env)
+{
+ AXIS2_ENV_CHECK(env, void);
+
+ if(apache2_worker->conf_ctx)
+ {
+ axis2_conf_ctx_free(apache2_worker->conf_ctx, env);
+ apache2_worker->conf_ctx = NULL;
+ }
+
+ AXIS2_FREE(env->allocator, apache2_worker);
+
+ return;
+}
+
+AXIS2_EXTERN int AXIS2_CALL
+axis2_apache2_worker_process_request(
+ axis2_apache2_worker_t * apache2_worker,
+ const axutil_env_t * env,
+ request_rec * request)
+{
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ axis2_msg_ctx_t *msg_ctx = NULL;
+ axutil_stream_t *request_body = NULL;
+ axutil_stream_t *out_stream = NULL;
+ axis2_transport_out_desc_t *out_desc = NULL;
+ axis2_transport_in_desc_t *in_desc = NULL;
+ axis2_char_t *http_version = NULL;
+ axutil_string_t *soap_action = NULL;
+ axis2_char_t *soap_action_header_txt = NULL;
+ axis2_bool_t processed = AXIS2_FALSE;
+ int content_length = -1;
+ axis2_char_t *url_external_form = NULL;
+ axis2_char_t *body_string = NULL;
+ unsigned int body_string_len = 0;
+ int send_status = DECLINED;
+ axis2_char_t *content_type = NULL;
+ axis2_http_out_transport_info_t *apache2_out_transport_info = NULL;
+ axis2_char_t *ctx_uuid = NULL;
+ axis2_op_ctx_t *op_ctx = NULL;
+ axis2_char_t *peer_ip = NULL;
+ axutil_property_t *peer_property = NULL;
+ axutil_url_t *request_url = NULL;
+ axis2_char_t *accept_header_value = NULL;
+ axis2_char_t *accept_charset_header_value = NULL;
+ axis2_char_t *accept_language_header_value = NULL;
+ axis2_char_t *content_language_header_value = NULL;
+ axis2_bool_t do_mtom = AXIS2_FALSE;
+ axutil_array_list_t *mime_parts = NULL;
+ axutil_param_t *callback_name_param = NULL;
+ axis2_char_t *mtom_sending_callback_name = NULL;
+ axis2_char_t *cookie = NULL;
+ axis2_char_t *header_value = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+ axutil_hash_t *headers = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, request, AXIS2_CRITICAL_FAILURE);
+
+ conf_ctx = apache2_worker->conf_ctx;
+
+ if(!conf_ctx)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NULL_CONFIGURATION_CONTEXT, AXIS2_FAILURE);
+ return AXIS2_CRITICAL_FAILURE;
+ }
+ content_length = (int)request->remaining;
+ /* We are sure that the difference lies within the int range */
+ http_version = request->protocol;
+
+ request_url = axutil_url_create(env, "http", request->hostname, request->parsed_uri.port,
+ request->unparsed_uri);
+ if(request_url)
+ {
+ url_external_form = axutil_url_to_external_form(request_url, env);
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, url_external_form);
+ axutil_url_free(request_url, env);
+ request_url = NULL;
+ }
+ else
+ {
+ send_status = OK;
+ request->status = HTTP_BAD_REQUEST;
+ return send_status;
+ }
+
+ content_type = (axis2_char_t *)apr_table_get(request->headers_in,
+ AXIS2_HTTP_HEADER_CONTENT_TYPE);
+ if(!content_type)
+ {
+ content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_PLAIN;
+ }
+ request->content_type = content_type;
+
+ out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(apache2_worker->conf_ctx, env),
+ env, AXIS2_TRANSPORT_ENUM_HTTP);
+ in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(apache2_worker->conf_ctx, env),
+ env, AXIS2_TRANSPORT_ENUM_HTTP);
+ {
+ axis2_transport_receiver_t *receiver = NULL;
+ receiver = axis2_transport_in_desc_get_recv(in_desc, env);
+ if(receiver)
+ axis2_transport_receiver_set_server_ip(receiver, env, request->connection->local_ip);
+ }
+
+ msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc);
+ axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);
+
+ cookie = (axis2_char_t *)apr_table_get(request->headers_in,
+ AXIS2_HTTP_HEADER_COOKIE);
+ if(cookie)
+ {
+ char *session_str = NULL;
+ axis2_char_t *session_id = NULL;
+
+ session_id = axis2_http_transport_utils_get_session_id_from_cookie(env, cookie);
+ if(session_id)
+ session_str = env->get_session_fn((void *) request, session_id);
+ if(session_str)
+ axis2_http_transport_utils_set_session(env, msg_ctx, session_str);
+ }
+
+ if(request->read_chunked == AXIS2_TRUE && 0 == content_length)
+ {
+ content_length = -1;
+ request->chunked = 1;
+ }
+ if(!http_version)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NULL_HTTP_VERSION, AXIS2_FAILURE);
+ return AXIS2_CRITICAL_FAILURE;
+ }
+ out_stream = axutil_stream_create_basic(env);
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Client HTTP version %s", http_version);
+
+ peer_ip = request->connection->remote_ip;
+
+ if(peer_ip)
+ {
+ peer_property = axutil_property_create(env);
+ axutil_property_set_value(peer_property, env, axutil_strdup(env, peer_ip));
+ axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_SVR_PEER_IP_ADDR, peer_property);
+ }
+
+ axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, out_stream);
+
+ ctx_uuid = axutil_uuid_gen(env);
+ if(ctx_uuid)
+ {
+ axutil_string_t *uuid_str = axutil_string_create_assume_ownership(env, &ctx_uuid);
+ axis2_msg_ctx_set_svc_grp_ctx_id(msg_ctx, env, uuid_str);
+ axutil_string_free(uuid_str, env);
+ }
+
+ apache2_out_transport_info = axis2_apache2_out_transport_info_create(env, request);
+ axis2_msg_ctx_set_out_transport_info(msg_ctx, env, &(apache2_out_transport_info->out_transport));
+
+ accept_header_value = (axis2_char_t *)apr_table_get(request->headers_in,
+ AXIS2_HTTP_HEADER_ACCEPT);
+ if(accept_header_value)
+ {
+ axutil_array_list_t *accept_header_field_list = NULL;
+ axutil_array_list_t *accept_record_list = NULL;
+ accept_header_field_list = axutil_tokenize(env, accept_header_value, ',');
+ if(accept_header_field_list && axutil_array_list_size(accept_header_field_list, env) > 0)
+ {
+ axis2_char_t *token = NULL;
+ accept_record_list = axutil_array_list_create(env, axutil_array_list_size(
+ accept_header_field_list, env));
+ do
+ {
+ if(token)
+ {
+ axis2_http_accept_record_t *rec = NULL;
+ rec = axis2_http_accept_record_create(env, token);
+ if(rec)
+ {
+ axutil_array_list_add(accept_record_list, env, rec);
+ }
+ AXIS2_FREE(env->allocator, token);
+ }
+ token = (axis2_char_t *)axutil_array_list_remove(accept_header_field_list, env, 0);
+ }
+ while(token);
+ }
+ if(accept_record_list && axutil_array_list_size(accept_record_list, env) > 0)
+ {
+ axis2_msg_ctx_set_http_accept_record_list(msg_ctx, env, accept_record_list);
+ }
+ }
+
+ accept_charset_header_value = (axis2_char_t *)apr_table_get(request->headers_in,
+ AXIS2_HTTP_HEADER_ACCEPT_CHARSET);
+ if(accept_charset_header_value)
+ {
+ axutil_array_list_t *accept_charset_header_field_list = NULL;
+ axutil_array_list_t *accept_charset_record_list = NULL;
+ accept_charset_header_field_list = axutil_tokenize(env, accept_charset_header_value, ',');
+ if(accept_charset_header_field_list && axutil_array_list_size(
+ accept_charset_header_field_list, env) > 0)
+ {
+ axis2_char_t *token = NULL;
+ accept_charset_record_list = axutil_array_list_create(env, axutil_array_list_size(
+ accept_charset_header_field_list, env));
+ do
+ {
+ if(token)
+ {
+ axis2_http_accept_record_t *rec = NULL;
+ rec = axis2_http_accept_record_create(env, token);
+ if(rec)
+ {
+ axutil_array_list_add(accept_charset_record_list, env, rec);
+ }
+ AXIS2_FREE(env->allocator, token);
+ }
+ token = (axis2_char_t *)axutil_array_list_remove(accept_charset_header_field_list,
+ env, 0);
+ }
+ while(token);
+ }
+ if(accept_charset_record_list && axutil_array_list_size(accept_charset_record_list, env)
+ > 0)
+ {
+ axis2_msg_ctx_set_http_accept_charset_record_list(msg_ctx, env,
+ accept_charset_record_list);
+ }
+ }
+
+ accept_language_header_value = (axis2_char_t *)apr_table_get(request->headers_in,
+ AXIS2_HTTP_HEADER_ACCEPT_LANGUAGE);
+ if(accept_language_header_value)
+ {
+ axutil_array_list_t *accept_language_header_field_list = NULL;
+ axutil_array_list_t *accept_language_record_list = NULL;
+ accept_language_header_field_list = axutil_tokenize(env, accept_language_header_value, ',');
+ if(accept_language_header_field_list && axutil_array_list_size(
+ accept_language_header_field_list, env) > 0)
+ {
+ axis2_char_t *token = NULL;
+ accept_language_record_list = axutil_array_list_create(env, axutil_array_list_size(
+ accept_language_header_field_list, env));
+ do
+ {
+ if(token)
+ {
+ axis2_http_accept_record_t *rec = NULL;
+ rec = axis2_http_accept_record_create(env, token);
+ if(rec)
+ {
+ axutil_array_list_add(accept_language_record_list, env, rec);
+ }
+ AXIS2_FREE(env->allocator, token);
+ }
+ token = (axis2_char_t *)axutil_array_list_remove(accept_language_header_field_list,
+ env, 0);
+ }
+ while(token);
+ }
+ if(accept_language_record_list && axutil_array_list_size(accept_language_record_list, env)
+ > 0)
+ {
+ axis2_msg_ctx_set_http_accept_language_record_list(msg_ctx, env,
+ accept_language_record_list);
+ }
+ }
+
+ soap_action_header_txt = (axis2_char_t *)apr_table_get(request->headers_in,
+ AXIS2_HTTP_HEADER_SOAP_ACTION);
+
+ if(soap_action_header_txt)
+ {
+ soap_action = axutil_string_create(env, soap_action_header_txt);
+ }
+
+ headers = axis2_apache_worker_get_headers(env, request);
+ axis2_msg_ctx_set_transport_headers(msg_ctx, env, headers);
+
+ request_body = axutil_stream_create_apache2(env, request);
+ if(!request_body)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error occured in"
+ " creating input stream.");
+ return AXIS2_CRITICAL_FAILURE;
+ }
+ if(M_GET == request->method_number || M_DELETE == request->method_number)
+ {
+ if(M_DELETE == request->method_number)
+ {
+ processed = axis2_http_transport_utils_process_http_delete_request(env, msg_ctx,
+ request_body, out_stream, content_type, soap_action, url_external_form, conf_ctx,
+ axis2_http_transport_utils_get_request_params(env,
+ (axis2_char_t *)url_external_form));
+ }
+ else if(request->header_only)
+ {
+ processed = axis2_http_transport_utils_process_http_head_request(env, msg_ctx,
+ request_body, out_stream, content_type, soap_action, url_external_form, conf_ctx,
+ axis2_http_transport_utils_get_request_params(env,
+ (axis2_char_t *)url_external_form));
+ }
+ else
+ {
+ processed = axis2_http_transport_utils_process_http_get_request(env, msg_ctx,
+ request_body, out_stream, content_type, soap_action, url_external_form, conf_ctx,
+ axis2_http_transport_utils_get_request_params(env,
+ (axis2_char_t *)url_external_form));
+ }
+ if(AXIS2_FALSE == processed)
+ {
+ axis2_char_t *wsdl = NULL;
+ axis2_bool_t is_services_path = AXIS2_FALSE;
+ if(M_DELETE != request->method_number)
+ {
+ axis2_char_t *temp = NULL;
+ temp = strstr(url_external_form, AXIS2_REQUEST_URL_PREFIX);
+ if(temp)
+ {
+ temp += strlen(AXIS2_REQUEST_URL_PREFIX);
+ if(*temp == '/')
+ {
+ temp++;
+ }
+ if(!*temp || *temp == '?' || *temp == '#')
+ {
+ is_services_path = AXIS2_TRUE;
+ }
+ }
+ }
+ wsdl = strstr(url_external_form, AXIS2_REQUEST_WSDL);
+ if(is_services_path)
+ {
+ body_string = axis2_http_transport_utils_get_services_html(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+ }
+ else if(M_DELETE != request->method_number && wsdl)
+ {
+ body_string = axis2_http_transport_utils_get_services_static_wsdl(env, conf_ctx,
+ (axis2_char_t *)url_external_form);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML;
+
+ }
+ else if(env->error->error_number == AXIS2_ERROR_SVC_OR_OP_NOT_FOUND)
+ {
+ axutil_array_list_t *method_list = NULL;
+ int size = 0;
+ method_list = axis2_msg_ctx_get_supported_rest_http_methods(msg_ctx, env);
+ size = axutil_array_list_size(method_list, env);
+ if(method_list && size)
+ {
+ axis2_char_t *method_list_str = NULL;
+ axis2_char_t *temp;
+ int i = 0;
+ method_list_str = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 29);
+ temp = method_list_str;
+ request->allowed_methods->method_mask = 0;
+ for(i = 0; i < size; i++)
+ {
+ if(i)
+ {
+ sprintf(temp, ", ");
+ temp += 2;
+ }
+ sprintf(temp, "%s", (axis2_char_t *)axutil_array_list_get(method_list, env,
+ i));
+ temp += strlen(temp);
+ /* Conditions below is to assist down-stream modules */
+ if(!axutil_strcasecmp(AXIS2_HTTP_PUT, (axis2_char_t *)axutil_array_list_get(
+ method_list, env, i)))
+ {
+ request->allowed_methods->method_mask |= AP_METHOD_BIT << M_PUT;
+ }
+ else if(!axutil_strcasecmp(AXIS2_HTTP_POST, (axis2_char_t *)axutil_array_list_get(
+ method_list, env, i)))
+ {
+ request->allowed_methods->method_mask |= AP_METHOD_BIT << M_POST;
+ }
+ else if(!axutil_strcasecmp(AXIS2_HTTP_GET, (axis2_char_t *)axutil_array_list_get(
+ method_list, env, i)))
+ {
+ request->allowed_methods->method_mask |= AP_METHOD_BIT << M_GET;
+ }
+ else if(!axutil_strcasecmp(AXIS2_HTTP_HEAD, (axis2_char_t *)axutil_array_list_get(
+ method_list, env, i)))
+ {
+ /* Apache Can't differentiate between HEAD and GET */
+ request->allowed_methods->method_mask |= AP_METHOD_BIT << M_GET;
+ }
+ else if(!axutil_strcasecmp(AXIS2_HTTP_DELETE,
+ (axis2_char_t *)axutil_array_list_get(method_list, env, i)))
+ {
+ request->allowed_methods->method_mask |= AP_METHOD_BIT << M_DELETE;
+ }
+ }
+ *temp = '\0';
+ apr_table_set(request->err_headers_out, AXIS2_HTTP_HEADER_ALLOW,
+ method_list_str);
+ AXIS2_FREE(env->allocator, method_list_str);
+ body_string = axis2_http_transport_utils_get_method_not_allowed(env, conf_ctx);
+ request->status = HTTP_METHOD_NOT_ALLOWED;
+ }
+ else
+ {
+ body_string = axis2_http_transport_utils_get_not_found(env, conf_ctx);
+ request->status = HTTP_NOT_FOUND;
+ }
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+ }
+ else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
+ == AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_VAL)
+ {
+ body_string = axis2_http_transport_utils_get_bad_request(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+ request->status = HTTP_BAD_REQUEST;
+ }
+ else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
+ == AXIS2_HTTP_RESPONSE_REQUEST_TIMEOUT_CODE_VAL)
+ {
+ body_string = axis2_http_transport_utils_get_request_timeout(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+ request->status = HTTP_REQUEST_TIME_OUT;
+ }
+ else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
+ == AXIS2_HTTP_RESPONSE_CONFLICT_CODE_VAL)
+ {
+ body_string = axis2_http_transport_utils_get_conflict(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+ request->status = HTTP_CONFLICT;
+ }
+ else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
+ == AXIS2_HTTP_RESPONSE_GONE_CODE_VAL)
+ {
+ body_string = axis2_http_transport_utils_get_gone(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+ request->status = HTTP_GONE;
+ }
+ else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
+ == AXIS2_HTTP_RESPONSE_PRECONDITION_FAILED_CODE_VAL)
+ {
+ body_string = axis2_http_transport_utils_get_precondition_failed(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+ request->status = HTTP_PRECONDITION_FAILED;
+ }
+ else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
+ == AXIS2_HTTP_RESPONSE_REQUEST_ENTITY_TOO_LARGE_CODE_VAL)
+ {
+ body_string = axis2_http_transport_utils_get_request_entity_too_large(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+ request->status = HTTP_REQUEST_ENTITY_TOO_LARGE;
+ }
+ else if(axis2_msg_ctx_get_status_code(msg_ctx, env)
+ == AXIS2_HTTP_RESPONSE_SERVICE_UNAVAILABLE_CODE_VAL)
+ {
+ body_string = axis2_http_transport_utils_get_service_unavailable(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+ request->status = HTTP_SERVICE_UNAVAILABLE;
+ }
+ else
+ {
+ body_string = axis2_http_transport_utils_get_internal_server_error(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+ request->status = HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ if(body_string)
+ {
+ body_string_len = axutil_strlen(body_string);
+ }
+ send_status = OK;
+ }
+ }
+ else if(M_POST == request->method_number || M_PUT == request->method_number)
+ {
+ /*axis2_status_t status = AXIS2_FAILURE;*/
+ if(M_POST == request->method_number)
+ {
+ status = axis2_http_transport_utils_process_http_post_request(env, msg_ctx,
+ request_body, out_stream, content_type, content_length, soap_action,
+ (axis2_char_t *)url_external_form);
+ }
+ else
+ {
+ status = axis2_http_transport_utils_process_http_put_request(env, msg_ctx,
+ request_body, out_stream, content_type, content_length, soap_action,
+ (axis2_char_t *)url_external_form);
+ }
+ if(AXIS2_FAILURE == status && (M_PUT == request->method_number
+ || axis2_msg_ctx_get_doing_rest(msg_ctx, env)))
+ {
+ if(env->error->error_number == AXIS2_ERROR_SVC_OR_OP_NOT_FOUND)
+ {
+ axutil_array_list_t *method_list = NULL;
+ int size = 0;
+ method_list = axis2_msg_ctx_get_supported_rest_http_methods(msg_ctx, env);
+ size = axutil_array_list_size(method_list, env);
+ if(method_list && size)
+ {
+ axis2_char_t *method_list_str = NULL;
+ axis2_char_t *temp;
+ int i = 0;
+ method_list_str = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * 29);
+ temp = method_list_str;
+ request->allowed_methods->method_mask = 0;
+ for(i = 0; i < size; i++)
+ {
+ if(i)
+ {
+ sprintf(temp, ", ");
+ temp += 2;
+ }
+ sprintf(temp, "%s", (axis2_char_t *)axutil_array_list_get(method_list, env,
+ i));
+ temp += strlen(temp);
+ /* Conditions below is to assist down-stream modules */
+ if(!axutil_strcasecmp(AXIS2_HTTP_PUT, (axis2_char_t *)axutil_array_list_get(
+ method_list, env, i)))
+ {
+ request->allowed_methods->method_mask |= AP_METHOD_BIT << M_PUT;
+ }
+ else if(!axutil_strcasecmp(AXIS2_HTTP_POST, (axis2_char_t *)axutil_array_list_get(
+ method_list, env, i)))
+ {
+ request->allowed_methods->method_mask |= AP_METHOD_BIT << M_POST;
+ }
+ else if(!axutil_strcasecmp(AXIS2_HTTP_GET, (axis2_char_t *)axutil_array_list_get(
+ method_list, env, i)))
+ {
+ request->allowed_methods->method_mask |= AP_METHOD_BIT << M_GET;
+ }
+ else if(!axutil_strcasecmp(AXIS2_HTTP_HEAD, (axis2_char_t *)axutil_array_list_get(
+ method_list, env, i)))
+ {
+ /* Apache Can't differentiate between HEAD and GET */
+ request->allowed_methods->method_mask |= AP_METHOD_BIT << M_GET;
+ }
+ else if(!axutil_strcasecmp(AXIS2_HTTP_DELETE,
+ (axis2_char_t *)axutil_array_list_get(method_list, env, i)))
+ {
+ request->allowed_methods->method_mask |= AP_METHOD_BIT << M_DELETE;
+ }
+ }
+ *temp = '\0';
+ apr_table_set(request->err_headers_out, AXIS2_HTTP_HEADER_ALLOW,
+ method_list_str);
+ AXIS2_FREE(env->allocator, method_list_str);
+ body_string = axis2_http_transport_utils_get_method_not_allowed(env, conf_ctx);
+ request->status = HTTP_METHOD_NOT_ALLOWED;
+ }
+ else
+ {
+ body_string = axis2_http_transport_utils_get_not_found(env, conf_ctx);
+ request->status = HTTP_NOT_FOUND;
+ }
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+ }
+ else
+ {
+ body_string = axis2_http_transport_utils_get_internal_server_error(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+ request->status = HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ if(body_string)
+ {
+ body_string_len = axutil_strlen(body_string);
+ }
+ send_status = OK;
+ }
+ else if(status == AXIS2_FAILURE)
+ {
+ axis2_msg_ctx_t *fault_ctx = NULL;
+ axis2_char_t *fault_code = NULL;
+ axis2_engine_t *engine = axis2_engine_create(env, conf_ctx);
+ if(!engine)
+ {
+ /* Critical error, cannot proceed, Apache will send default
+ document for 500
+ */
+ return AXIS2_CRITICAL_FAILURE;
+ }
+ if(axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
+ {
+ fault_code = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
+ AXIOM_SOAP11_FAULT_CODE_SENDER;
+ }
+ else
+ {
+ fault_code = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
+ AXIOM_SOAP12_SOAP_FAULT_VALUE_SENDER;
+ }
+ fault_ctx = axis2_engine_create_fault_msg_ctx(engine, env, msg_ctx,
+ fault_code,
+ axutil_error_get_message
+ (env->error));
+ axis2_engine_send_fault(engine, env, fault_ctx);
+ if (out_stream)
+ {
+ body_string = axutil_stream_get_buffer(out_stream, env);
+ body_string_len = axutil_stream_get_len(out_stream, env);
+ }
+
+ /* In case of a SOAP Fault, we have to set the status to 500,
+ but still return OK because the module has handled the error
+ */
+ send_status = OK;
+ request->status = HTTP_INTERNAL_SERVER_ERROR;
+ }
+ }
+ else
+ {
+ body_string =
+ axis2_http_transport_utils_get_not_implemented(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+
+ if (body_string)
+ {
+ body_string_len = axutil_strlen(body_string);
+ }
+ send_status = OK;
+ request->status = HTTP_NOT_IMPLEMENTED;
+ }
+
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+
+ if (op_ctx)
+ {
+ axis2_msg_ctx_t *out_msg_ctx = NULL;
+ axis2_msg_ctx_t **msg_ctx_map = NULL;
+
+ msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
+ out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
+ if (out_msg_ctx)
+ {
+ content_language_header_value = axis2_msg_ctx_get_content_language(out_msg_ctx, env);
+ }
+ }
+
+ if (send_status == DECLINED)
+ {
+ axis2_bool_t do_rest = AXIS2_FALSE;
+ if (M_POST != request->method_number ||
+ axis2_msg_ctx_get_doing_rest(msg_ctx, env))
+ {
+ do_rest = AXIS2_TRUE;
+ }
+ if ((accept_header_value || accept_charset_header_value ||
+ accept_language_header_value) && do_rest)
+ {
+ axis2_char_t *content_type_header_value = NULL;
+ axis2_char_t *temp = NULL;
+ axis2_char_t *language_header_value = NULL;
+
+ content_type_header_value = (axis2_char_t *) request->content_type;
+ language_header_value = content_language_header_value;
+ if (content_type_header_value)
+ {
+ temp = axutil_strdup(env, content_type_header_value);
+ }
+ if (temp)
+ {
+ axis2_char_t *content_type = NULL;
+ axis2_char_t *char_set = NULL;
+ axis2_char_t *temp2 = NULL;
+
+ temp2 = strchr(temp, ';');
+ if (temp2)
+ {
+ *temp2 = '\0';
+ temp2++;
+ char_set = axutil_strcasestr(temp2, AXIS2_HTTP_CHAR_SET_ENCODING);
+ }
+ if (char_set)
+ {
+ char_set = axutil_strltrim(env, char_set, " \t=");
+ }
+ if (char_set)
+ {
+ temp2 = strchr(char_set, ';');
+ }
+ if (temp2)
+ {
+ *temp2 = '\0';
+ }
+ content_type = axutil_strtrim(env, temp, NULL);
+
+ if (temp)
+ {
+ AXIS2_FREE(env->allocator, temp);
+ temp = NULL;
+ }
+ if (content_type && accept_header_value &&
+ !axutil_strcasestr(accept_header_value, content_type))
+ {
+ temp2 = strchr(content_type, '/');
+ if (temp2)
+ {
+ *temp2 = '\0';
+ temp = AXIS2_MALLOC(env->allocator,
+ sizeof(axis2_char_t) * ((int)strlen(content_type) + 3));
+ if (!temp)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return AXIS2_FALSE;
+ }
+ sprintf(temp, "%s/*", content_type);
+ if (!axutil_strcasestr(accept_header_value, temp) &&
+ !strstr(accept_header_value, AXIS2_HTTP_HEADER_ACCEPT_ALL))
+ {
+ body_string =
+ axis2_http_transport_utils_get_not_acceptable(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+
+ if (body_string)
+ {
+ body_string_len = axutil_strlen(body_string);
+ }
+ send_status = OK;
+ request->status = HTTP_NOT_ACCEPTABLE;
+ }
+ AXIS2_FREE(env->allocator, temp);
+ }
+ }
+ if (content_type)
+ {
+ AXIS2_FREE(env->allocator, content_type);
+ }
+ if (char_set && accept_charset_header_value &&
+ !axutil_strcasestr(accept_charset_header_value, char_set))
+ {
+ body_string =
+ axis2_http_transport_utils_get_not_acceptable(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+
+ if (body_string)
+ {
+ body_string_len = axutil_strlen(body_string);
+ }
+ send_status = OK;
+ request->status = HTTP_NOT_ACCEPTABLE;
+ }
+ if (char_set)
+ {
+ AXIS2_FREE(env->allocator, char_set);
+ }
+ }
+ if (language_header_value)
+ {
+ if (accept_language_header_value &&
+ !axutil_strcasestr(accept_language_header_value, language_header_value))
+ {
+ body_string =
+ axis2_http_transport_utils_get_not_acceptable(env, conf_ctx);
+ request->content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_HTML;
+
+ if (body_string)
+ {
+ body_string_len = axutil_strlen(body_string);
+ }
+ send_status = OK;
+ request->status = HTTP_NOT_ACCEPTABLE;
+ }
+ }
+ }
+ }
+
+ header_value = axis2_http_transport_utils_get_session(env, msg_ctx);
+ if(header_value)
+ {
+ axis2_http_out_transport_info_t *out_info = NULL;
+ out_info = (axis2_http_out_transport_info_t *)axis2_msg_ctx_get_out_transport_info(msg_ctx, env);
+ AXIS2_HTTP_OUT_TRANSPORT_INFO_SET_COOKIE_HEADER(out_info, env, header_value);
+ }
+ if (send_status == DECLINED)
+ {
+ axis2_bool_t do_rest = AXIS2_FALSE;
+ if (M_POST != request->method_number ||
+ axis2_msg_ctx_get_doing_rest(msg_ctx, env))
+ {
+ do_rest = AXIS2_TRUE;
+ }
+ if (op_ctx && axis2_op_ctx_get_response_written(op_ctx, env))
+ {
+ if (do_rest)
+ {
+ axis2_msg_ctx_t *out_msg_ctx = NULL;
+ axis2_msg_ctx_t *in_msg_ctx = NULL;
+ axis2_msg_ctx_t **msg_ctx_map = NULL;
+
+ msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
+ out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
+ in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
+ if (in_msg_ctx)
+ {
+ /* TODO: Add necessary handling */
+ }
+ if (out_msg_ctx)
+ {
+ int size = 0;
+ axutil_array_list_t *output_header_list = NULL;
+ output_header_list = axis2_msg_ctx_get_http_output_headers(out_msg_ctx, env);
+ if (output_header_list)
+ {
+ size = axutil_array_list_size(output_header_list, env);
+ }
+ while (size)
+ {
+ axis2_http_header_t *output_header = NULL;
+ size--;
+ output_header = (axis2_http_header_t *)
+ axutil_array_list_get(output_header_list, env, size);
+ apr_table_set(request->err_headers_out,
+ axis2_http_header_get_name(output_header, env),
+ axis2_http_header_get_value(output_header, env));
+ }
+ if (axis2_msg_ctx_get_status_code(out_msg_ctx, env))
+ {
+ int status_code = axis2_msg_ctx_get_status_code(out_msg_ctx, env);
+ switch (status_code)
+ {
+ case AXIS2_HTTP_RESPONSE_CONTINUE_CODE_VAL:
+ request->status = HTTP_CONTINUE;
+ break;
+ case AXIS2_HTTP_RESPONSE_ACK_CODE_VAL:
+ request->status = HTTP_ACCEPTED;
+ break;
+ case AXIS2_HTTP_RESPONSE_MULTIPLE_CHOICES_CODE_VAL:
+ request->status = HTTP_MULTIPLE_CHOICES;
+ break;
+ case AXIS2_HTTP_RESPONSE_MOVED_PERMANENTLY_CODE_VAL:
+ request->status = HTTP_MOVED_PERMANENTLY;
+ break;
+ case AXIS2_HTTP_RESPONSE_SEE_OTHER_CODE_VAL:
+ request->status = HTTP_SEE_OTHER;
+ break;
+ case AXIS2_HTTP_RESPONSE_NOT_MODIFIED_CODE_VAL:
+ request->status = HTTP_NOT_MODIFIED;
+ break;
+ case AXIS2_HTTP_RESPONSE_TEMPORARY_REDIRECT_CODE_VAL:
+ request->status = HTTP_TEMPORARY_REDIRECT;
+ break;
+ case AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_VAL:
+ request->status = HTTP_BAD_REQUEST;
+ break;
+ case AXIS2_HTTP_RESPONSE_REQUEST_TIMEOUT_CODE_VAL:
+ request->status = HTTP_REQUEST_TIME_OUT;
+ break;
+ case AXIS2_HTTP_RESPONSE_CONFLICT_CODE_VAL:
+ request->status = HTTP_CONFLICT;
+ break;
+ case AXIS2_HTTP_RESPONSE_GONE_CODE_VAL:
+ request->status = HTTP_GONE;
+ break;
+ case AXIS2_HTTP_RESPONSE_PRECONDITION_FAILED_CODE_VAL:
+ request->status = HTTP_PRECONDITION_FAILED;
+ break;
+ case AXIS2_HTTP_RESPONSE_REQUEST_ENTITY_TOO_LARGE_CODE_VAL:
+ request->status = HTTP_REQUEST_ENTITY_TOO_LARGE;
+ break;
+ case AXIS2_HTTP_RESPONSE_SERVICE_UNAVAILABLE_CODE_VAL:
+ request->status = HTTP_SERVICE_UNAVAILABLE;
+ break;
+ default:
+ request->status = HTTP_OK;
+ break;
+ }
+ send_status = DONE;
+ }
+ }
+ }
+ if (send_status == DECLINED)
+ {
+ send_status = OK;
+ if (out_stream)
+ {
+ body_string = axutil_stream_get_buffer(out_stream, env);
+ body_string_len = axutil_stream_get_len(out_stream, env);
+ }
+ }
+ }
+ else if (op_ctx)
+ {
+ if (do_rest)
+ {
+ axis2_msg_ctx_t *out_msg_ctx = NULL;
+ axis2_msg_ctx_t *in_msg_ctx = NULL;
+ axis2_msg_ctx_t **msg_ctx_map = NULL;
+
+ msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
+ out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
+ in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
+ if (in_msg_ctx)
+ {
+ /* TODO: Add necessary handling */
+ }
+ if (out_msg_ctx)
+ {
+ int size = 0;
+ axutil_array_list_t *output_header_list = NULL;
+ output_header_list = axis2_msg_ctx_get_http_output_headers(out_msg_ctx, env);
+ if (output_header_list)
+ {
+ size = axutil_array_list_size(output_header_list, env);
+ }
+ while (size)
+ {
+ axis2_http_header_t *output_header = NULL;
+ size--;
+ output_header = (axis2_http_header_t *)
+ axutil_array_list_get(output_header_list, env, size);
+ apr_table_set(request->err_headers_out,
+ axis2_http_header_get_name(output_header, env),
+ axis2_http_header_get_value(output_header, env));
+ }
+ if (axis2_msg_ctx_get_no_content(out_msg_ctx, env))
+ {
+ if (axis2_msg_ctx_get_status_code(out_msg_ctx, env))
+ {
+ int status_code = axis2_msg_ctx_get_status_code(out_msg_ctx, env);
+ switch (status_code)
+ {
+ case AXIS2_HTTP_RESPONSE_RESET_CONTENT_CODE_VAL:
+ request->status = HTTP_RESET_CONTENT;
+ break;
+ case AXIS2_HTTP_RESPONSE_NOT_MODIFIED_CODE_VAL:
+ request->status = HTTP_NOT_MODIFIED;
+ break;
+ default:
+ request->status = HTTP_NO_CONTENT;
+ break;
+ }
+ }
+ else
+ {
+ request->status = HTTP_NO_CONTENT;
+ }
+ send_status = DONE;
+ }
+ else if (axis2_msg_ctx_get_status_code(out_msg_ctx, env))
+ {
+ int status_code = axis2_msg_ctx_get_status_code(out_msg_ctx, env);
+ switch (status_code)
+ {
+ case AXIS2_HTTP_RESPONSE_CONTINUE_CODE_VAL:
+ request->status = HTTP_CONTINUE;
+ break;
+ case AXIS2_HTTP_RESPONSE_OK_CODE_VAL:
+ request->status = HTTP_OK;
+ break;
+ case AXIS2_HTTP_RESPONSE_MULTIPLE_CHOICES_CODE_VAL:
+ request->status = HTTP_MULTIPLE_CHOICES;
+ break;
+ case AXIS2_HTTP_RESPONSE_MOVED_PERMANENTLY_CODE_VAL:
+ request->status = HTTP_MOVED_PERMANENTLY;
+ break;
+ case AXIS2_HTTP_RESPONSE_SEE_OTHER_CODE_VAL:
+ request->status = HTTP_SEE_OTHER;
+ break;
+ case AXIS2_HTTP_RESPONSE_NOT_MODIFIED_CODE_VAL:
+ request->status = HTTP_NOT_MODIFIED;
+ break;
+ case AXIS2_HTTP_RESPONSE_TEMPORARY_REDIRECT_CODE_VAL:
+ request->status = HTTP_TEMPORARY_REDIRECT;
+ break;
+ case AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_VAL:
+ request->status = HTTP_BAD_REQUEST;
+ break;
+ case AXIS2_HTTP_RESPONSE_REQUEST_TIMEOUT_CODE_VAL:
+ request->status = HTTP_REQUEST_TIME_OUT;
+ break;
+ case AXIS2_HTTP_RESPONSE_CONFLICT_CODE_VAL:
+ request->status = HTTP_CONFLICT;
+ break;
+ case AXIS2_HTTP_RESPONSE_GONE_CODE_VAL:
+ request->status = HTTP_GONE;
+ break;
+ case AXIS2_HTTP_RESPONSE_PRECONDITION_FAILED_CODE_VAL:
+ request->status = HTTP_PRECONDITION_FAILED;
+ break;
+ case AXIS2_HTTP_RESPONSE_REQUEST_ENTITY_TOO_LARGE_CODE_VAL:
+ request->status = HTTP_REQUEST_ENTITY_TOO_LARGE;
+ break;
+ case AXIS2_HTTP_RESPONSE_SERVICE_UNAVAILABLE_CODE_VAL:
+ request->status = HTTP_SERVICE_UNAVAILABLE;
+ break;
+ default:
+ request->status = HTTP_ACCEPTED;
+ break;
+ }
+ send_status = DONE;
+ }
+ }
+ }
+ if (send_status == DECLINED)
+ {
+ if (msg_ctx)
+ {
+ int size = 0;
+ int status_code;
+ axutil_array_list_t *output_header_list = NULL;
+ output_header_list = axis2_msg_ctx_get_http_output_headers(msg_ctx, env);
+ if (output_header_list)
+ {
+ size = axutil_array_list_size(output_header_list, env);
+ }
+ while (size)
+ {
+ axis2_http_header_t *output_header = NULL;
+ size--;
+ output_header = (axis2_http_header_t *)
+ axutil_array_list_get(output_header_list, env, size);
+ apr_table_set(request->err_headers_out,
+ axis2_http_header_get_name(output_header, env),
+ axis2_http_header_get_value(output_header, env));
+ }
+
+ status_code = axis2_msg_ctx_get_status_code(msg_ctx, env);
+ switch (status_code)
+ {
+ case AXIS2_HTTP_RESPONSE_CONTINUE_CODE_VAL:
+ request->status = HTTP_CONTINUE;
+ break;
+ case AXIS2_HTTP_RESPONSE_OK_CODE_VAL:
+ request->status = HTTP_OK;
+ break;
+ case AXIS2_HTTP_RESPONSE_MULTIPLE_CHOICES_CODE_VAL:
+ request->status = HTTP_MULTIPLE_CHOICES;
+ break;
+ case AXIS2_HTTP_RESPONSE_MOVED_PERMANENTLY_CODE_VAL:
+ request->status = HTTP_MOVED_PERMANENTLY;
+ break;
+ case AXIS2_HTTP_RESPONSE_SEE_OTHER_CODE_VAL:
+ request->status = HTTP_SEE_OTHER;
+ break;
+ case AXIS2_HTTP_RESPONSE_NOT_MODIFIED_CODE_VAL:
+ request->status = HTTP_NOT_MODIFIED;
+ break;
+ case AXIS2_HTTP_RESPONSE_TEMPORARY_REDIRECT_CODE_VAL:
+ request->status = HTTP_TEMPORARY_REDIRECT;
+ break;
+ case AXIS2_HTTP_RESPONSE_BAD_REQUEST_CODE_VAL:
+ request->status = HTTP_BAD_REQUEST;
+ break;
+ case AXIS2_HTTP_RESPONSE_REQUEST_TIMEOUT_CODE_VAL:
+ request->status = HTTP_REQUEST_TIME_OUT;
+ break;
+ case AXIS2_HTTP_RESPONSE_CONFLICT_CODE_VAL:
+ request->status = HTTP_CONFLICT;
+ break;
+ case AXIS2_HTTP_RESPONSE_GONE_CODE_VAL:
+ request->status = HTTP_GONE;
+ break;
+ case AXIS2_HTTP_RESPONSE_PRECONDITION_FAILED_CODE_VAL:
+ request->status = HTTP_PRECONDITION_FAILED;
+ break;
+ case AXIS2_HTTP_RESPONSE_REQUEST_ENTITY_TOO_LARGE_CODE_VAL:
+ request->status = HTTP_REQUEST_ENTITY_TOO_LARGE;
+ break;
+ case AXIS2_HTTP_RESPONSE_SERVICE_UNAVAILABLE_CODE_VAL:
+ request->status = HTTP_SERVICE_UNAVAILABLE;
+ break;
+ case AXIS2_HTTP_RESPONSE_FORBIDDEN_CODE_VAL:
+ request->status = HTTP_FORBIDDEN;
+ break;
+ case AXIS2_HTTP_RESPONSE_HTTP_UNAUTHORIZED_CODE_VAL:
+ request->status = HTTP_UNAUTHORIZED;
+ break;
+ default:
+ request->status = HTTP_ACCEPTED;
+ break;
+ }
+
+ out_stream = axis2_msg_ctx_get_transport_out_stream(msg_ctx, env);
+ if (out_stream)
+ {
+ body_string = axutil_stream_get_buffer(out_stream, env);
+ body_string_len = axutil_stream_get_len(out_stream, env);
+ }
+ send_status = DONE;
+ }
+ else
+ {
+ request->status = HTTP_ACCEPTED;
+ send_status = DONE;
+ }
+ }
+ }
+ else
+ {
+ send_status = DONE;
+ request->status = HTTP_ACCEPTED;
+ }
+ }
+
+ if (content_language_header_value)
+ {
+ apr_table_set(request->err_headers_out, AXIS2_HTTP_HEADER_CONTENT_LANGUAGE,
+ content_language_header_value);
+ }
+
+ if (op_ctx)
+ {
+ axis2_msg_ctx_t *out_msg_ctx = NULL,
+ *in_msg_ctx = NULL;
+ axis2_msg_ctx_t **msg_ctx_map = NULL;
+ axis2_char_t *msg_id = NULL;
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
+
+ out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
+ in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
+
+ /* In mtom case we send the attachment differently */
+
+ /* status = AXIS2_FAILURE means fault scenario. We are not
+ * doing MTOM for fault cases. */
+
+ if(status != AXIS2_FAILURE)
+ {
+ do_mtom = axis2_msg_ctx_get_doing_mtom(out_msg_ctx, env);
+ if(do_mtom)
+ {
+ mime_parts = axis2_msg_ctx_get_mime_parts(out_msg_ctx, env);
+ if(!mime_parts)
+ {
+ return AXIS2_FAILURE;
+ }
+ callback_name_param = axis2_msg_ctx_get_parameter(msg_ctx, env ,
+ AXIS2_MTOM_SENDING_CALLBACK);
+ if(callback_name_param)
+ {
+ mtom_sending_callback_name =
+ (axis2_char_t *) axutil_param_get_value (callback_name_param, env);
+ }
+ }
+ }
+
+ if (out_msg_ctx)
+ {
+ axis2_msg_ctx_free(out_msg_ctx, env);
+ out_msg_ctx = NULL;
+ msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT] = NULL;
+ }
+
+ if (in_msg_ctx)
+ {
+ msg_id =
+ axutil_strdup(env, axis2_msg_ctx_get_msg_id(in_msg_ctx, env));
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(in_msg_ctx, env);
+ axis2_msg_ctx_reset_out_transport_info(in_msg_ctx, env);
+ axis2_msg_ctx_free(in_msg_ctx, env);
+ in_msg_ctx = NULL;
+ msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN] = NULL;
+ }
+
+ if (!axis2_op_ctx_is_in_use(op_ctx, env))
+ {
+ axis2_op_ctx_destroy_mutex(op_ctx, env);
+ if (conf_ctx && msg_id)
+ {
+ axis2_conf_ctx_register_op_ctx(conf_ctx, env, msg_id, NULL);
+ AXIS2_FREE(env->allocator, msg_id);
+ }
+ axis2_op_ctx_free(op_ctx, env);
+ }
+
+ } /* Done freeing message contexts */
+
+ /* We send the message in parts when doing MTOM */
+
+ if(do_mtom)
+ {
+ axis2_status_t mtom_status = AXIS2_FAILURE;
+
+ if(!mtom_sending_callback_name)
+ {
+ /* If the callback name is not there, then we will check whether there
+ * is any mime_parts which has type callback. If we found then no point
+ * of continuing we should return a failure */
+
+ if(!mtom_sending_callback_name)
+ {
+ if(axis2_http_transport_utils_is_callback_required(
+ env, mime_parts))
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Sender callback not specified");
+ return AXIS2_FAILURE;
+ }
+ }
+ }
+
+ mtom_status = apache2_worker_send_mtom_message(request, env, mime_parts,
+ mtom_sending_callback_name);
+ if(mtom_status == AXIS2_SUCCESS)
+ {
+ send_status = DONE;
+ }
+ else
+ {
+ send_status = DECLINED;
+ }
+
+ axis2_http_transport_utils_destroy_mime_parts(mime_parts, env);
+ mime_parts = NULL;
+ }
+
+ else if (body_string)
+ {
+ ap_rwrite(body_string, body_string_len, request);
+ body_string = NULL;
+ }
+
+ if (request_body)
+ {
+ axutil_stream_free(request_body, env);
+ request_body = NULL;
+ }
+
+ axutil_string_free(soap_action, env);
+
+ msg_ctx = NULL;
+ return send_status;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+axis2_apache2_worker_get_bytes(
+ const axutil_env_t * env,
+ axutil_stream_t * stream)
+{
+
+ axutil_stream_t *tmp_stream = NULL;
+ int return_size = -1;
+ axis2_char_t *buffer = NULL;
+ axis2_bool_t loop_status = AXIS2_TRUE;
+
+ AXIS2_ENV_CHECK(env, NULL);
+ AXIS2_PARAM_CHECK(env->error, stream, NULL);
+
+ tmp_stream = axutil_stream_create_basic(env);
+ while(loop_status)
+ {
+ int read = 0;
+ int write = 0;
+
+ char buf[READ_SIZE];
+ read = axutil_stream_read(stream, env, buf, READ_SIZE);
+ if(read < 0)
+ {
+ break;
+ }
+ write = axutil_stream_write(tmp_stream, env, buf, read);
+ if(read < (READ_SIZE - 1))
+ {
+ break;
+ }
+ }
+ return_size = axutil_stream_get_len(tmp_stream, env);
+
+ if(return_size > 0)
+ {
+ buffer = (char *)AXIS2_MALLOC(env->allocator, sizeof(char) * (return_size + 2));
+ return_size = axutil_stream_read(tmp_stream, env, buffer, return_size + 1);
+ buffer[return_size + 1] = '\0';
+ }
+ axutil_stream_free(tmp_stream, env);
+ return buffer;
+}
+
+static axis2_status_t
+apache2_worker_send_mtom_message(
+ request_rec *request,
+ const axutil_env_t * env,
+ axutil_array_list_t *mime_parts,
+ axis2_char_t *mtom_sending_callback_name)
+{
+ int i = 0;
+ axiom_mime_part_t *mime_part = NULL;
+ axis2_status_t status = AXIS2_SUCCESS;
+ /*int written = 0;*/
+ int len = 0;
+
+ if(mime_parts)
+ {
+ for(i = 0; i < axutil_array_list_size(mime_parts, env); i++)
+ {
+ mime_part = (axiom_mime_part_t *)axutil_array_list_get(mime_parts, env, i);
+ if((mime_part->type) == AXIOM_MIME_PART_BUFFER)
+ {
+ len = 0;
+ len = ap_rwrite(mime_part->part, (int)mime_part->part_size, request);
+ ap_rflush(request);
+ if(len == -1)
+ {
+ status = AXIS2_FAILURE;
+ break;
+ }
+ }
+ else if((mime_part->type) == AXIOM_MIME_PART_FILE)
+ {
+ FILE *f = NULL;
+ axis2_byte_t *output_buffer = NULL;
+ int output_buffer_size = 0;
+
+ f = fopen(mime_part->file_name, "rb");
+ if(!f)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error opening file %s for reading",
+ mime_part->file_name);
+ return AXIS2_FAILURE;
+ }
+ if(mime_part->part_size > AXIS2_MTOM_OUTPUT_BUFFER_SIZE)
+ {
+ output_buffer_size = AXIS2_MTOM_OUTPUT_BUFFER_SIZE;
+ }
+ else
+ {
+ output_buffer_size = (int)mime_part->part_size;
+ }
+
+ output_buffer = AXIS2_MALLOC(env->allocator, (output_buffer_size + 1)
+ * sizeof(axis2_char_t));
+
+ status = apache2_worker_send_attachment_using_file(env, request, f, output_buffer,
+ output_buffer_size);
+ if(status == AXIS2_FAILURE)
+ {
+ return status;
+ }
+ }
+ else if((mime_part->type) == AXIOM_MIME_PART_CALLBACK)
+ {
+ void *handler = NULL;
+ axiom_mtom_sending_callback_t *callback = NULL;
+
+ handler = axis2_http_transport_utils_initiate_callback(env,
+ mtom_sending_callback_name, mime_part->user_param, &callback);
+
+ if(handler)
+ {
+ status = apache2_worker_send_attachment_using_callback(env, request, callback,
+ handler, mime_part->user_param);
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "MTOM Sending Callback loading failed");
+ status = AXIS2_FAILURE;
+ }
+ if(callback)
+ {
+ axutil_param_t *param = NULL;
+
+ param = callback->param;
+
+ AXIOM_MTOM_SENDING_CALLBACK_FREE(callback, env);
+ callback = NULL;
+
+ if(param)
+ {
+ axutil_param_free(param, env);
+ param = NULL;
+ }
+
+ }
+
+ if(status == AXIS2_FAILURE)
+ {
+ return status;
+ }
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+ if(status == AXIS2_FAILURE)
+ {
+ break;
+ }
+ }
+ return status;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+}
+
+static axis2_status_t
+apache2_worker_send_attachment_using_file(
+ const axutil_env_t * env,
+ request_rec *request,
+ FILE *fp,
+ axis2_byte_t *buffer,
+ int buffer_size)
+{
+
+ int count = 0;
+ int len = 0;
+ /*int written = 0;*/
+ axis2_status_t status = AXIS2_SUCCESS;
+
+ do
+ {
+ count = (int)fread(buffer, 1, buffer_size + 1, fp);
+ if(ferror(fp))
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in reading file containg the attachment");
+ if(buffer)
+ {
+ AXIS2_FREE(env->allocator, buffer);
+ buffer = NULL;
+ }
+ fclose(fp);
+ return AXIS2_FAILURE;
+ }
+
+ if(count > 0)
+ {
+ len = 0;
+ len = ap_rwrite(buffer, count, request);
+ ap_rflush(request);
+ if(len == -1)
+ {
+ status = AXIS2_FAILURE;
+ break;
+ }
+ }
+ else
+ {
+ if(buffer)
+ {
+ AXIS2_FREE(env->allocator, buffer);
+ buffer = NULL;
+ }
+ fclose(fp);
+ return AXIS2_FAILURE;
+ }
+ memset(buffer, 0, buffer_size);
+ if(status == AXIS2_FAILURE)
+ {
+ if(buffer)
+ {
+ AXIS2_FREE(env->allocator, buffer);
+ buffer = NULL;
+ }
+ fclose(fp);
+ return AXIS2_FAILURE;
+ }
+ }
+ while(!feof(fp));
+
+ fclose(fp);
+ AXIS2_FREE(env->allocator, buffer);
+ buffer = NULL;
+ return AXIS2_SUCCESS;
+}
+
+static axis2_status_t
+apache2_worker_send_attachment_using_callback(
+ const axutil_env_t * env,
+ request_rec *request,
+ axiom_mtom_sending_callback_t *callback,
+ void *handler,
+ void *user_param)
+{
+ int count = 0;
+ int len = 0;
+ axis2_status_t status = AXIS2_SUCCESS;
+ axis2_char_t *buffer = NULL;
+
+ /* Keep on loading the data in a loop until
+ * all the data is sent */
+
+ while((count = AXIOM_MTOM_SENDING_CALLBACK_LOAD_DATA(callback, env, handler, &buffer)) > 0)
+ {
+ len = 0;
+ len = ap_rwrite(buffer, count, request);
+ ap_rflush(request);
+ if(len == -1)
+ {
+ status = AXIS2_FAILURE;
+ break;
+ }
+ }
+
+ if(status == AXIS2_FAILURE)
+ {
+ AXIOM_MTOM_SENDING_CALLBACK_CLOSE_HANDLER(callback, env, handler);
+ return status;
+ }
+
+ status = AXIOM_MTOM_SENDING_CALLBACK_CLOSE_HANDLER(callback, env, handler);
+ return status;
+}
+
+
+static axutil_hash_t*
+axis2_apache_worker_get_headers(
+ const axutil_env_t *env,
+ request_rec *request)
+{
+ int i = 0;
+ axutil_hash_t *header_map = NULL;
+ const apr_array_header_t *tarr;
+ const apr_table_entry_t *telts;
+ axis2_http_header_t * tmp_http_header = NULL;
+
+
+ header_map = axutil_hash_make(env);
+ tarr = apr_table_elts(request->headers_in);
+ telts = (const apr_table_entry_t*)tarr->elts;
+
+ for (i = 0; i < tarr->nelts; i++)
+ {
+ axis2_char_t* tmp_key = (axis2_char_t*) telts[i].key;
+ axis2_char_t* tmp_value = (axis2_char_t*) telts[i].val;
+ tmp_http_header = axis2_http_header_create(env, tmp_key, tmp_value);
+ axutil_hash_set(header_map, tmp_key, AXIS2_HASH_KEY_STRING, tmp_http_header);
+ }
+
+ return header_map;
+
+
+}
diff --git a/src/modules/mod_addr/addr_out_handler.c b/src/modules/mod_addr/addr_out_handler.c
index 21618a7..0967901 100644
--- a/src/modules/mod_addr/addr_out_handler.c
+++ b/src/modules/mod_addr/addr_out_handler.c
@@ -1,862 +1,862 @@
-/*
- * 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.
- */
-
-#include <axis2_handler_desc.h>
-#include <axutil_qname.h>
-#include <axis2_svc.h>
-#include <axiom_soap_header.h>
-#include <axiom_soap_body.h>
-#include <axis2_addr.h>
-#include <axiom_soap_header_block.h>
-#include <axis2_endpoint_ref.h>
-#include <axutil_property.h>
-#include <stdio.h>
-
-axis2_status_t AXIS2_CALL
-axis2_addr_out_handler_invoke(
- struct axis2_handler * handler,
- const axutil_env_t * env,
- struct axis2_msg_ctx * msg_ctx);
-
-axis2_status_t
-axis2_addr_out_handler_add_to_soap_header(
- const axutil_env_t * env,
- axis2_endpoint_ref_t * endpoint_ref,
- const axis2_char_t * type,
- axiom_soap_header_t * soap_header,
- const axis2_char_t * addr_ns);
-
-axis2_status_t
-axis2_addr_out_handler_add_to_header(
- const axutil_env_t * env,
- axis2_endpoint_ref_t * epr,
- axiom_node_t ** parent_node,
- const axis2_char_t * addr_ns);
-
-axis2_status_t
-axis2_addr_out_handler_process_any_content_type(
- const axutil_env_t * env,
- axis2_any_content_type_t * reference_values,
- axiom_node_t * parent_ele_node,
- const axis2_char_t * addr_ns);
-
-axiom_node_t *
-axis2_addr_out_handler_process_string_info(
- const axutil_env_t * env,
- const axis2_char_t * value,
- const axis2_char_t * type,
- axiom_soap_header_t ** soap_header,
- const axis2_char_t * addr_ns,
- axis2_bool_t set_must_understand);
-
-AXIS2_EXTERN axis2_handler_t *AXIS2_CALL
-axis2_addr_out_handler_create(
- const axutil_env_t * env,
- axutil_string_t * name)
-{
- axis2_handler_t *handler = NULL;
-
- AXIS2_ENV_CHECK(env, NULL);
-
- handler = axis2_handler_create(env);
- if(!handler)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create addressing out handler");
- return NULL;
- }
-
- axis2_handler_set_invoke(handler, env, axis2_addr_out_handler_invoke);
-
- return handler;
-}
-
-axis2_status_t AXIS2_CALL
-axis2_addr_out_handler_invoke(
- struct axis2_handler * handler,
- const axutil_env_t * env,
- axis2_msg_ctx_t * msg_ctx)
-{
- axis2_char_t *addr_ver_from_msg_ctx = NULL;
- const axis2_char_t *addr_ns = NULL;
- axis2_msg_info_headers_t *msg_info_headers = NULL;
- axis2_ctx_t *ctx = NULL;
- axiom_soap_envelope_t *soap_envelope = NULL;
- axiom_soap_header_t *soap_header = NULL;
- axiom_node_t *soap_header_node = NULL;
- axiom_element_t *soap_header_ele = NULL;
- axis2_endpoint_ref_t *epr_to = NULL;
- axis2_endpoint_ref_t *epr_reply_to = NULL;
- axis2_endpoint_ref_t *epr_from = NULL;
- axis2_endpoint_ref_t *epr_fault_to = NULL;
- axutil_property_t *property = NULL;
- const axis2_char_t *wsa_action = NULL;
- axis2_bool_t set_must_understand = AXIS2_FALSE;
- axutil_property_t *must_understand_prop;
-
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
-
- AXIS2_LOG_INFO(env->log, "Starting addressing out handler");
-
- soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
- if(!soap_envelope)
- {
- AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No SOAP envelope. Stop processing addressing");
- return AXIS2_SUCCESS; /* Can happen in case of ONE-WAY services/clients */
- }
-
- msg_info_headers = axis2_msg_ctx_get_msg_info_headers(msg_ctx, env);
-
- if(msg_info_headers)
- {
- wsa_action = axis2_msg_info_headers_get_action(msg_info_headers, env);
- }
- else
- {
- AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No addressing in use");
- return AXIS2_SUCCESS; /* No addressing in use */
- }
-
- if(!wsa_action || !*wsa_action)
- {
- AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No action present. Stop processing addressing");
- return AXIS2_SUCCESS; /* If no action present, assume no addressing in use */
- }
-
-
- ctx = axis2_msg_ctx_get_base(msg_ctx, env);
- property = axis2_ctx_get_property(ctx, env, AXIS2_WSA_VERSION);
-
- if(property)
- {
- addr_ver_from_msg_ctx = axutil_property_get_value(property, env);
- property = NULL;
- }
-
- must_understand_prop = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_ADDR_ADD_MUST_UNDERSTAND_TO_ADDR_HEADERS);
- if(must_understand_prop)
- {
- axis2_char_t *value = axutil_property_get_value(must_understand_prop, env);
- if(axutil_strcmp(value, AXIS2_VALUE_TRUE) == 0)
- set_must_understand = AXIS2_TRUE;
- }
-
- /* Setting version 1.0 as the default addressing namespace */
- addr_ns = AXIS2_WSA_NAMESPACE;
-
- if(addr_ver_from_msg_ctx)
- {
- if(!axutil_strcmp(AXIS2_WSA_NAMESPACE_SUBMISSION, addr_ver_from_msg_ctx))
- {
- addr_ns = AXIS2_WSA_NAMESPACE_SUBMISSION;
- }
- }
- else if(axis2_msg_ctx_get_op_ctx(msg_ctx, env))
- {
- axis2_op_ctx_t *op_ctx = NULL;
- axis2_msg_ctx_t *in_msg_ctx = NULL;
- op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
-
- if(op_ctx)
- {
- in_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN);
- }
-
- if(in_msg_ctx)
- {
- axis2_ctx_t *in_ctx = NULL;
- in_ctx = axis2_msg_ctx_get_base(in_msg_ctx, env);
-
- property = axis2_ctx_get_property(in_ctx, env, AXIS2_WSA_VERSION);
- if(property)
- {
- addr_ns = axutil_property_get_value(property, env);
- property = NULL;
- }
-
- if(!addr_ns || !*addr_ns)
- {
- addr_ns = AXIS2_WSA_NAMESPACE;
- }
- }
- }
-
- soap_header = axiom_soap_envelope_get_header(soap_envelope, env);
- if(!soap_header)
- {
- AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No SOAP header. Stop processing addressing");
- return AXIS2_SUCCESS; /* No SOAP header, so no point proceeding */
- }
- else
- {
- /* By this time, we definitely have some addressing information to be sent. This is because,
- * we have tested at the start of this whether msg_info_headers are null or not.
- * So rather than declaring addressing namespace in each and every addressing header, lets
- * define that in the Header itself.
- */
- const axis2_char_t *action = NULL;
- const axis2_char_t *address = NULL;
- const axis2_char_t *svc_group_context_id = NULL;
- const axis2_char_t *message_id = NULL;
- axis2_relates_to_t *relates_to = NULL;
- axiom_node_t *relates_to_header_node = NULL;
- axiom_element_t *relates_to_header_ele = NULL;
- axiom_namespace_t *addressing_namespace = NULL;
-
- soap_header_node = axiom_soap_header_get_base_node(soap_header, env);
- soap_header_ele = (axiom_element_t *)axiom_node_get_data_element(soap_header_node, env);
-
- addressing_namespace = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
-
- axiom_element_declare_namespace(soap_header_ele, env, soap_header_node,
- addressing_namespace);
-
- epr_to = axis2_msg_info_headers_get_to(msg_info_headers, env);
-
- if(epr_to)
- {
- axiom_soap_body_t *body = axiom_soap_envelope_get_body(soap_envelope, env);
-
- if(body)
- {
- /* In case of a SOAP fault, we got to send the response to
- the adress specified by FaultTo */
- if(axiom_soap_body_has_fault(body, env))
- {
- axis2_endpoint_ref_t *epr_fault_to = axis2_msg_info_headers_get_fault_to(
- msg_info_headers, env);
- if(epr_fault_to)
- {
- const axis2_char_t *fault_to_address = axis2_endpoint_ref_get_address(
- epr_fault_to, env);
- if(fault_to_address)
- {
- if(axutil_strcmp(AXIS2_WSA_NONE_URL, fault_to_address)
- && axutil_strcmp(AXIS2_WSA_NONE_URL_SUBMISSION, fault_to_address))
- {
- axis2_endpoint_ref_set_address(epr_to, env, fault_to_address);
- }
- }
- }
- }
- }
-
- address = axis2_endpoint_ref_get_address(epr_to, env);
- if(address && *address)
- {
- axiom_node_t *to_header_block_node = NULL;
- axiom_soap_header_block_t *to_header_block = NULL;
- axutil_array_list_t *ref_param_list = NULL;
- int size = 0;
-
- to_header_block = axiom_soap_header_add_header_block(soap_header, env,
- AXIS2_WSA_TO, addressing_namespace);
- if(set_must_understand == AXIS2_TRUE)
- {
- axiom_soap_header_block_set_must_understand_with_bool(to_header_block, env, AXIS2_TRUE);
- }
- to_header_block_node = axiom_soap_header_block_get_base_node(to_header_block, env);
- if(to_header_block_node)
- {
- axiom_element_t *to_header_block_element = NULL;
- to_header_block_element = (axiom_element_t *)axiom_node_get_data_element(
- to_header_block_node, env);
- if(to_header_block_element)
- {
- axiom_element_set_text(to_header_block_element, env, address,
- to_header_block_node);
- }
- }
-
- ref_param_list = axis2_endpoint_ref_get_ref_param_list(epr_to, env);
-
- size = axutil_array_list_size(ref_param_list, env);
- if(ref_param_list && size > 0)
- {
- axiom_soap_header_block_t *reference_header_block = NULL;
- axiom_node_t *reference_node = NULL;
- int i = 0;
-
- for(i = 0; i < size; i++)
- {
- axiom_node_t *temp_node = NULL;
-
- temp_node = (axiom_node_t *)axutil_array_list_get(ref_param_list, env, i);
- if(temp_node)
- {
- axiom_element_t *temp_ele = NULL;
-
- temp_ele = axiom_node_get_data_element(temp_node, env);
- if(temp_ele)
- {
- reference_header_block = axiom_soap_header_add_header_block(
- soap_header, env, axiom_element_get_localname(temp_ele, env),
- axiom_element_get_namespace(temp_ele, env, temp_node));
- if(set_must_understand)
- {
- axiom_soap_header_block_set_must_understand_with_bool(reference_header_block, env, AXIS2_TRUE);
- }
-
- reference_node = axiom_soap_header_block_get_base_node(
- reference_header_block, env);
- if(reference_node)
- {
- axiom_element_t *reference_ele = NULL;
- reference_ele = (axiom_element_t *)axiom_node_get_data_element(
- reference_node, env);
-
- if(reference_ele)
- {
- axiom_namespace_t *addr_ns_obj = NULL;
- axiom_attribute_t *reference_attr = NULL;
-
- addr_ns_obj = axiom_namespace_create(env, addr_ns,
- AXIS2_WSA_DEFAULT_PREFIX);
- reference_attr = axiom_attribute_create(env,
- /*"isReferenceParameter"*/
- AXIS2_WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE, "true",
- addr_ns_obj);
- axiom_element_add_attribute(reference_ele, env,
- reference_attr, reference_node);
- axiom_element_set_text(reference_ele, env,
- axiom_element_get_text(temp_ele, env, temp_node),
- reference_node);
- }
- }
- }
- }
- }
- }
- }
- }/* if(epr_to) */
-
- axiom_namespace_free(addressing_namespace, env);
-
- action = axis2_msg_info_headers_get_action(msg_info_headers, env);
- if(action && *action)
- {
- axis2_addr_out_handler_process_string_info(env, action, AXIS2_WSA_ACTION, &soap_header,
- addr_ns, set_must_understand);
- }
-
- epr_reply_to = axis2_msg_info_headers_get_reply_to(msg_info_headers, env);
- if(!epr_reply_to)
- {
- const axis2_char_t *anonymous_uri = NULL;
- axis2_bool_t anonymous = axis2_msg_info_headers_get_reply_to_anonymous(
- msg_info_headers, env);
- axis2_bool_t none = axis2_msg_info_headers_get_reply_to_none(msg_info_headers, env);
- if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
- {
- if(none)
- {
- anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION;
- }
- else if(anonymous)
- {
- anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION;
- }
- }
- else
- {
- if(none)
- {
- anonymous_uri = AXIS2_WSA_NONE_URL;
- }
- else if(anonymous)
- {
- anonymous_uri = AXIS2_WSA_ANONYMOUS_URL;
- }
- }
-
- if(anonymous_uri)
- {
- epr_reply_to = axis2_endpoint_ref_create(env, anonymous_uri);
- }
-
- if(epr_reply_to)
- {
- axis2_msg_info_headers_set_reply_to(msg_info_headers, env, epr_reply_to);
- }
- }
-
- /* add the service group id as a reference parameter */
- svc_group_context_id = axutil_string_get_buffer(axis2_msg_ctx_get_svc_grp_ctx_id(msg_ctx,
- env), env);
-
- axis2_addr_out_handler_add_to_soap_header(env, epr_reply_to, AXIS2_WSA_REPLY_TO,
- soap_header, addr_ns);
-
- epr_from = axis2_msg_info_headers_get_from(msg_info_headers, env);
-
- if(epr_from)
- {
- axis2_addr_out_handler_add_to_soap_header(env, epr_from, AXIS2_WSA_FROM, soap_header,
- addr_ns);
-
- }
-
- epr_fault_to = axis2_msg_info_headers_get_fault_to(msg_info_headers, env);
- if(!epr_fault_to)
- {
- const axis2_char_t *anonymous_uri = NULL;
- axis2_bool_t anonymous = axis2_msg_info_headers_get_fault_to_anonymous(
- msg_info_headers, env);
- axis2_bool_t none = axis2_msg_info_headers_get_fault_to_none(msg_info_headers, env);
- if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
- {
- if(none)
- {
- anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION;
- }
- else if(anonymous)
- {
- anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION;
- }
- }
- else
- {
- if(none)
- anonymous_uri = AXIS2_WSA_NONE_URL;
- else if(anonymous)
- anonymous_uri = AXIS2_WSA_ANONYMOUS_URL;
- }
-
- if(anonymous_uri)
- {
- epr_fault_to = axis2_endpoint_ref_create(env, anonymous_uri);
- }
- }
-
- if(epr_fault_to)
- {
- /* optional */
- axis2_addr_out_handler_add_to_soap_header(env, epr_fault_to, AXIS2_WSA_FAULT_TO,
- soap_header, addr_ns);
- }
-
- message_id = axis2_msg_info_headers_get_message_id(msg_info_headers, env);
-
- if(message_id)
- {
- axis2_addr_out_handler_process_string_info(env, message_id, AXIS2_WSA_MESSAGE_ID,
- &soap_header, addr_ns, set_must_understand);
- }
-
- relates_to = axis2_msg_info_headers_get_relates_to(msg_info_headers, env);
-
- if(relates_to)
- {
- const axis2_char_t *value = NULL;
- value = axis2_relates_to_get_value(relates_to, env);
- relates_to_header_node = axis2_addr_out_handler_process_string_info(env, value,
- AXIS2_WSA_RELATES_TO, &soap_header, addr_ns, set_must_understand);
- }
-
- if(relates_to_header_node)
- {
- const axis2_char_t *relationship_type = NULL;
- relationship_type = axis2_relates_to_get_relationship_type(relates_to, env);
- if(relationship_type && *relationship_type)
- {
- axiom_attribute_t *om_attr = NULL;
- axiom_namespace_t *addr_ns_obj = NULL;
- axiom_namespace_t *dec_ns = NULL;
- relates_to_header_ele = (axiom_element_t *)axiom_node_get_data_element(
- relates_to_header_node, env);
- if(relates_to_header_ele)
- {
- dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env,
- addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
- if(dec_ns)
- {
- addr_ns_obj = dec_ns;
- }
- else
- {
- addr_ns_obj
- = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
- }
-
- if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
- {
- om_attr = axiom_attribute_create(env,
- AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE,
- AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE_SUBMISSION,
- addr_ns_obj);
- }
- else
- {
- om_attr = axiom_attribute_create(env,
- AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE,
- AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE, addr_ns_obj);
- }
-
- axiom_element_add_attribute(relates_to_header_ele, env, om_attr,
- relates_to_header_node);
-
- dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env,
- addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
- if(!dec_ns)
- {
- dec_ns = axiom_element_find_namespace(relates_to_header_ele, env,
- relates_to_header_node, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
- if(dec_ns)
- {
- axiom_namespace_free(addr_ns_obj, env);
- addr_ns_obj = NULL;
- axiom_attribute_set_namespace(om_attr, env, dec_ns);
- }
- }
- }
-
- }
- }
- }
- return AXIS2_SUCCESS;
-}
-
-axiom_node_t *
-axis2_addr_out_handler_process_string_info(
- const axutil_env_t * env,
- const axis2_char_t * value,
- const axis2_char_t * type,
- axiom_soap_header_t ** soap_header_p,
- const axis2_char_t * addr_ns,
- axis2_bool_t set_must_understand)
-{
- axiom_soap_header_t *soap_header = NULL;
- axiom_soap_header_block_t *header_block = NULL;
- axiom_node_t *header_block_node = NULL;
- axiom_element_t *header_block_ele = NULL;
-
- AXIS2_ENV_CHECK(env, NULL);
- AXIS2_PARAM_CHECK(env->error, value, NULL);
- AXIS2_PARAM_CHECK(env->error, type, NULL);
- AXIS2_PARAM_CHECK(env->error, soap_header_p, NULL);
- AXIS2_PARAM_CHECK(env->error, addr_ns, NULL);
-
- soap_header = *(soap_header_p);
-
- if(value && *value)
- {
- axiom_namespace_t *addr_ns_obj = NULL;
- addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
- header_block = axiom_soap_header_add_header_block(soap_header, env, type, addr_ns_obj);
- header_block_node = axiom_soap_header_block_get_base_node(header_block, env);
- header_block_ele = (axiom_element_t *)axiom_node_get_data_element(header_block_node, env);
- if(header_block_ele)
- {
- axiom_namespace_t *dec_ns = NULL;
- axiom_element_set_text(header_block_ele, env, value, header_block_node);
- dec_ns = axiom_element_find_declared_namespace(header_block_ele, env, addr_ns,
- AXIS2_WSA_DEFAULT_PREFIX);
- if(!dec_ns)
- {
- axiom_namespace_free(addr_ns_obj, env);
- addr_ns_obj = NULL;
- }
- }
- if(set_must_understand)
- {
- axiom_soap_header_block_set_must_understand_with_bool(header_block, env, AXIS2_TRUE);
- }
- }
- return header_block_node;
-}
-
-axis2_status_t
-axis2_addr_out_handler_add_to_soap_header(
- const axutil_env_t * env,
- axis2_endpoint_ref_t * endpoint_ref,
- const axis2_char_t * type,
- axiom_soap_header_t * soap_header,
- const axis2_char_t * addr_ns)
-{
- axiom_soap_header_block_t *header_block = NULL;
- const axis2_char_t *address = NULL;
- axutil_array_list_t *ref_param_list = NULL;
- axutil_array_list_t *meta_data_list = NULL;
- axutil_array_list_t *extension_list = NULL;
- axiom_node_t *header_block_node = NULL;
- axiom_node_t *header_node = NULL;
- axiom_namespace_t *addr_ns_obj = NULL;
- int size = 0;
-
- AXIS2_PARAM_CHECK(env->error, endpoint_ref, AXIS2_FAILURE);
- AXIS2_PARAM_CHECK(env->error, type, AXIS2_FAILURE);
- AXIS2_PARAM_CHECK(env->error, soap_header, AXIS2_FAILURE);
-
- header_node = axiom_soap_header_get_base_node(soap_header, env);
-
- addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
- header_block = axiom_soap_header_add_header_block(soap_header, env, type, addr_ns_obj);
- if(addr_ns_obj)
- {
- axiom_namespace_free(addr_ns_obj, env);
- addr_ns_obj = NULL;
- }
-
- address = axis2_endpoint_ref_get_address(endpoint_ref, env);
- if(address && *address)
- {
- axiom_node_t *hb_node = NULL;
- axiom_element_t *hb_ele = NULL;
- axiom_node_t *address_node = NULL;
- axiom_element_t *address_ele = NULL;
- hb_node = axiom_soap_header_block_get_base_node(header_block, env);
- hb_ele = (axiom_element_t *)axiom_node_get_data_element(hb_node, env);
-
- addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
-
- address_ele = axiom_element_create(env, hb_node, EPR_ADDRESS, addr_ns_obj, &address_node);
- axiom_namespace_free(addr_ns_obj, env);
- if(address_ele)
- {
- axiom_namespace_t *dec_ns = NULL;
- axiom_element_set_text(address_ele, env, address, address_node);
- dec_ns = axiom_element_find_declared_namespace(address_ele, env, addr_ns,
- AXIS2_WSA_DEFAULT_PREFIX);
- }
- }
-
- header_block_node = axiom_soap_header_block_get_base_node(header_block, env);
- axis2_addr_out_handler_add_to_header(env, endpoint_ref, &header_block_node, addr_ns);
-
- ref_param_list = axis2_endpoint_ref_get_ref_param_list(endpoint_ref, env);
- if(ref_param_list && axutil_array_list_size(ref_param_list, env) > 0)
- {
- axiom_node_t *reference_node = NULL;
- axiom_element_t *reference_ele = NULL;
- axutil_array_list_t *ref_attribute_list = NULL;
- int i = 0;
-
- addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
-
- reference_ele = axiom_element_create(env, header_block_node, EPR_REFERENCE_PARAMETERS,
- addr_ns_obj, &reference_node);
- axiom_namespace_free(addr_ns_obj, env);
-
- ref_attribute_list = axis2_endpoint_ref_get_ref_attribute_list(endpoint_ref, env);
- if(ref_attribute_list)
- {
- int j = 0;
-
- size = axutil_array_list_size(ref_attribute_list, env);
- for(j = 0; j < size; j++)
- {
- axiom_attribute_t *attr = (axiom_attribute_t *)axutil_array_list_get(
- ref_attribute_list, env, j);
- if(attr)
- {
- axiom_element_add_attribute(reference_ele, env, attr, reference_node);
- }
- }
- }
-
- size = axutil_array_list_size(ref_param_list, env);
- for(i = 0; i < size; i++)
- {
- axiom_node_t *ref_node = (axiom_node_t *)axutil_array_list_get(ref_param_list, env, i);
- if(ref_node)
- {
- axiom_node_add_child(reference_node, env, ref_node);
- }
- }
-
- }
-
- meta_data_list = axis2_endpoint_ref_get_metadata_list(endpoint_ref, env);
- if(meta_data_list && axutil_array_list_size(meta_data_list, env) > 0)
- {
- axiom_node_t *reference_node = NULL;
- axiom_element_t *reference_ele = NULL;
- axutil_array_list_t *meta_attribute_list = NULL;
- int i = 0;
-
- if(!reference_node) /* may be we alredy created this in ref params block */
- {
- addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
-
- reference_ele = axiom_element_create(env, header_block_node, AXIS2_WSA_METADATA,
- addr_ns_obj, &reference_node);
- axiom_namespace_free(addr_ns_obj, env);
- }
-
- meta_attribute_list = axis2_endpoint_ref_get_metadata_attribute_list(endpoint_ref, env);
- if(meta_attribute_list)
- {
- int j = 0;
- size = axutil_array_list_size(meta_attribute_list, env);
- for(j = 0; j < size; j++)
- {
- axiom_attribute_t *attr = (axiom_attribute_t *)axutil_array_list_get(
- meta_attribute_list, env, j);
- if(attr)
- {
- axiom_element_add_attribute(reference_ele, env, attr, reference_node);
- }
- }
- }
-
- size = axutil_array_list_size(meta_data_list, env);
- for(i = 0; i < size; i++)
- {
- axiom_node_t *ref_node = (axiom_node_t *)axutil_array_list_get(meta_data_list, env, i);
- if(ref_node)
- {
- axiom_node_add_child(reference_node, env, ref_node);
- }
- }
- }
-
- extension_list = axis2_endpoint_ref_get_extension_list(endpoint_ref, env);
- if(extension_list && axutil_array_list_size(extension_list, env) > 0)
- {
- int i = 0;
-
- size = axutil_array_list_size(extension_list, env);
- for(i = 0; i < size; i++)
- {
- axiom_node_t *ref_node = (axiom_node_t *)axutil_array_list_get(extension_list, env, i);
- if(ref_node)
- {
- axiom_node_add_child(header_block_node, env, ref_node);
- }
- }
- }
-
- return AXIS2_SUCCESS;
-}
-
-axis2_status_t
-axis2_addr_out_handler_add_to_header(
- const axutil_env_t * env,
- axis2_endpoint_ref_t * epr,
- axiom_node_t ** parent_node_p,
- const axis2_char_t * addr_ns)
-{
- axiom_node_t *parent_node = NULL;
- const axutil_qname_t *interface_qname = NULL;
- axiom_node_t *interface_node = NULL;
- axiom_element_t *interface_ele = NULL;
- const axis2_char_t *element_localname = NULL;
- axis2_svc_name_t *service_name = NULL;
- axiom_namespace_t *addr_ns_obj = NULL;
-
- AXIS2_PARAM_CHECK(env->error, epr, AXIS2_FAILURE);
- AXIS2_PARAM_CHECK(env->error, parent_node_p, AXIS2_FAILURE);
-
- parent_node = *(parent_node_p);
-
- interface_qname = axis2_endpoint_ref_get_interface_qname(epr, env);
-
- if(interface_qname)
- {
- axis2_char_t *text = NULL;
- axis2_char_t *qname_prefix = NULL;
- axis2_char_t *qname_localpart = NULL;
-
- addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
-
- if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
- {
- element_localname = EPR_PORT_TYPE;
- }
- else
- {
- element_localname = AXIS2_WSA_INTERFACE_NAME;
- }
-
- interface_ele = axiom_element_create(env, parent_node, element_localname, addr_ns_obj,
- &interface_node);
- qname_prefix = axutil_qname_get_prefix(interface_qname, env);
- qname_localpart = axutil_qname_get_localpart(interface_qname, env);
-
- text = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (axutil_strlen(qname_prefix)
- + axutil_strlen(qname_localpart) + 2));
- sprintf(text, "%s:%s", qname_prefix, qname_localpart);
- axiom_element_set_text(interface_ele, env, text, interface_node);
- AXIS2_FREE(env->allocator, text);
- if(interface_ele)
- {
- axiom_namespace_t *dec_ns = NULL;
- dec_ns = axiom_element_find_declared_namespace(interface_ele, env, addr_ns,
- AXIS2_WSA_DEFAULT_PREFIX);
- if(!dec_ns)
- {
- axiom_namespace_free(addr_ns_obj, env);
- addr_ns_obj = NULL;
- }
- }
-
- }
-
- service_name = axis2_endpoint_ref_get_svc_name(epr, env);
- return AXIS2_SUCCESS;
-}
-
-axis2_status_t
-axis2_addr_out_handler_process_any_content_type(
- const axutil_env_t * env,
- axis2_any_content_type_t * reference_values,
- axiom_node_t * parent_ele_node,
- const axis2_char_t * addr_ns)
-{
- axutil_hash_t *value_ht = NULL;
- axutil_hash_index_t *hash_index = NULL;
-
- if(reference_values)
- {
- const void *key = NULL;
- void *val = NULL;
- axis2_ssize_t len = 0;
- value_ht = axis2_any_content_type_get_value_map(reference_values, env);
- if(!value_ht)
- {
- return AXIS2_FAILURE;
- }
-
- for(hash_index = axutil_hash_first(value_ht, env); hash_index; hash_index
- = axutil_hash_next(env, hash_index))
- {
- axutil_hash_this(hash_index, &key, &len, &val);
- if(key)
- {
- axiom_node_t *node = NULL;
- axiom_element_t *ele = NULL;
- ele = axiom_element_create(env, parent_ele_node, key, NULL, &node);
- if(ele)
- {
- if(!axutil_strcmp(AXIS2_WSA_NAMESPACE, addr_ns))
- {
- axiom_namespace_t *addr_ns_obj = NULL;
- axiom_attribute_t *att = NULL;
- addr_ns_obj
- = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
- att = axiom_attribute_create(env,
- AXIS2_WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE,
- AXIS2_WSA_TYPE_ATTRIBUTE_VALUE, addr_ns_obj);
- }
- axiom_element_set_text(ele, env, val, node);
- }
- }
- }
- }
- return AXIS2_SUCCESS;
-}
+/*
+ * 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.
+ */
+
+#include <axis2_handler_desc.h>
+#include <axutil_qname.h>
+#include <axis2_svc.h>
+#include <axiom_soap_header.h>
+#include <axiom_soap_body.h>
+#include <axis2_addr.h>
+#include <axiom_soap_header_block.h>
+#include <axis2_endpoint_ref.h>
+#include <axutil_property.h>
+#include <stdio.h>
+
+axis2_status_t AXIS2_CALL
+axis2_addr_out_handler_invoke(
+ struct axis2_handler * handler,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * msg_ctx);
+
+axis2_status_t
+axis2_addr_out_handler_add_to_soap_header(
+ const axutil_env_t * env,
+ axis2_endpoint_ref_t * endpoint_ref,
+ const axis2_char_t * type,
+ axiom_soap_header_t * soap_header,
+ const axis2_char_t * addr_ns);
+
+axis2_status_t
+axis2_addr_out_handler_add_to_header(
+ const axutil_env_t * env,
+ axis2_endpoint_ref_t * epr,
+ axiom_node_t ** parent_node,
+ const axis2_char_t * addr_ns);
+
+axis2_status_t
+axis2_addr_out_handler_process_any_content_type(
+ const axutil_env_t * env,
+ axis2_any_content_type_t * reference_values,
+ axiom_node_t * parent_ele_node,
+ const axis2_char_t * addr_ns);
+
+axiom_node_t *
+axis2_addr_out_handler_process_string_info(
+ const axutil_env_t * env,
+ const axis2_char_t * value,
+ const axis2_char_t * type,
+ axiom_soap_header_t ** soap_header,
+ const axis2_char_t * addr_ns,
+ axis2_bool_t set_must_understand);
+
+AXIS2_EXTERN axis2_handler_t *AXIS2_CALL
+axis2_addr_out_handler_create(
+ const axutil_env_t * env,
+ axutil_string_t * name)
+{
+ axis2_handler_t *handler = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ handler = axis2_handler_create(env);
+ if(!handler)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create addressing out handler");
+ return NULL;
+ }
+
+ axis2_handler_set_invoke(handler, env, axis2_addr_out_handler_invoke);
+
+ return handler;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_addr_out_handler_invoke(
+ struct axis2_handler * handler,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_char_t *addr_ver_from_msg_ctx = NULL;
+ const axis2_char_t *addr_ns = NULL;
+ axis2_msg_info_headers_t *msg_info_headers = NULL;
+ axis2_ctx_t *ctx = NULL;
+ axiom_soap_envelope_t *soap_envelope = NULL;
+ axiom_soap_header_t *soap_header = NULL;
+ axiom_node_t *soap_header_node = NULL;
+ axiom_element_t *soap_header_ele = NULL;
+ axis2_endpoint_ref_t *epr_to = NULL;
+ axis2_endpoint_ref_t *epr_reply_to = NULL;
+ axis2_endpoint_ref_t *epr_from = NULL;
+ axis2_endpoint_ref_t *epr_fault_to = NULL;
+ axutil_property_t *property = NULL;
+ const axis2_char_t *wsa_action = NULL;
+ axis2_bool_t set_must_understand = AXIS2_FALSE;
+ axutil_property_t *must_understand_prop;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ AXIS2_LOG_INFO(env->log, "Starting addressing out handler");
+
+ soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
+ if(!soap_envelope)
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No SOAP envelope. Stop processing addressing");
+ return AXIS2_SUCCESS; /* Can happen in case of ONE-WAY services/clients */
+ }
+
+ msg_info_headers = axis2_msg_ctx_get_msg_info_headers(msg_ctx, env);
+
+ if(msg_info_headers)
+ {
+ wsa_action = axis2_msg_info_headers_get_action(msg_info_headers, env);
+ }
+ else
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No addressing in use");
+ return AXIS2_SUCCESS; /* No addressing in use */
+ }
+
+ if(!wsa_action || !*wsa_action)
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No action present. Stop processing addressing");
+ return AXIS2_SUCCESS; /* If no action present, assume no addressing in use */
+ }
+
+
+ ctx = axis2_msg_ctx_get_base(msg_ctx, env);
+ property = axis2_ctx_get_property(ctx, env, AXIS2_WSA_VERSION);
+
+ if(property)
+ {
+ addr_ver_from_msg_ctx = axutil_property_get_value(property, env);
+ property = NULL;
+ }
+
+ must_understand_prop = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_ADDR_ADD_MUST_UNDERSTAND_TO_ADDR_HEADERS);
+ if(must_understand_prop)
+ {
+ axis2_char_t *value = axutil_property_get_value(must_understand_prop, env);
+ if(axutil_strcmp(value, AXIS2_VALUE_TRUE) == 0)
+ set_must_understand = AXIS2_TRUE;
+ }
+
+ /* Setting version 1.0 as the default addressing namespace */
+ addr_ns = AXIS2_WSA_NAMESPACE;
+
+ if(addr_ver_from_msg_ctx)
+ {
+ if(!axutil_strcmp(AXIS2_WSA_NAMESPACE_SUBMISSION, addr_ver_from_msg_ctx))
+ {
+ addr_ns = AXIS2_WSA_NAMESPACE_SUBMISSION;
+ }
+ }
+ else if(axis2_msg_ctx_get_op_ctx(msg_ctx, env))
+ {
+ axis2_op_ctx_t *op_ctx = NULL;
+ axis2_msg_ctx_t *in_msg_ctx = NULL;
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+
+ if(op_ctx)
+ {
+ in_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN);
+ }
+
+ if(in_msg_ctx)
+ {
+ axis2_ctx_t *in_ctx = NULL;
+ in_ctx = axis2_msg_ctx_get_base(in_msg_ctx, env);
+
+ property = axis2_ctx_get_property(in_ctx, env, AXIS2_WSA_VERSION);
+ if(property)
+ {
+ addr_ns = axutil_property_get_value(property, env);
+ property = NULL;
+ }
+
+ if(!addr_ns || !*addr_ns)
+ {
+ addr_ns = AXIS2_WSA_NAMESPACE;
+ }
+ }
+ }
+
+ soap_header = axiom_soap_envelope_get_header(soap_envelope, env);
+ if(!soap_header)
+ {
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No SOAP header. Stop processing addressing");
+ return AXIS2_SUCCESS; /* No SOAP header, so no point proceeding */
+ }
+ else
+ {
+ /* By this time, we definitely have some addressing information to be sent. This is because,
+ * we have tested at the start of this whether msg_info_headers are null or not.
+ * So rather than declaring addressing namespace in each and every addressing header, lets
+ * define that in the Header itself.
+ */
+ const axis2_char_t *action = NULL;
+ const axis2_char_t *address = NULL;
+ const axis2_char_t *svc_group_context_id = NULL;
+ const axis2_char_t *message_id = NULL;
+ axis2_relates_to_t *relates_to = NULL;
+ axiom_node_t *relates_to_header_node = NULL;
+ axiom_element_t *relates_to_header_ele = NULL;
+ axiom_namespace_t *addressing_namespace = NULL;
+
+ soap_header_node = axiom_soap_header_get_base_node(soap_header, env);
+ soap_header_ele = (axiom_element_t *)axiom_node_get_data_element(soap_header_node, env);
+
+ addressing_namespace = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+
+ axiom_element_declare_namespace(soap_header_ele, env, soap_header_node,
+ addressing_namespace);
+
+ epr_to = axis2_msg_info_headers_get_to(msg_info_headers, env);
+
+ if(epr_to)
+ {
+ axiom_soap_body_t *body = axiom_soap_envelope_get_body(soap_envelope, env);
+
+ if(body)
+ {
+ /* In case of a SOAP fault, we got to send the response to
+ the adress specified by FaultTo */
+ if(axiom_soap_body_has_fault(body, env))
+ {
+ axis2_endpoint_ref_t *epr_fault_to = axis2_msg_info_headers_get_fault_to(
+ msg_info_headers, env);
+ if(epr_fault_to)
+ {
+ const axis2_char_t *fault_to_address = axis2_endpoint_ref_get_address(
+ epr_fault_to, env);
+ if(fault_to_address)
+ {
+ if(axutil_strcmp(AXIS2_WSA_NONE_URL, fault_to_address)
+ && axutil_strcmp(AXIS2_WSA_NONE_URL_SUBMISSION, fault_to_address))
+ {
+ axis2_endpoint_ref_set_address(epr_to, env, fault_to_address);
+ }
+ }
+ }
+ }
+ }
+
+ address = axis2_endpoint_ref_get_address(epr_to, env);
+ if(address && *address)
+ {
+ axiom_node_t *to_header_block_node = NULL;
+ axiom_soap_header_block_t *to_header_block = NULL;
+ axutil_array_list_t *ref_param_list = NULL;
+ int size = 0;
+
+ to_header_block = axiom_soap_header_add_header_block(soap_header, env,
+ AXIS2_WSA_TO, addressing_namespace);
+ if(set_must_understand == AXIS2_TRUE)
+ {
+ axiom_soap_header_block_set_must_understand_with_bool(to_header_block, env, AXIS2_TRUE);
+ }
+ to_header_block_node = axiom_soap_header_block_get_base_node(to_header_block, env);
+ if(to_header_block_node)
+ {
+ axiom_element_t *to_header_block_element = NULL;
+ to_header_block_element = (axiom_element_t *)axiom_node_get_data_element(
+ to_header_block_node, env);
+ if(to_header_block_element)
+ {
+ axiom_element_set_text(to_header_block_element, env, address,
+ to_header_block_node);
+ }
+ }
+
+ ref_param_list = axis2_endpoint_ref_get_ref_param_list(epr_to, env);
+
+ size = axutil_array_list_size(ref_param_list, env);
+ if(ref_param_list && size > 0)
+ {
+ axiom_soap_header_block_t *reference_header_block = NULL;
+ axiom_node_t *reference_node = NULL;
+ int i = 0;
+
+ for(i = 0; i < size; i++)
+ {
+ axiom_node_t *temp_node = NULL;
+
+ temp_node = (axiom_node_t *)axutil_array_list_get(ref_param_list, env, i);
+ if(temp_node)
+ {
+ axiom_element_t *temp_ele = NULL;
+
+ temp_ele = axiom_node_get_data_element(temp_node, env);
+ if(temp_ele)
+ {
+ reference_header_block = axiom_soap_header_add_header_block(
+ soap_header, env, axiom_element_get_localname(temp_ele, env),
+ axiom_element_get_namespace(temp_ele, env, temp_node));
+ if(set_must_understand)
+ {
+ axiom_soap_header_block_set_must_understand_with_bool(reference_header_block, env, AXIS2_TRUE);
+ }
+
+ reference_node = axiom_soap_header_block_get_base_node(
+ reference_header_block, env);
+ if(reference_node)
+ {
+ axiom_element_t *reference_ele = NULL;
+ reference_ele = (axiom_element_t *)axiom_node_get_data_element(
+ reference_node, env);
+
+ if(reference_ele)
+ {
+ axiom_namespace_t *addr_ns_obj = NULL;
+ axiom_attribute_t *reference_attr = NULL;
+
+ addr_ns_obj = axiom_namespace_create(env, addr_ns,
+ AXIS2_WSA_DEFAULT_PREFIX);
+ reference_attr = axiom_attribute_create(env,
+ /*"isReferenceParameter"*/
+ AXIS2_WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE, "true",
+ addr_ns_obj);
+ axiom_element_add_attribute(reference_ele, env,
+ reference_attr, reference_node);
+ axiom_element_set_text(reference_ele, env,
+ axiom_element_get_text(temp_ele, env, temp_node),
+ reference_node);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }/* if(epr_to) */
+
+ axiom_namespace_free(addressing_namespace, env);
+
+ action = axis2_msg_info_headers_get_action(msg_info_headers, env);
+ if(action && *action)
+ {
+ axis2_addr_out_handler_process_string_info(env, action, AXIS2_WSA_ACTION, &soap_header,
+ addr_ns, set_must_understand);
+ }
+
+ epr_reply_to = axis2_msg_info_headers_get_reply_to(msg_info_headers, env);
+ if(!epr_reply_to)
+ {
+ const axis2_char_t *anonymous_uri = NULL;
+ axis2_bool_t anonymous = axis2_msg_info_headers_get_reply_to_anonymous(
+ msg_info_headers, env);
+ axis2_bool_t none = axis2_msg_info_headers_get_reply_to_none(msg_info_headers, env);
+ if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
+ {
+ if(none)
+ {
+ anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION;
+ }
+ else if(anonymous)
+ {
+ anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION;
+ }
+ }
+ else
+ {
+ if(none)
+ {
+ anonymous_uri = AXIS2_WSA_NONE_URL;
+ }
+ else if(anonymous)
+ {
+ anonymous_uri = AXIS2_WSA_ANONYMOUS_URL;
+ }
+ }
+
+ if(anonymous_uri)
+ {
+ epr_reply_to = axis2_endpoint_ref_create(env, anonymous_uri);
+ }
+
+ if(epr_reply_to)
+ {
+ axis2_msg_info_headers_set_reply_to(msg_info_headers, env, epr_reply_to);
+ }
+ }
+
+ /* add the service group id as a reference parameter */
+ svc_group_context_id = axutil_string_get_buffer(axis2_msg_ctx_get_svc_grp_ctx_id(msg_ctx,
+ env), env);
+
+ axis2_addr_out_handler_add_to_soap_header(env, epr_reply_to, AXIS2_WSA_REPLY_TO,
+ soap_header, addr_ns);
+
+ epr_from = axis2_msg_info_headers_get_from(msg_info_headers, env);
+
+ if(epr_from)
+ {
+ axis2_addr_out_handler_add_to_soap_header(env, epr_from, AXIS2_WSA_FROM, soap_header,
+ addr_ns);
+
+ }
+
+ epr_fault_to = axis2_msg_info_headers_get_fault_to(msg_info_headers, env);
+ if(!epr_fault_to)
+ {
+ const axis2_char_t *anonymous_uri = NULL;
+ axis2_bool_t anonymous = axis2_msg_info_headers_get_fault_to_anonymous(
+ msg_info_headers, env);
+ axis2_bool_t none = axis2_msg_info_headers_get_fault_to_none(msg_info_headers, env);
+ if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
+ {
+ if(none)
+ {
+ anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION;
+ }
+ else if(anonymous)
+ {
+ anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION;
+ }
+ }
+ else
+ {
+ if(none)
+ anonymous_uri = AXIS2_WSA_NONE_URL;
+ else if(anonymous)
+ anonymous_uri = AXIS2_WSA_ANONYMOUS_URL;
+ }
+
+ if(anonymous_uri)
+ {
+ epr_fault_to = axis2_endpoint_ref_create(env, anonymous_uri);
+ }
+ }
+
+ if(epr_fault_to)
+ {
+ /* optional */
+ axis2_addr_out_handler_add_to_soap_header(env, epr_fault_to, AXIS2_WSA_FAULT_TO,
+ soap_header, addr_ns);
+ }
+
+ message_id = axis2_msg_info_headers_get_message_id(msg_info_headers, env);
+
+ if(message_id)
+ {
+ axis2_addr_out_handler_process_string_info(env, message_id, AXIS2_WSA_MESSAGE_ID,
+ &soap_header, addr_ns, set_must_understand);
+ }
+
+ relates_to = axis2_msg_info_headers_get_relates_to(msg_info_headers, env);
+
+ if(relates_to)
+ {
+ const axis2_char_t *value = NULL;
+ value = axis2_relates_to_get_value(relates_to, env);
+ relates_to_header_node = axis2_addr_out_handler_process_string_info(env, value,
+ AXIS2_WSA_RELATES_TO, &soap_header, addr_ns, set_must_understand);
+ }
+
+ if(relates_to_header_node)
+ {
+ const axis2_char_t *relationship_type = NULL;
+ relationship_type = axis2_relates_to_get_relationship_type(relates_to, env);
+ if(relationship_type && *relationship_type)
+ {
+ axiom_attribute_t *om_attr = NULL;
+ axiom_namespace_t *addr_ns_obj = NULL;
+ axiom_namespace_t *dec_ns = NULL;
+ relates_to_header_ele = (axiom_element_t *)axiom_node_get_data_element(
+ relates_to_header_node, env);
+ if(relates_to_header_ele)
+ {
+ dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env,
+ addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ if(dec_ns)
+ {
+ addr_ns_obj = dec_ns;
+ }
+ else
+ {
+ addr_ns_obj
+ = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ }
+
+ if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
+ {
+ om_attr = axiom_attribute_create(env,
+ AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE,
+ AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE_SUBMISSION,
+ addr_ns_obj);
+ }
+ else
+ {
+ om_attr = axiom_attribute_create(env,
+ AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE,
+ AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE, addr_ns_obj);
+ }
+
+ axiom_element_add_attribute(relates_to_header_ele, env, om_attr,
+ relates_to_header_node);
+
+ dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env,
+ addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ if(!dec_ns)
+ {
+ dec_ns = axiom_element_find_namespace(relates_to_header_ele, env,
+ relates_to_header_node, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ if(dec_ns)
+ {
+ axiom_namespace_free(addr_ns_obj, env);
+ addr_ns_obj = NULL;
+ axiom_attribute_set_namespace(om_attr, env, dec_ns);
+ }
+ }
+ }
+
+ }
+ }
+ }
+ return AXIS2_SUCCESS;
+}
+
+axiom_node_t *
+axis2_addr_out_handler_process_string_info(
+ const axutil_env_t * env,
+ const axis2_char_t * value,
+ const axis2_char_t * type,
+ axiom_soap_header_t ** soap_header_p,
+ const axis2_char_t * addr_ns,
+ axis2_bool_t set_must_understand)
+{
+ axiom_soap_header_t *soap_header = NULL;
+ axiom_soap_header_block_t *header_block = NULL;
+ axiom_node_t *header_block_node = NULL;
+ axiom_element_t *header_block_ele = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+ AXIS2_PARAM_CHECK(env->error, value, NULL);
+ AXIS2_PARAM_CHECK(env->error, type, NULL);
+ AXIS2_PARAM_CHECK(env->error, soap_header_p, NULL);
+ AXIS2_PARAM_CHECK(env->error, addr_ns, NULL);
+
+ soap_header = *(soap_header_p);
+
+ if(value && *value)
+ {
+ axiom_namespace_t *addr_ns_obj = NULL;
+ addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ header_block = axiom_soap_header_add_header_block(soap_header, env, type, addr_ns_obj);
+ header_block_node = axiom_soap_header_block_get_base_node(header_block, env);
+ header_block_ele = (axiom_element_t *)axiom_node_get_data_element(header_block_node, env);
+ if(header_block_ele)
+ {
+ axiom_namespace_t *dec_ns = NULL;
+ axiom_element_set_text(header_block_ele, env, value, header_block_node);
+ dec_ns = axiom_element_find_declared_namespace(header_block_ele, env, addr_ns,
+ AXIS2_WSA_DEFAULT_PREFIX);
+ if(!dec_ns)
+ {
+ axiom_namespace_free(addr_ns_obj, env);
+ addr_ns_obj = NULL;
+ }
+ }
+ if(set_must_understand)
+ {
+ axiom_soap_header_block_set_must_understand_with_bool(header_block, env, AXIS2_TRUE);
+ }
+ }
+ return header_block_node;
+}
+
+axis2_status_t
+axis2_addr_out_handler_add_to_soap_header(
+ const axutil_env_t * env,
+ axis2_endpoint_ref_t * endpoint_ref,
+ const axis2_char_t * type,
+ axiom_soap_header_t * soap_header,
+ const axis2_char_t * addr_ns)
+{
+ axiom_soap_header_block_t *header_block = NULL;
+ const axis2_char_t *address = NULL;
+ axutil_array_list_t *ref_param_list = NULL;
+ axutil_array_list_t *meta_data_list = NULL;
+ axutil_array_list_t *extension_list = NULL;
+ axiom_node_t *header_block_node = NULL;
+ axiom_node_t *header_node = NULL;
+ axiom_namespace_t *addr_ns_obj = NULL;
+ int size = 0;
+
+ AXIS2_PARAM_CHECK(env->error, endpoint_ref, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, type, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, soap_header, AXIS2_FAILURE);
+
+ header_node = axiom_soap_header_get_base_node(soap_header, env);
+
+ addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ header_block = axiom_soap_header_add_header_block(soap_header, env, type, addr_ns_obj);
+ if(addr_ns_obj)
+ {
+ axiom_namespace_free(addr_ns_obj, env);
+ addr_ns_obj = NULL;
+ }
+
+ address = axis2_endpoint_ref_get_address(endpoint_ref, env);
+ if(address && *address)
+ {
+ axiom_node_t *hb_node = NULL;
+ axiom_element_t *hb_ele = NULL;
+ axiom_node_t *address_node = NULL;
+ axiom_element_t *address_ele = NULL;
+ hb_node = axiom_soap_header_block_get_base_node(header_block, env);
+ hb_ele = (axiom_element_t *)axiom_node_get_data_element(hb_node, env);
+
+ addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+
+ address_ele = axiom_element_create(env, hb_node, EPR_ADDRESS, addr_ns_obj, &address_node);
+ axiom_namespace_free(addr_ns_obj, env);
+ if(address_ele)
+ {
+ axiom_namespace_t *dec_ns = NULL;
+ axiom_element_set_text(address_ele, env, address, address_node);
+ dec_ns = axiom_element_find_declared_namespace(address_ele, env, addr_ns,
+ AXIS2_WSA_DEFAULT_PREFIX);
+ }
+ }
+
+ header_block_node = axiom_soap_header_block_get_base_node(header_block, env);
+ axis2_addr_out_handler_add_to_header(env, endpoint_ref, &header_block_node, addr_ns);
+
+ ref_param_list = axis2_endpoint_ref_get_ref_param_list(endpoint_ref, env);
+ if(ref_param_list && axutil_array_list_size(ref_param_list, env) > 0)
+ {
+ axiom_node_t *reference_node = NULL;
+ axiom_element_t *reference_ele = NULL;
+ axutil_array_list_t *ref_attribute_list = NULL;
+ int i = 0;
+
+ addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+
+ reference_ele = axiom_element_create(env, header_block_node, EPR_REFERENCE_PARAMETERS,
+ addr_ns_obj, &reference_node);
+ axiom_namespace_free(addr_ns_obj, env);
+
+ ref_attribute_list = axis2_endpoint_ref_get_ref_attribute_list(endpoint_ref, env);
+ if(ref_attribute_list)
+ {
+ int j = 0;
+
+ size = axutil_array_list_size(ref_attribute_list, env);
+ for(j = 0; j < size; j++)
+ {
+ axiom_attribute_t *attr = (axiom_attribute_t *)axutil_array_list_get(
+ ref_attribute_list, env, j);
+ if(attr)
+ {
+ axiom_element_add_attribute(reference_ele, env, attr, reference_node);
+ }
+ }
+ }
+
+ size = axutil_array_list_size(ref_param_list, env);
+ for(i = 0; i < size; i++)
+ {
+ axiom_node_t *ref_node = (axiom_node_t *)axutil_array_list_get(ref_param_list, env, i);
+ if(ref_node)
+ {
+ axiom_node_add_child(reference_node, env, ref_node);
+ }
+ }
+
+ }
+
+ meta_data_list = axis2_endpoint_ref_get_metadata_list(endpoint_ref, env);
+ if(meta_data_list && axutil_array_list_size(meta_data_list, env) > 0)
+ {
+ axiom_node_t *reference_node = NULL;
+ axiom_element_t *reference_ele = NULL;
+ axutil_array_list_t *meta_attribute_list = NULL;
+ int i = 0;
+
+ if(!reference_node) /* may be we alredy created this in ref params block */
+ {
+ addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+
+ reference_ele = axiom_element_create(env, header_block_node, AXIS2_WSA_METADATA,
+ addr_ns_obj, &reference_node);
+ axiom_namespace_free(addr_ns_obj, env);
+ }
+
+ meta_attribute_list = axis2_endpoint_ref_get_metadata_attribute_list(endpoint_ref, env);
+ if(meta_attribute_list)
+ {
+ int j = 0;
+ size = axutil_array_list_size(meta_attribute_list, env);
+ for(j = 0; j < size; j++)
+ {
+ axiom_attribute_t *attr = (axiom_attribute_t *)axutil_array_list_get(
+ meta_attribute_list, env, j);
+ if(attr)
+ {
+ axiom_element_add_attribute(reference_ele, env, attr, reference_node);
+ }
+ }
+ }
+
+ size = axutil_array_list_size(meta_data_list, env);
+ for(i = 0; i < size; i++)
+ {
+ axiom_node_t *ref_node = (axiom_node_t *)axutil_array_list_get(meta_data_list, env, i);
+ if(ref_node)
+ {
+ axiom_node_add_child(reference_node, env, ref_node);
+ }
+ }
+ }
+
+ extension_list = axis2_endpoint_ref_get_extension_list(endpoint_ref, env);
+ if(extension_list && axutil_array_list_size(extension_list, env) > 0)
+ {
+ int i = 0;
+
+ size = axutil_array_list_size(extension_list, env);
+ for(i = 0; i < size; i++)
+ {
+ axiom_node_t *ref_node = (axiom_node_t *)axutil_array_list_get(extension_list, env, i);
+ if(ref_node)
+ {
+ axiom_node_add_child(header_block_node, env, ref_node);
+ }
+ }
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t
+axis2_addr_out_handler_add_to_header(
+ const axutil_env_t * env,
+ axis2_endpoint_ref_t * epr,
+ axiom_node_t ** parent_node_p,
+ const axis2_char_t * addr_ns)
+{
+ axiom_node_t *parent_node = NULL;
+ const axutil_qname_t *interface_qname = NULL;
+ axiom_node_t *interface_node = NULL;
+ axiom_element_t *interface_ele = NULL;
+ const axis2_char_t *element_localname = NULL;
+ axis2_svc_name_t *service_name = NULL;
+ axiom_namespace_t *addr_ns_obj = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, epr, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, parent_node_p, AXIS2_FAILURE);
+
+ parent_node = *(parent_node_p);
+
+ interface_qname = axis2_endpoint_ref_get_interface_qname(epr, env);
+
+ if(interface_qname)
+ {
+ axis2_char_t *text = NULL;
+ axis2_char_t *qname_prefix = NULL;
+ axis2_char_t *qname_localpart = NULL;
+
+ addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+
+ if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
+ {
+ element_localname = EPR_PORT_TYPE;
+ }
+ else
+ {
+ element_localname = AXIS2_WSA_INTERFACE_NAME;
+ }
+
+ interface_ele = axiom_element_create(env, parent_node, element_localname, addr_ns_obj,
+ &interface_node);
+ qname_prefix = axutil_qname_get_prefix(interface_qname, env);
+ qname_localpart = axutil_qname_get_localpart(interface_qname, env);
+
+ text = AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) * (axutil_strlen(qname_prefix)
+ + axutil_strlen(qname_localpart) + 2));
+ sprintf(text, "%s:%s", qname_prefix, qname_localpart);
+ axiom_element_set_text(interface_ele, env, text, interface_node);
+ AXIS2_FREE(env->allocator, text);
+ if(interface_ele)
+ {
+ axiom_namespace_t *dec_ns = NULL;
+ dec_ns = axiom_element_find_declared_namespace(interface_ele, env, addr_ns,
+ AXIS2_WSA_DEFAULT_PREFIX);
+ if(!dec_ns)
+ {
+ axiom_namespace_free(addr_ns_obj, env);
+ addr_ns_obj = NULL;
+ }
+ }
+
+ }
+
+ service_name = axis2_endpoint_ref_get_svc_name(epr, env);
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t
+axis2_addr_out_handler_process_any_content_type(
+ const axutil_env_t * env,
+ axis2_any_content_type_t * reference_values,
+ axiom_node_t * parent_ele_node,
+ const axis2_char_t * addr_ns)
+{
+ axutil_hash_t *value_ht = NULL;
+ axutil_hash_index_t *hash_index = NULL;
+
+ if(reference_values)
+ {
+ const void *key = NULL;
+ void *val = NULL;
+ axis2_ssize_t len = 0;
+ value_ht = axis2_any_content_type_get_value_map(reference_values, env);
+ if(!value_ht)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ for(hash_index = axutil_hash_first(value_ht, env); hash_index; hash_index
+ = axutil_hash_next(env, hash_index))
+ {
+ axutil_hash_this(hash_index, &key, &len, &val);
+ if(key)
+ {
+ axiom_node_t *node = NULL;
+ axiom_element_t *ele = NULL;
+ ele = axiom_element_create(env, parent_ele_node, key, NULL, &node);
+ if(ele)
+ {
+ if(!axutil_strcmp(AXIS2_WSA_NAMESPACE, addr_ns))
+ {
+ axiom_namespace_t *addr_ns_obj = NULL;
+ axiom_attribute_t *att = NULL;
+ addr_ns_obj
+ = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ att = axiom_attribute_create(env,
+ AXIS2_WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE,
+ AXIS2_WSA_TYPE_ATTRIBUTE_VALUE, addr_ns_obj);
+ }
+ axiom_element_set_text(ele, env, val, node);
+ }
+ }
+ }
+ }
+ return AXIS2_SUCCESS;
+}
diff --git a/test/find_policy.c b/test/find_policy.c
index 9549fdf..b5c8a63 100644
--- a/test/find_policy.c
+++ b/test/find_policy.c
@@ -1,34 +1,34 @@
-/*
- * 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.
- */
-
-#include <axiom_stax_builder.h>
-#include <axiom_document.h>
-#include <axiom_node.h>
-#include <axiom_element.h>
-#include <axiom_text.h>
-#include <axiom_data_source.h>
-#include <axutil_stream.h>
-#include <axutil_log_default.h>
-#include <axutil_error_default.h>
-#include <axiom_xml_reader.h>
-#include <stdio.h>
-#include <axiom_xml_writer.h>
-#include <axutil_env.h>
+/*
+ * 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.
+ */
+
+#include <axiom_stax_builder.h>
+#include <axiom_document.h>
+#include <axiom_node.h>
+#include <axiom_element.h>
+#include <axiom_text.h>
+#include <axiom_data_source.h>
+#include <axutil_stream.h>
+#include <axutil_log_default.h>
+#include <axutil_error_default.h>
+#include <axiom_xml_reader.h>
+#include <stdio.h>
+#include <axiom_xml_writer.h>
+#include <axutil_env.h>
axiom_node_t * return_policy_element(axis2_char_t * name,
const axutil_env_t * env,
axis2_char_t * wsdl_name);
@@ -38,12 +38,12 @@
const axutil_env_t * env,
axutil_array_list_t * policy_node_list,
axis2_char_t * wsdl_name);
-
-/**
- Define the environment related variables globaly so that they are available
- for both functions
-*/
+
+/**
+ Define the environment related variables globaly so that they are available
+ for both functions
+*/
axutil_allocator_t * allocator = NULL;
axutil_env_t * environment = NULL;
axutil_stream_t * stream = NULL;
@@ -51,14 +51,14 @@
axutil_log_t * axis_log = NULL;
FILE * f = NULL;
FILE * o = NULL;
-
-/** a method that demonstrate creating a om model using an xml file */
+
+/** a method that demonstrate creating a om model using an xml file */
int AXIS2_CALL
read_input(
char *buffer,
int size,
- void *ctx)
+ void *ctx)
{
int len = 0;
char *pos = NULL;
@@ -66,17 +66,17 @@ read_input(
if (buffer)
pos = strstr(buffer, "---");
if (pos)
-
+
{
len = pos - buffer;
*pos = '\0';
}
return len;
}
- int
+ int
main(
int argc,
- char *argv[])
+ char *argv[])
{
axutil_qname_t * qname = NULL;
axiom_node_t * policy_node = NULL, *node = NULL;
@@ -96,8 +96,8 @@ main(
environment =
axutil_env_create_with_error_log(allocator, error, axis_log);
policy_array = axutil_array_list_create(environment, 10);
-
- /*get all the policy values of "Binding_2B"*/
+
+ /*get all the policy values of "Binding_2B"*/
get_all_policy("Binding-2B", environment, policy_array, file_name);
node =
(axiom_node_t *) axutil_array_list_get(policy_array, environment, 2);
@@ -111,10 +111,10 @@ main(
axiom_node_serialize(node, environment, om_output);
buffer = (axis2_char_t *) axiom_xml_writer_get_xml(writer, environment);
if (buffer)
-
+
{
-
- /*printf(outfilename);*/
+
+ /*printf(outfilename);*/
o = fopen("C:\\OMWsdl\\wsdltest\\debug\\out.xml", "w");
if (!o)
return -1;
@@ -130,7 +130,7 @@ main(
axiom_node_t * return_policy_element(axis2_char_t * name,
const axutil_env_t * env,
- axis2_char_t * wsdl_name)
+ axis2_char_t * wsdl_name)
{
axiom_element_t * ele1 = NULL, *ele2 = NULL;
axiom_document_t * document = NULL;
@@ -152,14 +152,14 @@ main(
axiom_xml_reader_create_for_io(environment, read_input, NULL, NULL,
NULL);
if (!reader)
-
+
{
printf("ERROR CREATING PULLPARSER");
return NULL;
}
builder = axiom_stax_builder_create(environment, reader);
if (!builder)
-
+
{
printf("ERROR CREATING PULL PARSER");
return NULL;
@@ -169,34 +169,34 @@ main(
return NULL;
node1 = axiom_document_get_root_element(document, environment);
if (!node1)
-
+
{
printf(" root element null ");
axiom_stax_builder_free(builder, environment);
return NULL;
}
-
+
do
-
+
{
node2 = axiom_document_build_next(document, environment);
if (!node2)
break;
if (axiom_node_get_node_type(node2, environment) == AXIOM_ELEMENT)
-
+
{
ele2 =
(axiom_element_t *) axiom_node_get_data_element(node2,
environment);
attr_hash = axiom_element_get_all_attributes(ele2, environment);
if (attr_hash)
-
+
{
hi = axutil_hash_first(attr_hash, environment);
axutil_hash_this(hi, NULL, NULL, &attr);
if (axutil_strcmp
(axiom_attribute_get_value(attr, environment), name) == 0)
-
+
{
policy_node = node2;
}
@@ -207,7 +207,7 @@ main(
return policy_node;
}
- axis2_char_t * get_policy_ref(axiom_node_t * node, const axutil_env_t * env)
+ axis2_char_t * get_policy_ref(axiom_node_t * node, const axutil_env_t * env)
{
axiom_element_t * policy_element = NULL;
axiom_children_iterator_t * children_iter = NULL;
@@ -220,11 +220,11 @@ main(
(axiom_element_t *) axiom_node_get_data_element(node, env);
children_iter = axiom_element_get_children(policy_element, env, node);
while (axiom_children_iterator_has_next(children_iter, env))
-
+
{
child_node = axiom_children_iterator_next(children_iter, env);
if (axiom_node_get_node_type(child_node, environment) == AXIOM_ELEMENT)
-
+
{
policy_element =
(axiom_element_t *) axiom_node_get_data_element(child_node,
@@ -232,14 +232,14 @@ main(
if (axutil_strcmp
(axiom_element_get_localname(policy_element, environment),
"PolicyReference") == 0)
-
+
{
qname = axutil_qname_create(environment, "URI", NULL, NULL);
attr =
axiom_element_get_attribute(policy_element, environment,
qname);
if (attr)
-
+
{
value = axiom_attribute_get_value(attr, environment);
val = axutil_string_substring_starting_at(value, 1);
@@ -255,7 +255,7 @@ get_all_policy(
axis2_char_t * element_name,
const axutil_env_t * env,
axutil_array_list_t * policy_node_list,
- axis2_char_t * wsdl_name)
+ axis2_char_t * wsdl_name)
{
axutil_hash_t * attr_hash = NULL;
axutil_hash_index_t * hi = NULL;
@@ -270,21 +270,21 @@ get_all_policy(
return_policy_element(get_policy_ref(parent_node, env), env, wsdl_name);
axutil_array_list_add(policy_node_list, env, parent_policy_node);
if (axiom_node_get_node_type(parent_node, env) == AXIOM_ELEMENT)
-
+
{
element =
(axiom_element_t *) axiom_node_get_data_element(parent_node, env);
attr_hash = axiom_element_get_all_attributes(element, env);
if (attr_hash)
-
+
{
hi = axutil_hash_next(env, axutil_hash_first(attr_hash, env));
-
+
do
-
+
{
if (hi)
-
+
{
axutil_hash_this(hi, NULL, NULL, &attribute);
attribute_val = axiom_attribute_get_value(attribute, env);
diff --git a/util/include/axutil_network_handler.h b/util/include/axutil_network_handler.h
index 3d55cd1..bc361e2 100644
--- a/util/include/axutil_network_handler.h
+++ b/util/include/axutil_network_handler.h
@@ -1,194 +1,194 @@
-
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain count 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 AXUTIL_NETWORK_HANDLER_H
-#define AXUTIL_NETWORK_HANDLER_H
-
-#include <axutil_utils.h>
-#include <axutil_utils_defines.h>
-#include <axutil_env.h>
-#include <sys/types.h>
-#include <platforms/axutil_platform_auto_sense.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /**
- * @defgroup axutil_network_handler network handler
- * @ingroup axis2_util
- * @{
- */
-
- /**
- * open a socket for a given server
- * @param server ip address or the fqn of the server
- * @param port port of the service
- * @return opened socket
- */
- AXIS2_EXTERN axis2_socket_t AXIS2_CALL
-
- axutil_network_handler_open_socket(
- const axutil_env_t * env,
- char *server,
- int port);
-
- /**
- * creates a server socket for a given port
- * @param port port of the socket to be bound
- * @return creates server socket
- */
- AXIS2_EXTERN axis2_socket_t AXIS2_CALL
-
- axutil_network_handler_create_server_socket(
- const axutil_env_t * env,
- int port);
-
- /**
- * closes a socket
- * @param opened socket that need to be closed
- * @return status code
- */
- AXIS2_EXTERN axis2_status_t AXIS2_CALL
-
- axutil_network_handler_close_socket(
- const axutil_env_t * env,
- axis2_socket_t socket);
-
- /**
- * used to set up socket options such as timeouts, non-blocking ..etc
- * @param socket valid socket (obtained by socket() or similar call)
- * @param option the name of the option
- * @param value Value to be set
- * @return status of the operations as axis2_status_t
- */
- AXIS2_EXTERN axis2_status_t AXIS2_CALL
-
- axutil_network_handler_set_sock_option(
- const axutil_env_t * env,
- axis2_socket_t socket,
- int option,
- int value);
-
- /**
- * Accepts remote connections for a server socket
- * @param socket valid server socket (obtained by socket() or similar call)
- * @return created socket to handle the incoming client connection
- */
- AXIS2_EXTERN axis2_socket_t AXIS2_CALL
-
- axutil_network_handler_svr_socket_accept(
- const axutil_env_t * env,
- axis2_socket_t socket);
-
- /**
- * Returns the ip address of the server associated with the socket
- * @param socket valid socket (obtained by accept() or similar call)
- * @return ip address asoociated with the socket or NULL
- */
- AXIS2_EXTERN axis2_char_t *AXIS2_CALL
- axutil_network_handler_get_svr_ip(
- const axutil_env_t * env,
- axis2_socket_t socket);
-
- AXIS2_EXTERN axis2_char_t *AXIS2_CALL
- axutil_network_handler_get_peer_ip(
- const axutil_env_t * env,
- axis2_socket_t socket);
-
- /*
- * Create a datagram socket.
- * @param env pointer to env
- * @return a datagram socket
- */
- AXIS2_EXTERN axis2_socket_t AXIS2_CALL
- axutil_network_handler_open_dgram_socket(const axutil_env_t *env);
-
- /*
- * Send a UDP packet to the given source and port address.
- * Read a incoming UDP packet from the port and server address.
- * @param env pointer to the env structure
- * @param socket a datagram socket
- * @param buffer a buffer containing the data to be sent
- * @param buf_len length of the buffer
- * @param addr address of the source field
- * @param port udp port number
- * @return success if everything goes well
- */
- AXIS2_EXTERN axis2_status_t AXIS2_CALL
- axutil_network_handler_send_dgram(const axutil_env_t *env, axis2_socket_t socket,
- axis2_char_t *buff, int *buf_len,
- axis2_char_t *addr, int dest_port, int *source_port);
-
- /*
- * Read a incoming UDP packet from the port and server address.
- * @param env pointer to the env structure
- * @param socket a datagram socket
- * @param buffer a buffer allocated and passed to be filled
- * @param buf_len length of the buffer allocated. In return buffer len
- contains the length of the data read
- * @param addr address of the sender. This is a return value.
- * @param port senders port address. Return value
- * @return if everything goes well return success
- */
- AXIS2_EXTERN axis2_status_t AXIS2_CALL
- axutil_network_handler_read_dgram(const axutil_env_t *env, axis2_socket_t socket,
- axis2_char_t *buffer, int *buf_len,
- axis2_char_t **addr, int *port);
-
- /*
- * Create a datagram socket to receive incoming UDP packets.
- * @param env a pointer to the env structure
- * @param port udp port to listen
- * @return AXIS2_SUCCESS if everything goes well
- */
- AXIS2_EXTERN axis2_socket_t AXIS2_CALL
- axutil_network_handler_create_dgram_svr_socket(
- const axutil_env_t *env,
- int port);
-
- /*
- * Bind a socket to the specified address
- * @param env a pointer to the env structure
- * @param sock socket
- * @param port port number to bind to
- * @return AXIS2_SUCCESS if binding is performed
- */
- AXIS2_EXTERN axis2_status_t AXIS2_CALL
- axutil_network_handler_bind_socket(const axutil_env_t *env,
- axis2_socket_t sock, int port);
-
- /*
- * Create a multicast socket for listening on the given port.
- * @param env a pointer to the env structure
- * @param port udp port to listen
- * @param mul_addr multicast address to join. The address should be valid and in dotted format.
- * @param ttl TTL value.
- * @return AXIS2_SUCCESS if everything goes well.s
- */
- AXIS2_EXTERN axis2_socket_t AXIS2_CALL
- axutil_network_hadler_create_multicast_svr_socket(const axutil_env_t *env,
- int port, axis2_char_t *mul_addr);
-
- /** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* AXIS2_NETWORK_HANDLER_H */
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain count 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 AXUTIL_NETWORK_HANDLER_H
+#define AXUTIL_NETWORK_HANDLER_H
+
+#include <axutil_utils.h>
+#include <axutil_utils_defines.h>
+#include <axutil_env.h>
+#include <sys/types.h>
+#include <platforms/axutil_platform_auto_sense.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /**
+ * @defgroup axutil_network_handler network handler
+ * @ingroup axis2_util
+ * @{
+ */
+
+ /**
+ * open a socket for a given server
+ * @param server ip address or the fqn of the server
+ * @param port port of the service
+ * @return opened socket
+ */
+ AXIS2_EXTERN axis2_socket_t AXIS2_CALL
+
+ axutil_network_handler_open_socket(
+ const axutil_env_t * env,
+ char *server,
+ int port);
+
+ /**
+ * creates a server socket for a given port
+ * @param port port of the socket to be bound
+ * @return creates server socket
+ */
+ AXIS2_EXTERN axis2_socket_t AXIS2_CALL
+
+ axutil_network_handler_create_server_socket(
+ const axutil_env_t * env,
+ int port);
+
+ /**
+ * closes a socket
+ * @param opened socket that need to be closed
+ * @return status code
+ */
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+
+ axutil_network_handler_close_socket(
+ const axutil_env_t * env,
+ axis2_socket_t socket);
+
+ /**
+ * used to set up socket options such as timeouts, non-blocking ..etc
+ * @param socket valid socket (obtained by socket() or similar call)
+ * @param option the name of the option
+ * @param value Value to be set
+ * @return status of the operations as axis2_status_t
+ */
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+
+ axutil_network_handler_set_sock_option(
+ const axutil_env_t * env,
+ axis2_socket_t socket,
+ int option,
+ int value);
+
+ /**
+ * Accepts remote connections for a server socket
+ * @param socket valid server socket (obtained by socket() or similar call)
+ * @return created socket to handle the incoming client connection
+ */
+ AXIS2_EXTERN axis2_socket_t AXIS2_CALL
+
+ axutil_network_handler_svr_socket_accept(
+ const axutil_env_t * env,
+ axis2_socket_t socket);
+
+ /**
+ * Returns the ip address of the server associated with the socket
+ * @param socket valid socket (obtained by accept() or similar call)
+ * @return ip address asoociated with the socket or NULL
+ */
+ AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+ axutil_network_handler_get_svr_ip(
+ const axutil_env_t * env,
+ axis2_socket_t socket);
+
+ AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+ axutil_network_handler_get_peer_ip(
+ const axutil_env_t * env,
+ axis2_socket_t socket);
+
+ /*
+ * Create a datagram socket.
+ * @param env pointer to env
+ * @return a datagram socket
+ */
+ AXIS2_EXTERN axis2_socket_t AXIS2_CALL
+ axutil_network_handler_open_dgram_socket(const axutil_env_t *env);
+
+ /*
+ * Send a UDP packet to the given source and port address.
+ * Read a incoming UDP packet from the port and server address.
+ * @param env pointer to the env structure
+ * @param socket a datagram socket
+ * @param buffer a buffer containing the data to be sent
+ * @param buf_len length of the buffer
+ * @param addr address of the source field
+ * @param port udp port number
+ * @return success if everything goes well
+ */
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axutil_network_handler_send_dgram(const axutil_env_t *env, axis2_socket_t socket,
+ axis2_char_t *buff, int *buf_len,
+ axis2_char_t *addr, int dest_port, int *source_port);
+
+ /*
+ * Read a incoming UDP packet from the port and server address.
+ * @param env pointer to the env structure
+ * @param socket a datagram socket
+ * @param buffer a buffer allocated and passed to be filled
+ * @param buf_len length of the buffer allocated. In return buffer len
+ contains the length of the data read
+ * @param addr address of the sender. This is a return value.
+ * @param port senders port address. Return value
+ * @return if everything goes well return success
+ */
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axutil_network_handler_read_dgram(const axutil_env_t *env, axis2_socket_t socket,
+ axis2_char_t *buffer, int *buf_len,
+ axis2_char_t **addr, int *port);
+
+ /*
+ * Create a datagram socket to receive incoming UDP packets.
+ * @param env a pointer to the env structure
+ * @param port udp port to listen
+ * @return AXIS2_SUCCESS if everything goes well
+ */
+ AXIS2_EXTERN axis2_socket_t AXIS2_CALL
+ axutil_network_handler_create_dgram_svr_socket(
+ const axutil_env_t *env,
+ int port);
+
+ /*
+ * Bind a socket to the specified address
+ * @param env a pointer to the env structure
+ * @param sock socket
+ * @param port port number to bind to
+ * @return AXIS2_SUCCESS if binding is performed
+ */
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axutil_network_handler_bind_socket(const axutil_env_t *env,
+ axis2_socket_t sock, int port);
+
+ /*
+ * Create a multicast socket for listening on the given port.
+ * @param env a pointer to the env structure
+ * @param port udp port to listen
+ * @param mul_addr multicast address to join. The address should be valid and in dotted format.
+ * @param ttl TTL value.
+ * @return AXIS2_SUCCESS if everything goes well.s
+ */
+ AXIS2_EXTERN axis2_socket_t AXIS2_CALL
+ axutil_network_hadler_create_multicast_svr_socket(const axutil_env_t *env,
+ int port, axis2_char_t *mul_addr);
+
+ /** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AXIS2_NETWORK_HANDLER_H */
diff --git a/util/include/axutil_utils_defines.h b/util/include/axutil_utils_defines.h
index ddc3a70..003cbae 100644
--- a/util/include/axutil_utils_defines.h
+++ b/util/include/axutil_utils_defines.h
@@ -62,12 +62,12 @@ extern "C"
#define AXIS2_PRINTF_INT64_FORMAT_SPECIFIER "%lld"
#define AXIS2_PRINTF_UINT64_FORMAT_SPECIFIER "%llu"
#endif
-# if defined(_MSC_VER) && _MSC_VER >= 1300
-# define AXIS2_PRINTF_INT32_FORMAT_SPECIFIER "%I32d"
-# define AXIS2_PRINTF_UINT32_FORMAT_SPECIFIER "%I32u"
-# else
-# define AXIS2_PRINTF_INT32_FORMAT_SPECIFIER "%d"
-# define AXIS2_PRINTF_UINT32_FORMAT_SPECIFIER "%u"
+# if defined(_MSC_VER) && _MSC_VER >= 1300
+# define AXIS2_PRINTF_INT32_FORMAT_SPECIFIER "%I32d"
+# define AXIS2_PRINTF_UINT32_FORMAT_SPECIFIER "%I32u"
+# else
+# define AXIS2_PRINTF_INT32_FORMAT_SPECIFIER "%d"
+# define AXIS2_PRINTF_UINT32_FORMAT_SPECIFIER "%u"
# endif
/**#define AXIS2_PRINTF_INT32_FORMAT_SPECIFIER "%d"
#define AXIS2_PRINTF_UINT32_FORMAT_SPECIFIER "%u" */
diff --git a/util/include/platforms/os400/axutil_os400.h b/util/include/platforms/os400/axutil_os400.h
index 1b6477f..5261c4d 100644
--- a/util/include/platforms/os400/axutil_os400.h
+++ b/util/include/platforms/os400/axutil_os400.h
@@ -1,277 +1,277 @@
-
-/*
- * 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 AXIS2_UNIX_H
-#define AXIS2_UNIX_H
-
-#include <axutil_config.h>
-
-/**
- * @file axutil_unix.h
- * @brief axis2 unix platform specific interface
- */
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /** @defgroup axis2_unix Platform Specific
- * @ingroup axis2_platforms_unix
- * @{
- */
-
- /***************************************************************
- * Default paths to shared library/DLLs and files
- ***************************************************************
- */
-
-#define AXIS2_PLATFORM_DEFAULT_DEPLOY_PATH ""
-
-#define AXIS2_PLATFORM_XMLPARSER_PATH "libaxis2_parser.so"
-#define AXIS2_PLATFORM_TRANSPORTHTTP_PATH "libhttp_transport.so"
-#define AXIS2_PLATFORM_CHANNEL_PATH "libhttp_channel.so"
-#define AXIS2_PLATFORM_SSLCHANNEL_PATH "Unknown"
-
-#define AXIS2_PLATFORM_LOG_PATH "/axis2/log/axutil_log"
-#define AXIS2_PLATFORM_CLIENTLOG_PATH "/axis2/log/axis2_client_log"
-#define AXIS2_PLATFORM_CONFIG_PATH "/etc/axiscpp.conf"
-#define AXIS2_PLATFORM_SECUREINFO ""
-
- /**
- * Resource that contains the configuration
- */
-#define AXIS2_CONFIGURATION_RESOURCE "/axis2/axis2.xml"
-
- /*****************************************************************
- * Library loading and procedure resolution
- ****************************************************************/
-
-#define AXIS2_DLHANDLER void*
-
-#define AXIS2_PLATFORM_LOADLIBINIT()
-#define AXIS2_PLATFORM_LOADLIB(_lib) os400_dlopen(_lib)
-
-#define AXIS2_PLATFORM_UNLOADLIB os400_dlclose
-#define AXIS2_PLATFORM_GETPROCADDR os400_dlsym
-#define AXIS2_PLATFORM_LOADLIBEXIT()
-#define AXIS2_PLATFORM_LOADLIB_ERROR os400_dlerror()
-
-extern void *os400_dlopen(const char *);
-extern void *os400_dlsym(void *, const char *);
-extern int os400_dlclose(void *);
-extern char *os400_dlerror();
-
-
- /***************************************************************
- * National Language Support
- ****************************************************************/
-
-// STRTOASC is to translate single byte 'native' character representation to ASCII
-// ASCTOSTR is to translate single byte ascii representation to 'native' character (EBCDIC)
-// CANNOT be used with constants.
-extern char* strtoasc( char* );
-extern char* asctostr( char* );
-#define AXIS2_PLATFORM_STRTOASC( x ) strtoasc( (char*)(x) )
-#define AXIS2_PLATFORM_ASCTOSTR( x ) asctostr( (char*)(x) )
-
-// reference to ebcdic to ascii conversion table
-extern const char EBCDICtoASCII[256];
-
-// Turkish double quote in EBCDIC is not invariant (i.e. the hexadecimal
-// value for double quote is different in turkish locale than when running
-// in english locale). This, when using double quotes we must reference the
-// following, which will be set to proper value on EBCDIC-based systems.
-
-extern char AXIS2_PLATFORM_DOUBLE_QUOTE_S[];
-extern char AXIS2_PLATFORM_DOUBLE_QUOTE_C;
-
-extern char AXIS2_PLATFORM_XML_ENTITY_REFERENCE_CHARS_S[];
-
- /***************************************************************
- * Miscellaneous
- ****************************************************************/
-#include <sys/time.h>
-
-#include <errno.h>
-#include <sys/param.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include "axutil_uuid_gen_os400.h" /* uuid_gen unix implementation */
-#include <netinet/tcp.h> /* TCP_NODELAY */
-#include <utime.h>
-
-#include "axutil_date_time_util_os400.h"
-
- /* for file access handling */
-#include <unistd.h>
-
- /* network handling */
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <sys/ioctl.h>
-
-#include <fcntl.h>
-
- /* dir handling */
-#include <sys/types.h>
-#include <dirent.h>
-
-#define AXIS2_STRRCHR(x, y) (strrchr(x, y))
-
-#define AXIS2_PLATFORM_SLEEP(x) sleep(0)
-
- /** sleep function abstraction */
-#define AXIS2_SLEEP sleep
-#define AXIS2_USLEEP usleep
-
- /**
- * Platform specific method to obtain current thread ID
- */
-#include <pthread.h>
-#define AXIS2_PLATFORM_GET_THREAD_ID() os400_getThreadID()
-
-static long long os400_getThreadID()
-{
- pthread_id_np_t tid = pthread_getthreadid_np();
- return *((long long *)&tid);
-}
-
- /**
- * Platform specific method to obtain current time in milli seconds
- */
-struct os400_timeb
-{
- long time;
- long millitm;
-};
-
-static int os400_ftime(struct os400_timeb * tp)
-{
- struct timeval t;
- gettimeofday(&t, NULL);
- tp->time = t.tv_sec;
- tp->millitm = t.tv_usec/1000;
- return 0;
-}
-#define AXIS2_PLATFORM_GET_TIME_IN_MILLIS os400_ftime
-#define AXIS2_PLATFORM_TIMEB os400_timeb
-
- /**
- * type to be used for 64bit integers
- */
-#define AXIS2_LONGLONG long long
-#define AXIS2_LONGLONGVALUE(value) value##LL
-#define AXIS2_UNSIGNED_LONGLONGVALUE(value) value##ULL
-
- /**
- * Format string to be used in printf for 64bit integers
- */
-#define AXIS2_PRINTF_LONGLONG_FORMAT_SPECIFIER "%lld"
-#define AXIS2_PRINTF_LONGLONG_FORMAT_SPECIFIER_CHARS "lld"
-#define AXIS2_PRINTF_UNSIGNED_LONGLONG_FORMAT_SPECIFIER "%llu"
-#define AXIS2_PRINTF_UNSIGNED_LONGLONG_FORMAT_SPECIFIER_CHARS "llu"
-
- /**
- * Platform specific path separator char
- */
-
-#define AXIS2_PATH_SEP_CHAR '/'
-#define AXIS2_PATH_SEP_STR "/"
-#define AXIS2_LIB_PREFIX "lib"
-#define AXIS2_LIB_SUFFIX ".so"
-
- /**
- * Platform specific time
- */
-#define AXIS2_TIME_T time_t
-
- /**
- * Platform specific file handling
- */
-#define AXIS2_FOPEN fopen
-#define AXIS2_FREAD fread
-#define AXIS2_FWRITE fwrite
-#define AXIS2_FCLOSE fclose
-#define AXIS2_FTELL ftell
-#define AXIS2_ACCESS(zpath,imode) access(zpath,imode)
-#define AXIS2_R_OK R_OK /* test for read permission */
-#define AXIS2_W_OK W_OK /* test for write permission */
-#define AXIS2_X_OK X_OK /* test for execute or search permission */
-#define AXIS2_F_OK F_OK /* test whether the directories leading to the file can be
- searched and the file exists */
-
- /**
- * Platform specific environment variable access method
- */
-#define AXIS2_GETENV(_env_var_name) getenv(_env_var_name)
-
- /**
- * unix specific directory handling functions
- */
-#define AXIS2_SCANDIR os400_scandir
-#define AXIS2_ALPHASORT os400_alphasort
-#define AXIS2_OPENDIR opendir
-#define AXIS2_CLOSEDIR closedir
-#define AXIS2_READDIR readdir
-#define AXIS2_READDIR_R readdir_r
-#define AXIS2_REWINDDIR rewinddir
-#define AXIS2_MKDIR mkdir
-#define AXIS2_GETCWD getcwd
-#define AXIS2_CHDIR chdir
-
- /**
- * network specific functions and defs
- */
-#define axis2_socket_t int
-#define AXIS2_INVALID_SOCKET -1
-#define AXIS2_INADDR_NONE (in_addr_t)-1
-#define axis2_unsigned_short_t uint16_t
-#define AXIS2_CLOSE_SOCKET(sock) close(sock)
-#define AXIS2_CLOSE_SOCKET_ON_EXIT(sock) fcntl(sock,F_SETFD, FD_CLOEXEC)
-#define axis2_socket_len_t socklen_t
-#define AXIS2_SHUT_WR SHUT_WR
-
- /** getopt function */
-#define AXIS2_GETOPT getopt
-
- /** minizip functions */
-#define axis2_fill_win32_filefunc(ffunc)
-#define AXIS2_UNZOPEN2(zipfilename,ffunc) do { unzOpen2(zipfilename,NULL); memset(&ffunc, 0, sizeof(ffunc)); } while (0)
-
- /**
- * handling variable number of arguments (for log.c)
- */
-#define AXIS2_VSNPRINTF vsnprintf
-
-#define AXIS2_SNPRINTF snprintf
-
-#define axis2_gmtime_r gmtime_r
-
- /** @} */
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* AXIS2_UNIX_H */
+
+/*
+ * 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 AXIS2_UNIX_H
+#define AXIS2_UNIX_H
+
+#include <axutil_config.h>
+
+/**
+ * @file axutil_unix.h
+ * @brief axis2 unix platform specific interface
+ */
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /** @defgroup axis2_unix Platform Specific
+ * @ingroup axis2_platforms_unix
+ * @{
+ */
+
+ /***************************************************************
+ * Default paths to shared library/DLLs and files
+ ***************************************************************
+ */
+
+#define AXIS2_PLATFORM_DEFAULT_DEPLOY_PATH ""
+
+#define AXIS2_PLATFORM_XMLPARSER_PATH "libaxis2_parser.so"
+#define AXIS2_PLATFORM_TRANSPORTHTTP_PATH "libhttp_transport.so"
+#define AXIS2_PLATFORM_CHANNEL_PATH "libhttp_channel.so"
+#define AXIS2_PLATFORM_SSLCHANNEL_PATH "Unknown"
+
+#define AXIS2_PLATFORM_LOG_PATH "/axis2/log/axutil_log"
+#define AXIS2_PLATFORM_CLIENTLOG_PATH "/axis2/log/axis2_client_log"
+#define AXIS2_PLATFORM_CONFIG_PATH "/etc/axiscpp.conf"
+#define AXIS2_PLATFORM_SECUREINFO ""
+
+ /**
+ * Resource that contains the configuration
+ */
+#define AXIS2_CONFIGURATION_RESOURCE "/axis2/axis2.xml"
+
+ /*****************************************************************
+ * Library loading and procedure resolution
+ ****************************************************************/
+
+#define AXIS2_DLHANDLER void*
+
+#define AXIS2_PLATFORM_LOADLIBINIT()
+#define AXIS2_PLATFORM_LOADLIB(_lib) os400_dlopen(_lib)
+
+#define AXIS2_PLATFORM_UNLOADLIB os400_dlclose
+#define AXIS2_PLATFORM_GETPROCADDR os400_dlsym
+#define AXIS2_PLATFORM_LOADLIBEXIT()
+#define AXIS2_PLATFORM_LOADLIB_ERROR os400_dlerror()
+
+extern void *os400_dlopen(const char *);
+extern void *os400_dlsym(void *, const char *);
+extern int os400_dlclose(void *);
+extern char *os400_dlerror();
+
+
+ /***************************************************************
+ * National Language Support
+ ****************************************************************/
+
+// STRTOASC is to translate single byte 'native' character representation to ASCII
+// ASCTOSTR is to translate single byte ascii representation to 'native' character (EBCDIC)
+// CANNOT be used with constants.
+extern char* strtoasc( char* );
+extern char* asctostr( char* );
+#define AXIS2_PLATFORM_STRTOASC( x ) strtoasc( (char*)(x) )
+#define AXIS2_PLATFORM_ASCTOSTR( x ) asctostr( (char*)(x) )
+
+// reference to ebcdic to ascii conversion table
+extern const char EBCDICtoASCII[256];
+
+// Turkish double quote in EBCDIC is not invariant (i.e. the hexadecimal
+// value for double quote is different in turkish locale than when running
+// in english locale). This, when using double quotes we must reference the
+// following, which will be set to proper value on EBCDIC-based systems.
+
+extern char AXIS2_PLATFORM_DOUBLE_QUOTE_S[];
+extern char AXIS2_PLATFORM_DOUBLE_QUOTE_C;
+
+extern char AXIS2_PLATFORM_XML_ENTITY_REFERENCE_CHARS_S[];
+
+ /***************************************************************
+ * Miscellaneous
+ ****************************************************************/
+#include <sys/time.h>
+
+#include <errno.h>
+#include <sys/param.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include "axutil_uuid_gen_os400.h" /* uuid_gen unix implementation */
+#include <netinet/tcp.h> /* TCP_NODELAY */
+#include <utime.h>
+
+#include "axutil_date_time_util_os400.h"
+
+ /* for file access handling */
+#include <unistd.h>
+
+ /* network handling */
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <sys/ioctl.h>
+
+#include <fcntl.h>
+
+ /* dir handling */
+#include <sys/types.h>
+#include <dirent.h>
+
+#define AXIS2_STRRCHR(x, y) (strrchr(x, y))
+
+#define AXIS2_PLATFORM_SLEEP(x) sleep(0)
+
+ /** sleep function abstraction */
+#define AXIS2_SLEEP sleep
+#define AXIS2_USLEEP usleep
+
+ /**
+ * Platform specific method to obtain current thread ID
+ */
+#include <pthread.h>
+#define AXIS2_PLATFORM_GET_THREAD_ID() os400_getThreadID()
+
+static long long os400_getThreadID()
+{
+ pthread_id_np_t tid = pthread_getthreadid_np();
+ return *((long long *)&tid);
+}
+
+ /**
+ * Platform specific method to obtain current time in milli seconds
+ */
+struct os400_timeb
+{
+ long time;
+ long millitm;
+};
+
+static int os400_ftime(struct os400_timeb * tp)
+{
+ struct timeval t;
+ gettimeofday(&t, NULL);
+ tp->time = t.tv_sec;
+ tp->millitm = t.tv_usec/1000;
+ return 0;
+}
+#define AXIS2_PLATFORM_GET_TIME_IN_MILLIS os400_ftime
+#define AXIS2_PLATFORM_TIMEB os400_timeb
+
+ /**
+ * type to be used for 64bit integers
+ */
+#define AXIS2_LONGLONG long long
+#define AXIS2_LONGLONGVALUE(value) value##LL
+#define AXIS2_UNSIGNED_LONGLONGVALUE(value) value##ULL
+
+ /**
+ * Format string to be used in printf for 64bit integers
+ */
+#define AXIS2_PRINTF_LONGLONG_FORMAT_SPECIFIER "%lld"
+#define AXIS2_PRINTF_LONGLONG_FORMAT_SPECIFIER_CHARS "lld"
+#define AXIS2_PRINTF_UNSIGNED_LONGLONG_FORMAT_SPECIFIER "%llu"
+#define AXIS2_PRINTF_UNSIGNED_LONGLONG_FORMAT_SPECIFIER_CHARS "llu"
+
+ /**
+ * Platform specific path separator char
+ */
+
+#define AXIS2_PATH_SEP_CHAR '/'
+#define AXIS2_PATH_SEP_STR "/"
+#define AXIS2_LIB_PREFIX "lib"
+#define AXIS2_LIB_SUFFIX ".so"
+
+ /**
+ * Platform specific time
+ */
+#define AXIS2_TIME_T time_t
+
+ /**
+ * Platform specific file handling
+ */
+#define AXIS2_FOPEN fopen
+#define AXIS2_FREAD fread
+#define AXIS2_FWRITE fwrite
+#define AXIS2_FCLOSE fclose
+#define AXIS2_FTELL ftell
+#define AXIS2_ACCESS(zpath,imode) access(zpath,imode)
+#define AXIS2_R_OK R_OK /* test for read permission */
+#define AXIS2_W_OK W_OK /* test for write permission */
+#define AXIS2_X_OK X_OK /* test for execute or search permission */
+#define AXIS2_F_OK F_OK /* test whether the directories leading to the file can be
+ searched and the file exists */
+
+ /**
+ * Platform specific environment variable access method
+ */
+#define AXIS2_GETENV(_env_var_name) getenv(_env_var_name)
+
+ /**
+ * unix specific directory handling functions
+ */
+#define AXIS2_SCANDIR os400_scandir
+#define AXIS2_ALPHASORT os400_alphasort
+#define AXIS2_OPENDIR opendir
+#define AXIS2_CLOSEDIR closedir
+#define AXIS2_READDIR readdir
+#define AXIS2_READDIR_R readdir_r
+#define AXIS2_REWINDDIR rewinddir
+#define AXIS2_MKDIR mkdir
+#define AXIS2_GETCWD getcwd
+#define AXIS2_CHDIR chdir
+
+ /**
+ * network specific functions and defs
+ */
+#define axis2_socket_t int
+#define AXIS2_INVALID_SOCKET -1
+#define AXIS2_INADDR_NONE (in_addr_t)-1
+#define axis2_unsigned_short_t uint16_t
+#define AXIS2_CLOSE_SOCKET(sock) close(sock)
+#define AXIS2_CLOSE_SOCKET_ON_EXIT(sock) fcntl(sock,F_SETFD, FD_CLOEXEC)
+#define axis2_socket_len_t socklen_t
+#define AXIS2_SHUT_WR SHUT_WR
+
+ /** getopt function */
+#define AXIS2_GETOPT getopt
+
+ /** minizip functions */
+#define axis2_fill_win32_filefunc(ffunc)
+#define AXIS2_UNZOPEN2(zipfilename,ffunc) do { unzOpen2(zipfilename,NULL); memset(&ffunc, 0, sizeof(ffunc)); } while (0)
+
+ /**
+ * handling variable number of arguments (for log.c)
+ */
+#define AXIS2_VSNPRINTF vsnprintf
+
+#define AXIS2_SNPRINTF snprintf
+
+#define axis2_gmtime_r gmtime_r
+
+ /** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AXIS2_UNIX_H */
diff --git a/util/include/platforms/windows/axutil_uuid_gen_windows.h b/util/include/platforms/windows/axutil_uuid_gen_windows.h
index f8c0872..3b9a371 100644
--- a/util/include/platforms/windows/axutil_uuid_gen_windows.h
+++ b/util/include/platforms/windows/axutil_uuid_gen_windows.h
@@ -1,46 +1,46 @@
-/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed 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 AXIS2_UDDI_GEN_WINDOWS_H
-#define AXIS2_UDDI_GEN_WINDOWS_H
-
-#include <axutil_utils_defines.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-
-#endif /* */
-
- /* Function prototypes */
-
-
- /**
- * Generate universally unique id
- * @return a char pointer to uuid
- */
- AXIS2_EXTERN axis2_char_t * AXIS2_CALL
- axutil_platform_uuid_gen(
- char *s);
-
-
- /** @} */
-#ifdef __cplusplus
-}
-#endif /* */
-
-#endif /* AXIS2_UDDI_GEN_WINDOWS_H */
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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 AXIS2_UDDI_GEN_WINDOWS_H
+#define AXIS2_UDDI_GEN_WINDOWS_H
+
+#include <axutil_utils_defines.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+
+#endif /* */
+
+ /* Function prototypes */
+
+
+ /**
+ * Generate universally unique id
+ * @return a char pointer to uuid
+ */
+ AXIS2_EXTERN axis2_char_t * AXIS2_CALL
+ axutil_platform_uuid_gen(
+ char *s);
+
+
+ /** @} */
+#ifdef __cplusplus
+}
+#endif /* */
+
+#endif /* AXIS2_UDDI_GEN_WINDOWS_H */
diff --git a/util/src/network_handler.c b/util/src/network_handler.c
index ae41943..40c9723 100644
--- a/util/src/network_handler.c
+++ b/util/src/network_handler.c
@@ -1,646 +1,646 @@
-/*
- * 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.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <axutil_network_handler.h>
-#include <fcntl.h>
-
-
-#if defined(WIN32)
-/* fix for an older version of winsock2.h */
-#if !defined(SO_EXCLUSIVEADDRUSE)
-#define SO_EXCLUSIVEADDRUSE ((int)(~SO_REUSEADDR))
-#endif
-#endif
-
-#if defined(WIN32)
-static int is_init_socket = 0;
-axis2_bool_t axis2_init_socket(
-);
-#endif
-
-AXIS2_EXTERN axis2_socket_t AXIS2_CALL
-axutil_network_handler_open_socket(
- const axutil_env_t *env,
- char *server,
- int port)
-{
- axis2_socket_t sock = AXIS2_INVALID_SOCKET;
- struct sockaddr_in sock_addr;
- struct linger ll;
- int nodelay = 1;
-
-#if defined(WIN32)
- if (is_init_socket == 0)
- {
- axis2_init_socket();
- is_init_socket = 1;
- }
-#endif
-
- AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
- AXIS2_PARAM_CHECK(env->error, server, AXIS2_INVALID_SOCKET);
-
-#ifndef WIN32
- if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
- /*AF_INET is not defined in sys/socket.h but PF_INET */
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
-#else
- if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
- /* In Win 32 if the socket creation failed it return 0 not a negative value */
- {
- char buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- /* Get the detailed error message */
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
-#endif
-
- memset(&sock_addr, 0, sizeof(sock_addr));
- sock_addr.sin_family = AF_INET;
- sock_addr.sin_addr.s_addr = inet_addr(server); /*arpa/inet.d */
-
- if(sock_addr.sin_addr.s_addr == AXIS2_INADDR_NONE) /*netinet/in.h */
- {
- /*
- * server may be a host name
- */
- struct hostent *lphost = NULL;
- lphost = gethostbyname(server);
-
- if(lphost)
- {
- sock_addr.sin_addr.s_addr = ((struct in_addr *)lphost->h_addr)->s_addr;
- }
- else
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
- }
-
- sock_addr.sin_port = htons((axis2_unsigned_short_t)port);
-
- /* Connect to server */
- if(connect(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0)
- {
- AXIS2_CLOSE_SOCKET(sock);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
- setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&nodelay, sizeof(nodelay));
- ll.l_onoff = 1;
- ll.l_linger = 5;
- setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *)&ll, sizeof(struct linger));
- return sock;
-}
-
-AXIS2_EXTERN axis2_socket_t AXIS2_CALL
-axutil_network_handler_create_server_socket(
- const axutil_env_t *env,
- int port)
-{
- axis2_socket_t sock = AXIS2_INVALID_SOCKET;
- axis2_socket_t i = 0;
- struct sockaddr_in sock_addr;
-
- AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
-#if defined(WIN32)
- if (is_init_socket == 0)
- {
- axis2_init_socket();
- is_init_socket = 1;
- }
-#endif
- sock = socket(AF_INET, SOCK_STREAM, 0);
-
-#ifndef WIN32
- if(sock < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
-#else
- if (sock == INVALID_SOCKET)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
- return AXIS2_INVALID_SOCKET;
- }
-#endif
- /* Address re-use */
- i = 1;
-#if defined(WIN32)
- setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *) &i, sizeof(axis2_socket_t)); /*casted 4th param to char* */
-#else
- setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&i, sizeof(axis2_socket_t)); /*casted 4th param to char* */
-#endif
-
- /* Exec behaviour */
- AXIS2_CLOSE_SOCKET_ON_EXIT(sock);
- memset(&sock_addr, 0, sizeof(sock_addr));
-
- sock_addr.sin_family = AF_INET;
- sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- sock_addr.sin_port = htons((axis2_unsigned_short_t)port);
-
- /* Bind the socket to our port number */
- if(bind(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_BIND_FAILED, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
- if(listen(sock, 50) < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_LISTEN_FAILED, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
- return sock;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axutil_network_handler_close_socket(
- const axutil_env_t *env,
- axis2_socket_t socket)
-{
- int i = 0;
- char buf[32];
- if(socket < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_SOCKET, AXIS2_FAILURE);
- return AXIS2_FAILURE;
- }
- shutdown(socket, AXIS2_SHUT_WR);
- axutil_network_handler_set_sock_option(env, socket, SO_RCVTIMEO, 1);
- i = recv(socket, buf, 32, 0);
- AXIS2_CLOSE_SOCKET(socket);
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axutil_network_handler_set_sock_option(
- const axutil_env_t *env,
- axis2_socket_t socket,
- int option,
- int value)
-{
- if(option == SO_RCVTIMEO || option == SO_SNDTIMEO)
- {
-#if defined(WIN32)
- DWORD tv = value; /* windows expects milliseconds in a DWORD */
-#else
- struct timeval tv;
- /* we deal with milliseconds */
- tv.tv_sec = value / 1000;
- tv.tv_usec = (value % 1000) * 1000;
-#endif
- setsockopt(socket, SOL_SOCKET, option, (char *)&tv, sizeof(tv));
- return AXIS2_SUCCESS;
- }
- else if(option == SO_REUSEADDR)
- {
- if((setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, (char *)&value, sizeof(value))) < 0)
- {
- return AXIS2_FAILURE;
- }
- return AXIS2_SUCCESS;
- }
- return AXIS2_FAILURE;
-}
-
-AXIS2_EXTERN axis2_socket_t AXIS2_CALL
-axutil_network_handler_svr_socket_accept(
- const axutil_env_t *env,
- axis2_socket_t svr_socket)
-{
- struct sockaddr cli_addr;
- struct linger ll;
- int nodelay = 1;
- axis2_socket_len_t cli_len = 0;
- axis2_socket_t cli_socket = AXIS2_INVALID_SOCKET;
- AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
-
- cli_len = sizeof(cli_addr);
- cli_socket = accept(svr_socket, (struct sockaddr *)&cli_addr, &cli_len);
-#ifndef WIN32
- if(cli_socket < 0)
- {
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "[Axis2][network_handler] Socket accept \
- failed");
- }
-#else
- if (cli_socket == INVALID_SOCKET)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
- }
-#endif
-
- setsockopt(svr_socket, IPPROTO_TCP, TCP_NODELAY, (const char *)&nodelay, (int)sizeof(nodelay));
- /* We are sure that the difference lies within the int range */
- ll.l_onoff = 1;
- ll.l_linger = 5;
- setsockopt(cli_socket, SOL_SOCKET, SO_LINGER, (const char *)&ll, (int)sizeof(struct linger));
- /* We are sure that the difference lies within the int range */
- return cli_socket;
-}
-
-#if defined (WIN32)
-axis2_bool_t
-axis2_init_socket(
-)
-{
- WORD wVersionRequested;
- WSADATA wsaData;
- int err;
- wVersionRequested = MAKEWORD(2, 2);
-
- err = WSAStartup(wVersionRequested, &wsaData);
-
- if (err != 0)
- return 0; /* WinSock 2.2 not found */
-
- /* Confirm that the WinSock DLL supports 2.2.
- * Note that if the DLL supports versions greater
- * than 2.2 in addition to 2.2, it will still return
- * 2.2 in wVersion since that is the version we
- * requested.
- */
-
- if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2)
- {
- WSACleanup();
- return 0; /* WinSock 2.2 not supported */
- }
- return 1;
-}
-#endif
-
-AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-axutil_network_handler_get_svr_ip(
- const axutil_env_t *env,
- axis2_socket_t socket)
-{
- struct sockaddr_in addr;
- axis2_socket_len_t len = sizeof(addr);
- char *ret = NULL;
- memset(&addr, 0, sizeof(addr));
- if(getsockname(socket, (struct sockaddr *)&addr, &len) < 0)
- {
- return NULL;
- }
- ret = inet_ntoa(addr.sin_addr);
- return ret;
-}
-
-AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-axutil_network_handler_get_peer_ip(
- const axutil_env_t *env,
- axis2_socket_t socket)
-{
- struct sockaddr_in addr;
- axis2_socket_len_t len = sizeof(addr);
- char *ret = NULL;
- memset(&addr, 0, sizeof(addr));
- if(getpeername(socket, (struct sockaddr *)&addr, &len) < 0)
- {
- return NULL;
- }
- ret = inet_ntoa(addr.sin_addr);
- return ret;
-}
-
-AXIS2_EXTERN axis2_socket_t AXIS2_CALL
-axutil_network_handler_create_dgram_svr_socket(
- const axutil_env_t *env,
- int port)
-{
- axis2_socket_t sock = AXIS2_INVALID_SOCKET;
- struct sockaddr_in sock_addr;
-
- AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
-#if defined(WIN32)
- if (is_init_socket == 0)
- {
- axis2_init_socket();
- is_init_socket = 1;
- }
-#endif
- sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-
-#ifndef WIN32
- if(sock < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
-#else
- if (sock == INVALID_SOCKET)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
- return AXIS2_INVALID_SOCKET;
- }
-#endif
- /* Exec behaviour */
- AXIS2_CLOSE_SOCKET_ON_EXIT(sock);
- memset(&sock_addr, 0, sizeof(sock_addr));
-
- sock_addr.sin_family = AF_INET;
- sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- sock_addr.sin_port = htons((axis2_unsigned_short_t)port);
-
- /* Bind the socket to our port number */
- if(bind(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_BIND_FAILED, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
- return sock;
-}
-
-AXIS2_EXTERN axis2_socket_t AXIS2_CALL
-axutil_network_handler_open_dgram_socket(
- const axutil_env_t *env)
-{
- axis2_socket_t sock = AXIS2_INVALID_SOCKET;
-#if defined(WIN32)
- if (is_init_socket == 0)
- {
- axis2_init_socket();
- is_init_socket = 1;
- }
-#endif
-
-#ifndef WIN32
- if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
- /*AF_INET is not defined in sys/socket.h but PF_INET */
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
-#else
- if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET)
- /* In Win 32 if the socket creation failed it return 0 not a negative value */
- {
- char buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- /* Get the detailed error message */
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
-#endif
- return sock;
-}
-
-/*
- * This function blocks until data is available to read from the socket
- * and read all the data in the socket. If the buffer size specified is
- * lesser than the actual data a failure will be returned.
- */
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axutil_network_handler_read_dgram(
- const axutil_env_t *env,
- axis2_socket_t sock,
- axis2_char_t *buffer,
- int *buf_len,
- axis2_char_t **addr,
- int *port)
-{
- struct sockaddr_in sender_address;
- int received = 0;
- socklen_t sender_address_size;
-
- sender_address_size = sizeof(sender_address);
- received = recvfrom(sock, buffer, *buf_len, 0, (struct sockaddr *)&sender_address, &sender_address_size);
-#ifdef WIN32
- if (SOCKET_ERROR == received)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
- return AXIS2_FAILURE;
- }
-#else
- if(received < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
-#endif
- if(port && addr)
- {
- *port = ntohs(sender_address.sin_port);
- *addr = inet_ntoa(sender_address.sin_addr);
- }
- *buf_len = received;
- return AXIS2_SUCCESS;
-}
-
-/*
- * Sends a datagram to the specified location.
- */
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axutil_network_handler_send_dgram(
- const axutil_env_t *env,
- axis2_socket_t sock,
- axis2_char_t *buff,
- int *buf_len,
- axis2_char_t *addr,
- int dest_port,
- int *source_port)
-{
- struct sockaddr_in recv_addr, source_addr;
- int send_bytes = 0;
- unsigned int recv_addr_size = 0;
- socklen_t source_addr_size = sizeof(source_addr);
- recv_addr_size = sizeof(recv_addr);
-
- memset(&recv_addr, 0, sizeof(recv_addr));
- memset(&recv_addr, 0, sizeof(source_addr));
-
- recv_addr.sin_addr.s_addr = inet_addr(addr);
- if(recv_addr.sin_addr.s_addr == AXIS2_INADDR_NONE) /*netinet/in.h */
- {
- /*
- * server may be a host name
- */
- struct hostent *lphost = NULL;
- lphost = gethostbyname(addr);
-
- if(lphost)
- {
- recv_addr.sin_addr.s_addr = ((struct in_addr *)lphost->h_addr)->s_addr;
- }
- else
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS, AXIS2_FAILURE);
- return AXIS2_FAILURE;
- }
- }
-
- recv_addr.sin_family = AF_INET;
- recv_addr.sin_port = htons((axis2_unsigned_short_t)dest_port);
-
- send_bytes = sendto(sock, buff, *buf_len, 0, (struct sockaddr *)&recv_addr, recv_addr_size);
-
- getsockname(sock, (struct sockaddr *)&source_addr, &source_addr_size);
-
-#ifdef WIN32
- if (send_bytes == SOCKET_ERROR)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
- return AXIS2_FAILURE;
- }
-#else
- if(send_bytes < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- return AXIS2_FAILURE;
- }
-#endif
- if(source_port)
- {
- *source_port = ntohs(source_addr.sin_port);
- }
- *buf_len = send_bytes;
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axutil_network_handler_bind_socket(
- const axutil_env_t *env,
- axis2_socket_t sock,
- int port)
-{
- struct sockaddr_in source_addr;
-
- memset(&source_addr, 0, sizeof(source_addr));
- source_addr.sin_family = AF_INET;
- source_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- source_addr.sin_port = htons((axis2_unsigned_short_t)port);
-#ifdef WIN32
- if (bind(sock, (struct sockaddr *)&source_addr, sizeof(source_addr)) == SOCKET_ERROR)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
- return AXIS2_FAILURE;
- }
-#else
- if(bind(sock, (struct sockaddr *)&source_addr, sizeof(source_addr)) < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
-#endif
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN axis2_socket_t AXIS2_CALL
-axutil_network_hadler_create_multicast_svr_socket(
- const axutil_env_t *env,
- int port,
- axis2_char_t *mul_addr)
-{
- axis2_socket_t sock = AXIS2_INVALID_SOCKET;
- struct sockaddr_in sock_addr;
- struct ip_mreq mc_req;
-
- AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
-#if defined(WIN32)
- if (is_init_socket == 0)
- {
- axis2_init_socket();
- is_init_socket = 1;
- }
-#endif
- sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-
-#ifndef WIN32
- if(sock < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- return AXIS2_FAILURE;
- }
-#else
- if (sock == INVALID_SOCKET)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
- return AXIS2_FAILURE;
- }
-#endif
-
- /* Exec behaviour */
- AXIS2_CLOSE_SOCKET_ON_EXIT(sock);
- memset(&sock_addr, 0, sizeof(sock_addr));
-
- sock_addr.sin_family = AF_INET;
- sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- sock_addr.sin_port = htons((axis2_unsigned_short_t)port);
-
- /* Bind the socket to our port number */
- if(bind(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_BIND_FAILED, AXIS2_FAILURE);
- return AXIS2_INVALID_SOCKET;
- }
-
- /* Send an IGMP request to join the multicast group */
- mc_req.imr_multiaddr.s_addr = inet_addr(mul_addr);
- mc_req.imr_interface.s_addr = htonl(INADDR_ANY);
-#ifdef WIN32
- if ((setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mc_req, sizeof(mc_req))) == SOCKET_ERROR)
- {
- axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
- axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
- return AXIS2_FAILURE;
- }
-#else
- if((setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&mc_req, sizeof(mc_req))) < 0)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
- return AXIS2_FAILURE;
- }
-#endif
- return sock;
-}
-
+/*
+ * 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.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <axutil_network_handler.h>
+#include <fcntl.h>
+
+
+#if defined(WIN32)
+/* fix for an older version of winsock2.h */
+#if !defined(SO_EXCLUSIVEADDRUSE)
+#define SO_EXCLUSIVEADDRUSE ((int)(~SO_REUSEADDR))
+#endif
+#endif
+
+#if defined(WIN32)
+static int is_init_socket = 0;
+axis2_bool_t axis2_init_socket(
+);
+#endif
+
+AXIS2_EXTERN axis2_socket_t AXIS2_CALL
+axutil_network_handler_open_socket(
+ const axutil_env_t *env,
+ char *server,
+ int port)
+{
+ axis2_socket_t sock = AXIS2_INVALID_SOCKET;
+ struct sockaddr_in sock_addr;
+ struct linger ll;
+ int nodelay = 1;
+
+#if defined(WIN32)
+ if (is_init_socket == 0)
+ {
+ axis2_init_socket();
+ is_init_socket = 1;
+ }
+#endif
+
+ AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, server, AXIS2_INVALID_SOCKET);
+
+#ifndef WIN32
+ if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+ /*AF_INET is not defined in sys/socket.h but PF_INET */
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+#else
+ if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
+ /* In Win 32 if the socket creation failed it return 0 not a negative value */
+ {
+ char buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ /* Get the detailed error message */
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+#endif
+
+ memset(&sock_addr, 0, sizeof(sock_addr));
+ sock_addr.sin_family = AF_INET;
+ sock_addr.sin_addr.s_addr = inet_addr(server); /*arpa/inet.d */
+
+ if(sock_addr.sin_addr.s_addr == AXIS2_INADDR_NONE) /*netinet/in.h */
+ {
+ /*
+ * server may be a host name
+ */
+ struct hostent *lphost = NULL;
+ lphost = gethostbyname(server);
+
+ if(lphost)
+ {
+ sock_addr.sin_addr.s_addr = ((struct in_addr *)lphost->h_addr)->s_addr;
+ }
+ else
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+ }
+
+ sock_addr.sin_port = htons((axis2_unsigned_short_t)port);
+
+ /* Connect to server */
+ if(connect(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0)
+ {
+ AXIS2_CLOSE_SOCKET(sock);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+ setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&nodelay, sizeof(nodelay));
+ ll.l_onoff = 1;
+ ll.l_linger = 5;
+ setsockopt(sock, SOL_SOCKET, SO_LINGER, (const char *)&ll, sizeof(struct linger));
+ return sock;
+}
+
+AXIS2_EXTERN axis2_socket_t AXIS2_CALL
+axutil_network_handler_create_server_socket(
+ const axutil_env_t *env,
+ int port)
+{
+ axis2_socket_t sock = AXIS2_INVALID_SOCKET;
+ axis2_socket_t i = 0;
+ struct sockaddr_in sock_addr;
+
+ AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
+#if defined(WIN32)
+ if (is_init_socket == 0)
+ {
+ axis2_init_socket();
+ is_init_socket = 1;
+ }
+#endif
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+
+#ifndef WIN32
+ if(sock < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+#else
+ if (sock == INVALID_SOCKET)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ return AXIS2_INVALID_SOCKET;
+ }
+#endif
+ /* Address re-use */
+ i = 1;
+#if defined(WIN32)
+ setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *) &i, sizeof(axis2_socket_t)); /*casted 4th param to char* */
+#else
+ setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&i, sizeof(axis2_socket_t)); /*casted 4th param to char* */
+#endif
+
+ /* Exec behaviour */
+ AXIS2_CLOSE_SOCKET_ON_EXIT(sock);
+ memset(&sock_addr, 0, sizeof(sock_addr));
+
+ sock_addr.sin_family = AF_INET;
+ sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ sock_addr.sin_port = htons((axis2_unsigned_short_t)port);
+
+ /* Bind the socket to our port number */
+ if(bind(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_BIND_FAILED, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+ if(listen(sock, 50) < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_LISTEN_FAILED, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+ return sock;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axutil_network_handler_close_socket(
+ const axutil_env_t *env,
+ axis2_socket_t socket)
+{
+ int i = 0;
+ char buf[32];
+ if(socket < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_SOCKET, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+ shutdown(socket, AXIS2_SHUT_WR);
+ axutil_network_handler_set_sock_option(env, socket, SO_RCVTIMEO, 1);
+ i = recv(socket, buf, 32, 0);
+ AXIS2_CLOSE_SOCKET(socket);
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axutil_network_handler_set_sock_option(
+ const axutil_env_t *env,
+ axis2_socket_t socket,
+ int option,
+ int value)
+{
+ if(option == SO_RCVTIMEO || option == SO_SNDTIMEO)
+ {
+#if defined(WIN32)
+ DWORD tv = value; /* windows expects milliseconds in a DWORD */
+#else
+ struct timeval tv;
+ /* we deal with milliseconds */
+ tv.tv_sec = value / 1000;
+ tv.tv_usec = (value % 1000) * 1000;
+#endif
+ setsockopt(socket, SOL_SOCKET, option, (char *)&tv, sizeof(tv));
+ return AXIS2_SUCCESS;
+ }
+ else if(option == SO_REUSEADDR)
+ {
+ if((setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, (char *)&value, sizeof(value))) < 0)
+ {
+ return AXIS2_FAILURE;
+ }
+ return AXIS2_SUCCESS;
+ }
+ return AXIS2_FAILURE;
+}
+
+AXIS2_EXTERN axis2_socket_t AXIS2_CALL
+axutil_network_handler_svr_socket_accept(
+ const axutil_env_t *env,
+ axis2_socket_t svr_socket)
+{
+ struct sockaddr cli_addr;
+ struct linger ll;
+ int nodelay = 1;
+ axis2_socket_len_t cli_len = 0;
+ axis2_socket_t cli_socket = AXIS2_INVALID_SOCKET;
+ AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
+
+ cli_len = sizeof(cli_addr);
+ cli_socket = accept(svr_socket, (struct sockaddr *)&cli_addr, &cli_len);
+#ifndef WIN32
+ if(cli_socket < 0)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "[Axis2][network_handler] Socket accept \
+ failed");
+ }
+#else
+ if (cli_socket == INVALID_SOCKET)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ }
+#endif
+
+ setsockopt(svr_socket, IPPROTO_TCP, TCP_NODELAY, (const char *)&nodelay, (int)sizeof(nodelay));
+ /* We are sure that the difference lies within the int range */
+ ll.l_onoff = 1;
+ ll.l_linger = 5;
+ setsockopt(cli_socket, SOL_SOCKET, SO_LINGER, (const char *)&ll, (int)sizeof(struct linger));
+ /* We are sure that the difference lies within the int range */
+ return cli_socket;
+}
+
+#if defined (WIN32)
+axis2_bool_t
+axis2_init_socket(
+)
+{
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ int err;
+ wVersionRequested = MAKEWORD(2, 2);
+
+ err = WSAStartup(wVersionRequested, &wsaData);
+
+ if (err != 0)
+ return 0; /* WinSock 2.2 not found */
+
+ /* Confirm that the WinSock DLL supports 2.2.
+ * Note that if the DLL supports versions greater
+ * than 2.2 in addition to 2.2, it will still return
+ * 2.2 in wVersion since that is the version we
+ * requested.
+ */
+
+ if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2)
+ {
+ WSACleanup();
+ return 0; /* WinSock 2.2 not supported */
+ }
+ return 1;
+}
+#endif
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+axutil_network_handler_get_svr_ip(
+ const axutil_env_t *env,
+ axis2_socket_t socket)
+{
+ struct sockaddr_in addr;
+ axis2_socket_len_t len = sizeof(addr);
+ char *ret = NULL;
+ memset(&addr, 0, sizeof(addr));
+ if(getsockname(socket, (struct sockaddr *)&addr, &len) < 0)
+ {
+ return NULL;
+ }
+ ret = inet_ntoa(addr.sin_addr);
+ return ret;
+}
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+axutil_network_handler_get_peer_ip(
+ const axutil_env_t *env,
+ axis2_socket_t socket)
+{
+ struct sockaddr_in addr;
+ axis2_socket_len_t len = sizeof(addr);
+ char *ret = NULL;
+ memset(&addr, 0, sizeof(addr));
+ if(getpeername(socket, (struct sockaddr *)&addr, &len) < 0)
+ {
+ return NULL;
+ }
+ ret = inet_ntoa(addr.sin_addr);
+ return ret;
+}
+
+AXIS2_EXTERN axis2_socket_t AXIS2_CALL
+axutil_network_handler_create_dgram_svr_socket(
+ const axutil_env_t *env,
+ int port)
+{
+ axis2_socket_t sock = AXIS2_INVALID_SOCKET;
+ struct sockaddr_in sock_addr;
+
+ AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
+#if defined(WIN32)
+ if (is_init_socket == 0)
+ {
+ axis2_init_socket();
+ is_init_socket = 1;
+ }
+#endif
+ sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+
+#ifndef WIN32
+ if(sock < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+#else
+ if (sock == INVALID_SOCKET)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ return AXIS2_INVALID_SOCKET;
+ }
+#endif
+ /* Exec behaviour */
+ AXIS2_CLOSE_SOCKET_ON_EXIT(sock);
+ memset(&sock_addr, 0, sizeof(sock_addr));
+
+ sock_addr.sin_family = AF_INET;
+ sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ sock_addr.sin_port = htons((axis2_unsigned_short_t)port);
+
+ /* Bind the socket to our port number */
+ if(bind(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_BIND_FAILED, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+ return sock;
+}
+
+AXIS2_EXTERN axis2_socket_t AXIS2_CALL
+axutil_network_handler_open_dgram_socket(
+ const axutil_env_t *env)
+{
+ axis2_socket_t sock = AXIS2_INVALID_SOCKET;
+#if defined(WIN32)
+ if (is_init_socket == 0)
+ {
+ axis2_init_socket();
+ is_init_socket = 1;
+ }
+#endif
+
+#ifndef WIN32
+ if((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+ /*AF_INET is not defined in sys/socket.h but PF_INET */
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+#else
+ if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET)
+ /* In Win 32 if the socket creation failed it return 0 not a negative value */
+ {
+ char buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ /* Get the detailed error message */
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+#endif
+ return sock;
+}
+
+/*
+ * This function blocks until data is available to read from the socket
+ * and read all the data in the socket. If the buffer size specified is
+ * lesser than the actual data a failure will be returned.
+ */
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axutil_network_handler_read_dgram(
+ const axutil_env_t *env,
+ axis2_socket_t sock,
+ axis2_char_t *buffer,
+ int *buf_len,
+ axis2_char_t **addr,
+ int *port)
+{
+ struct sockaddr_in sender_address;
+ int received = 0;
+ socklen_t sender_address_size;
+
+ sender_address_size = sizeof(sender_address);
+ received = recvfrom(sock, buffer, *buf_len, 0, (struct sockaddr *)&sender_address, &sender_address_size);
+#ifdef WIN32
+ if (SOCKET_ERROR == received)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ return AXIS2_FAILURE;
+ }
+#else
+ if(received < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+#endif
+ if(port && addr)
+ {
+ *port = ntohs(sender_address.sin_port);
+ *addr = inet_ntoa(sender_address.sin_addr);
+ }
+ *buf_len = received;
+ return AXIS2_SUCCESS;
+}
+
+/*
+ * Sends a datagram to the specified location.
+ */
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axutil_network_handler_send_dgram(
+ const axutil_env_t *env,
+ axis2_socket_t sock,
+ axis2_char_t *buff,
+ int *buf_len,
+ axis2_char_t *addr,
+ int dest_port,
+ int *source_port)
+{
+ struct sockaddr_in recv_addr, source_addr;
+ int send_bytes = 0;
+ unsigned int recv_addr_size = 0;
+ socklen_t source_addr_size = sizeof(source_addr);
+ recv_addr_size = sizeof(recv_addr);
+
+ memset(&recv_addr, 0, sizeof(recv_addr));
+ memset(&recv_addr, 0, sizeof(source_addr));
+
+ recv_addr.sin_addr.s_addr = inet_addr(addr);
+ if(recv_addr.sin_addr.s_addr == AXIS2_INADDR_NONE) /*netinet/in.h */
+ {
+ /*
+ * server may be a host name
+ */
+ struct hostent *lphost = NULL;
+ lphost = gethostbyname(addr);
+
+ if(lphost)
+ {
+ recv_addr.sin_addr.s_addr = ((struct in_addr *)lphost->h_addr)->s_addr;
+ }
+ else
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_ADDRESS, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+ }
+
+ recv_addr.sin_family = AF_INET;
+ recv_addr.sin_port = htons((axis2_unsigned_short_t)dest_port);
+
+ send_bytes = sendto(sock, buff, *buf_len, 0, (struct sockaddr *)&recv_addr, recv_addr_size);
+
+ getsockname(sock, (struct sockaddr *)&source_addr, &source_addr_size);
+
+#ifdef WIN32
+ if (send_bytes == SOCKET_ERROR)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ return AXIS2_FAILURE;
+ }
+#else
+ if(send_bytes < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+#endif
+ if(source_port)
+ {
+ *source_port = ntohs(source_addr.sin_port);
+ }
+ *buf_len = send_bytes;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axutil_network_handler_bind_socket(
+ const axutil_env_t *env,
+ axis2_socket_t sock,
+ int port)
+{
+ struct sockaddr_in source_addr;
+
+ memset(&source_addr, 0, sizeof(source_addr));
+ source_addr.sin_family = AF_INET;
+ source_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ source_addr.sin_port = htons((axis2_unsigned_short_t)port);
+#ifdef WIN32
+ if (bind(sock, (struct sockaddr *)&source_addr, sizeof(source_addr)) == SOCKET_ERROR)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ return AXIS2_FAILURE;
+ }
+#else
+ if(bind(sock, (struct sockaddr *)&source_addr, sizeof(source_addr)) < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+#endif
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_socket_t AXIS2_CALL
+axutil_network_hadler_create_multicast_svr_socket(
+ const axutil_env_t *env,
+ int port,
+ axis2_char_t *mul_addr)
+{
+ axis2_socket_t sock = AXIS2_INVALID_SOCKET;
+ struct sockaddr_in sock_addr;
+ struct ip_mreq mc_req;
+
+ AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
+#if defined(WIN32)
+ if (is_init_socket == 0)
+ {
+ axis2_init_socket();
+ is_init_socket = 1;
+ }
+#endif
+ sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+
+#ifndef WIN32
+ if(sock < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+#else
+ if (sock == INVALID_SOCKET)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ return AXIS2_FAILURE;
+ }
+#endif
+
+ /* Exec behaviour */
+ AXIS2_CLOSE_SOCKET_ON_EXIT(sock);
+ memset(&sock_addr, 0, sizeof(sock_addr));
+
+ sock_addr.sin_family = AF_INET;
+ sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ sock_addr.sin_port = htons((axis2_unsigned_short_t)port);
+
+ /* Bind the socket to our port number */
+ if(bind(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_BIND_FAILED, AXIS2_FAILURE);
+ return AXIS2_INVALID_SOCKET;
+ }
+
+ /* Send an IGMP request to join the multicast group */
+ mc_req.imr_multiaddr.s_addr = inet_addr(mul_addr);
+ mc_req.imr_interface.s_addr = htonl(INADDR_ANY);
+#ifdef WIN32
+ if ((setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mc_req, sizeof(mc_req))) == SOCKET_ERROR)
+ {
+ axis2_char_t buf[AXUTIL_WIN32_ERROR_BUFSIZE];
+ axutil_win32_get_last_wsa_error(buf, AXUTIL_WIN32_ERROR_BUFSIZE);
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, buf);
+ return AXIS2_FAILURE;
+ }
+#else
+ if((setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&mc_req, sizeof(mc_req))) < 0)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOCKET_ERROR, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+#endif
+ return sock;
+}
+
diff --git a/util/src/platforms/os400/platformSpecificOS400.c b/util/src/platforms/os400/platformSpecificOS400.c
index be60e8c..969d345 100644
--- a/util/src/platforms/os400/platformSpecificOS400.c
+++ b/util/src/platforms/os400/platformSpecificOS400.c
@@ -1,388 +1,388 @@
-/*
- * Copyright 2004-2004 The Apache Software Foundation.
-// (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved
- *
- * Licensed 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.
- */
-
-
-#include "platforms/axutil_platform_auto_sense.h"
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <qusec.h> // Qus_EC_t
-#include <mih/rslvsp.h> // rslvsp()
-#include <mih/micommon.h> // _AUTH_EXECUTE
-#include <qleawi.h> // QleActBndPgm(), QleGetExp()
-#include <qp0lstdi.h> // Qp0lCvtPathToQSYSObjName()
-#include <unistd.h> // readlink()
-#include <except.h>
-#include <errno.h>
-#include <qwcrtvca.h> // Retrieve job's ccsid API prototype
-
-
-
-/**********************************************************************/
-/* Function: */
-/* retrieveJobCcsid */
-/* Description: */
-/* Retrieves the ccsid of the current job. */
-/* If the current job's ccsid is 65535, the job's default ccsid is */
-/* returned. */
-/* If the ccsid cannot be retrieved (error occurs), -1 is returned. */
-/* Return: */
-/* int status of call. if 0, success; -1 failure. */
-/**********************************************************************/
-
-#define RTV_CCSID_ATTR_LEN 512
-
-static int retrieveJobCcsid(int *ccsid, char *langID)
-{
- char receiverVariable[RTV_CCSID_ATTR_LEN];
- char format[8] = {'R', 'T', 'V', 'C', '0', '1', '0', '0'};
- int numberOfAttributes = 3;
- int attributeKeys[3] = {QWCA_KEY_CCSID, QWCA_KEY_DEFAULTCCSID, QWCA_KEY_LANGID};
- Qwc_RTVC_Attribute_Data_t *attribute;
- int defaultCcsid;
- char errorCode[8];
- int i;
- memset(errorCode, 0x00, sizeof(errorCode));
-
-#pragma exception_handler(RetrieveJobCcsidError,0,_C1_ALL,_C2_ALL,_CTLA_HANDLE)
- QWCRTVCA(receiverVariable,RTV_CCSID_ATTR_LEN,format,numberOfAttributes,attributeKeys,&errorCode);
-#pragma disable_handler
- if (((Qwc_RTVC0100_t *)receiverVariable)->Number_Fields_Rtnd != 3)
- {
- /* Unable to retrieve the ccsid information */
- return -1;
- }
- /* Retrieved ccsid, default CCSID and language ID */
- attribute = (Qwc_RTVC_Attribute_Data_t *)(receiverVariable + sizeof(int));
- for (i=0; i < 3; i++)
- {
- if (attribute->Key_Field == QWCA_KEY_CCSID)
- *ccsid = *(int *)((char *)attribute + sizeof(Qwc_RTVC_Attribute_Data_t));
- else if (attribute->Key_Field == QWCA_KEY_DEFAULTCCSID)
- defaultCcsid = *(int *)((char *)attribute + sizeof(Qwc_RTVC_Attribute_Data_t));
- else
- strncpy(langID, ((char *)attribute + sizeof(Qwc_RTVC_Attribute_Data_t)), 3);
- attribute = (Qwc_RTVC_Attribute_Data_t *)((char *)attribute + attribute->Length_Field_Info_Rtnd);
- }
- if (*ccsid == 65535)
- *ccsid = defaultCcsid;
-
- return 0;
-
- RetrieveJobCcsidError:
- return -1;
-}
-
-
-typedef int HMODULE;
-
-static char *dlErrorMessage = NULL;
-
-/*
- * ==========================================
- * dlopen()
- * Gain access to an executable object file.
- * ==========================================
- */
-void * os400_dlopen(const char *file)
-{
- Qus_EC_t err = { sizeof(err), 0};
- int rc;
- char dllPath[4*1024+1];
- char *fp;
- char pathNameBuffer[8*1024];
- Qlg_Path_Name_T *pathName;
- Qp0l_QSYS_Info_t qsys_info;
- char objectName[11];
- char objectLibrary[11];
- _SYSPTR sysP;
- _OBJ_TYPE_T objectType;
- HMODULE handle;
- int actInfoLen;
- Qle_ABP_Info_t activationInfo;
- void *returnHandle;
-
- dlErrorMessage = NULL;
-
- // Assume symbolic link, if error, assume actual path
-
- memset(dllPath, 0x00, 4*1024+1);
- rc = readlink ( file , dllPath, 4*1024);
- if (rc == -1)
- strcpy(dllPath, file);
-
- // Uppercase file
- fp = dllPath;
- while (*fp++) *fp = toupper(*fp);
-
- // Parse the path to its QSYS.LIB file system name: library and service program.
-
- pathName = (Qlg_Path_Name_T *)pathNameBuffer;
-
- memset(pathNameBuffer, 0x00, sizeof (pathNameBuffer));
- pathName->Path_Length = strlen(dllPath);
- memcpy( &(((char *) pathName)[sizeof(Qlg_Path_Name_T)]), dllPath, pathName->Path_Length);
- pathName->Path_Name_Delimiter[0] = '/';
-
- Qp0lCvtPathToQSYSObjName(pathName,&qsys_info,"QSYS0100",sizeof(Qp0l_QSYS_Info_t), 0, &err);
-
- if (err.Bytes_Available)
- {
- dlErrorMessage = "Path to shared library not valid.";
- return NULL;
- }
-
- // blank pad object name and library in order to use on rslvsp().
-
- sprintf(objectName, "%-10.10s", qsys_info.Obj_Name);
- sprintf(objectLibrary,"%-10.10s", qsys_info.Lib_Name);
-
-#pragma exception_handler (LBL_RSLV_EH, 0,_C1_ALL,_C2_MH_ESCAPE |_C2_MH_FUNCTION_CHECK, _CTLA_HANDLE)
-
- // Resolve pointer to DLL.
- objectType = WLI_SRVPGM;
- sysP = rslvsp(objectType,objectName, objectLibrary,_AUTH_EXECUTE);
-
-#pragma disable_handler
-
- // We got a pointer to the DLL. Activate it (i.e. load it).
- actInfoLen = sizeof(activationInfo);
- QleActBndPgm (&sysP,&handle,&activationInfo,&actInfoLen,&err);
- if (err.Bytes_Available)
- {
- dlErrorMessage = "Unable to activate shared library.";
- return NULL;
- }
-
- // Return the dlopen object.
- returnHandle = malloc(sizeof(HMODULE));
- memcpy(returnHandle, &handle, sizeof(HMODULE));
- return returnHandle;
-
- LBL_RSLV_EH:
- dlErrorMessage = "Unable to resolve to shared library.";
- return NULL;
-}
-
-/*
- * dlsym()
- * Obtain the address to symbol from a dlopen() object.
- */
-void * os400_dlsym(void *handle, const char * name)
-{
- void *symbolAddress = NULL;
- int exportType;
-
- Qus_EC_t err = {sizeof(err),0 };
- dlErrorMessage = NULL;
-
-#pragma exception_handler (LBL_RSLV_EH, 0,_C1_ALL,_C2_MH_ESCAPE |_C2_MH_FUNCTION_CHECK, _CTLA_HANDLE)
-
- // Get the function pointer.
- // Export type of 1 means that that the pointer is to a procedure.
-
- QleGetExp ((int *)handle,0,0,(char *)name,&symbolAddress,&exportType,&err);
- if (err.Bytes_Available)
- {
- dlErrorMessage = "Unable to resolve to procedure in shared library.";
- return NULL;
- }
-
- return symbolAddress;
-
-#pragma disable_handler
-
- LBL_RSLV_EH:
- dlErrorMessage = "Unable to resolve to procedure in shared library.";
- return NULL;
-}
-
-
-/*
- * ==========================================
- * dlclose()
- * Close a dlopen() object.
- * ==========================================
- */
-int os400_dlclose(void *handle)
-{
- dlErrorMessage = NULL;
- *(int *)handle = -1;
- free(handle);
- return 0;
-}
-
-/*
- * ==========================================
- * dlclose()
- * Close a dlopen() object.
- * ==========================================
- */
-char * os400_dlerror()
-{
- char *retError = dlErrorMessage;
- dlErrorMessage = NULL;
- return retError;
-}
-
-/* ---------------------------------------------------------------------------------*/
-/* ---------------------------------------------------------------------------------*/
-/* Below are routines to handle conversion between ascii and ebcdic */
-/* */
-/* The tables below are used to translate single byte data, and should never */
-/* be used to translate data that is not single byte. */
-/* ---------------------------------------------------------------------------------*/
-/* ---------------------------------------------------------------------------------*/
-
-
-/* constToAsc conversion table generated by ebcdic 37 -> ascii 819 */
-const char EBCDICtoASCII[256] = {
-/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
- 0, 1, 2, 3, 156, 9, 134, 127, 151, 141, 142, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 157, 133, 8, 135, 24, 25, 146, 143, 28, 29, 30, 31,
- 128, 129, 130, 131, 132, 10, 23, 27, 136, 137, 138, 139, 140, 5, 6, 7,
- 144, 145, 22, 147, 148, 149, 150, 4, 152, 153, 154, 155, 20, 21, 158, 26,
- 32, 160, 226, 228, 224, 225, 227, 229, 231, 241, 162, 46, 60, 40, 43, 124,
- 38, 233, 234, 235, 232, 237, 238, 239, 236, 223, 33, 36, 42, 41, 59, 172,
- 45, 47, 194, 196, 192, 193, 195, 197, 199, 209, 166, 44, 37, 95, 62, 63,
- 248, 201, 202, 203, 200, 205, 206, 207, 204, 96, 58, 35, 64, 39, 61, 34,
- 216, 97, 98, 99, 100, 101, 102, 103, 104, 105, 171, 187, 240, 253, 254, 177,
- 176, 106, 107, 108, 109, 110, 111, 112, 113, 114, 170, 186, 230, 184, 198, 164,
- 181, 126, 115, 116, 117, 118, 119, 120, 121, 122, 161, 191, 208, 221, 222, 174,
- 94, 163, 165, 183, 169, 167, 182, 188, 189, 190, 91, 93, 175, 168, 180, 215,
- 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, 173, 244, 246, 242, 243, 245,
- 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, 185, 251, 252, 249, 250, 255,
- 92, 247, 83, 84, 85, 86, 87, 88, 89, 90, 178, 212, 214, 210, 211, 213,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 179, 219, 220, 217, 218, 159
-};
-
-/* ascToString conversion table generated by ascii 819 -> ebcdic 37 */
-const char ASCIItoEBCDIC[256] = {
-/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
- 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31,
- 64, 90, 127, 123, 91, 108, 80, 125, 77, 93, 92, 78, 107, 96, 75, 97,
- 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 122, 94, 76, 126, 110, 111,
- 124, 193, 194, 195, 196, 197, 198, 199, 200, 201, 209, 210, 211, 212, 213, 214,
- 215, 216, 217, 226, 227, 228, 229, 230, 231, 232, 233, 186, 224, 187, 176, 109,
- 121, 129, 130, 131, 132, 133, 134, 135, 136, 137, 145, 146, 147, 148, 149, 150,
- 151, 152, 153, 162, 163, 164, 165, 166, 167, 168, 169, 192, 79, 208, 161, 7,
- 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27,
- 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62, 255,
- 65, 170, 74, 177, 159, 178, 106, 181, 189, 180, 154, 138, 95, 202, 175, 188,
- 144, 143, 234, 250, 190, 160, 182, 179, 157, 218, 155, 139, 183, 184, 185, 171,
- 100, 101, 98, 102, 99, 103, 158, 104, 116, 113, 114, 115, 120, 117, 118, 119,
- 172, 105, 237, 238, 235, 239, 236, 191, 128, 253, 254, 251, 252, 173, 174, 89,
- 68, 69, 66, 70, 67, 71, 156, 72, 84, 81, 82, 83, 88, 85, 86, 87,
- 140, 73, 205, 206, 203, 207, 204, 225, 112, 221, 222, 219, 220, 141, 142, 223
-};
-
-
-/* converts an existing non constant character buffer from Ebcdic ( 37 ) */
-/* to Ascii ( 819 ). */
-char* strtoasc( char *string )
-{
- char* pch = string;
- if( string == NULL ) return NULL;
-
- /* while not EOL... */
- while( *pch != (char)0 )
- {
- *pch = EBCDICtoASCII[*pch];
- pch++;
- }
- return string;
-}
-char* buftoasc( char *b, int len )
-{
- char* pch = b;
- if( b == NULL ) return NULL;
-
- /* while not EOL... */
- while( len > 0 )
- {
- *pch = EBCDICtoASCII[*pch];
- pch++;len--;
- }
- return b;
-}
-
-/* converts an existing non-constant character buffer from ASCII ( 819 ) */
-/* to EBCDIC ( 37 ). */
-char* asctostr( char *string )
-{
- char* pch = string;
- if( string == NULL ) return NULL;
-
- /* while not EOL... */
- while( *pch != (char)0 )
- {
- *pch = ASCIItoEBCDIC[*pch];
- pch++;
- }
- return string;
-}
-char* asctobuf( char *b, int len )
-{
- char* pch = b;
- if( b == NULL ) return NULL;
-
- /* while not EOL... */
- while( len > 0 )
- {
- *pch = ASCIItoEBCDIC[*pch];
- pch++;len--;
- }
- return b;
-}
-
-
-char PLATFORM_DOUBLE_QUOTE_S[] = "\"";
-char PLATFORM_DOUBLE_QUOTE_C = '\"';
-char PLATFORM_XML_ENTITY_REFERENCE_CHARS_S[] = "<>&\"\'";
-
-static int initializePlatform(void)
-{
- char *language= "En_US";
- char langID[3] = {'E' , 'N' , 'U'};
- int jobCCSID = 37;
-
- int rc = retrieveJobCcsid(&jobCCSID, langID);
- if (rc == 0)
- {
- // double quote character is not invariant when running
- // turkish ccsid (1026). That is, the hexadecimal value
- // of double quote is different than when running in
- // any other language. So use correct double quote character.
- if (jobCCSID == 1026)
- {
- strcpy(PLATFORM_DOUBLE_QUOTE_S, "\xFC");
- PLATFORM_DOUBLE_QUOTE_C = '\xFC';
- strcpy(PLATFORM_XML_ENTITY_REFERENCE_CHARS_S, "<>&\xFC\'");
- }
- }
-
- return rc;
-}
-
-// TODO-AMRA static int platformRc = initializePlatform();
-
-
+/*
+ * Copyright 2004-2004 The Apache Software Foundation.
+// (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved
+ *
+ * Licensed 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.
+ */
+
+
+#include "platforms/axutil_platform_auto_sense.h"
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <qusec.h> // Qus_EC_t
+#include <mih/rslvsp.h> // rslvsp()
+#include <mih/micommon.h> // _AUTH_EXECUTE
+#include <qleawi.h> // QleActBndPgm(), QleGetExp()
+#include <qp0lstdi.h> // Qp0lCvtPathToQSYSObjName()
+#include <unistd.h> // readlink()
+#include <except.h>
+#include <errno.h>
+#include <qwcrtvca.h> // Retrieve job's ccsid API prototype
+
+
+
+/**********************************************************************/
+/* Function: */
+/* retrieveJobCcsid */
+/* Description: */
+/* Retrieves the ccsid of the current job. */
+/* If the current job's ccsid is 65535, the job's default ccsid is */
+/* returned. */
+/* If the ccsid cannot be retrieved (error occurs), -1 is returned. */
+/* Return: */
+/* int status of call. if 0, success; -1 failure. */
+/**********************************************************************/
+
+#define RTV_CCSID_ATTR_LEN 512
+
+static int retrieveJobCcsid(int *ccsid, char *langID)
+{
+ char receiverVariable[RTV_CCSID_ATTR_LEN];
+ char format[8] = {'R', 'T', 'V', 'C', '0', '1', '0', '0'};
+ int numberOfAttributes = 3;
+ int attributeKeys[3] = {QWCA_KEY_CCSID, QWCA_KEY_DEFAULTCCSID, QWCA_KEY_LANGID};
+ Qwc_RTVC_Attribute_Data_t *attribute;
+ int defaultCcsid;
+ char errorCode[8];
+ int i;
+ memset(errorCode, 0x00, sizeof(errorCode));
+
+#pragma exception_handler(RetrieveJobCcsidError,0,_C1_ALL,_C2_ALL,_CTLA_HANDLE)
+ QWCRTVCA(receiverVariable,RTV_CCSID_ATTR_LEN,format,numberOfAttributes,attributeKeys,&errorCode);
+#pragma disable_handler
+ if (((Qwc_RTVC0100_t *)receiverVariable)->Number_Fields_Rtnd != 3)
+ {
+ /* Unable to retrieve the ccsid information */
+ return -1;
+ }
+ /* Retrieved ccsid, default CCSID and language ID */
+ attribute = (Qwc_RTVC_Attribute_Data_t *)(receiverVariable + sizeof(int));
+ for (i=0; i < 3; i++)
+ {
+ if (attribute->Key_Field == QWCA_KEY_CCSID)
+ *ccsid = *(int *)((char *)attribute + sizeof(Qwc_RTVC_Attribute_Data_t));
+ else if (attribute->Key_Field == QWCA_KEY_DEFAULTCCSID)
+ defaultCcsid = *(int *)((char *)attribute + sizeof(Qwc_RTVC_Attribute_Data_t));
+ else
+ strncpy(langID, ((char *)attribute + sizeof(Qwc_RTVC_Attribute_Data_t)), 3);
+ attribute = (Qwc_RTVC_Attribute_Data_t *)((char *)attribute + attribute->Length_Field_Info_Rtnd);
+ }
+ if (*ccsid == 65535)
+ *ccsid = defaultCcsid;
+
+ return 0;
+
+ RetrieveJobCcsidError:
+ return -1;
+}
+
+
+typedef int HMODULE;
+
+static char *dlErrorMessage = NULL;
+
+/*
+ * ==========================================
+ * dlopen()
+ * Gain access to an executable object file.
+ * ==========================================
+ */
+void * os400_dlopen(const char *file)
+{
+ Qus_EC_t err = { sizeof(err), 0};
+ int rc;
+ char dllPath[4*1024+1];
+ char *fp;
+ char pathNameBuffer[8*1024];
+ Qlg_Path_Name_T *pathName;
+ Qp0l_QSYS_Info_t qsys_info;
+ char objectName[11];
+ char objectLibrary[11];
+ _SYSPTR sysP;
+ _OBJ_TYPE_T objectType;
+ HMODULE handle;
+ int actInfoLen;
+ Qle_ABP_Info_t activationInfo;
+ void *returnHandle;
+
+ dlErrorMessage = NULL;
+
+ // Assume symbolic link, if error, assume actual path
+
+ memset(dllPath, 0x00, 4*1024+1);
+ rc = readlink ( file , dllPath, 4*1024);
+ if (rc == -1)
+ strcpy(dllPath, file);
+
+ // Uppercase file
+ fp = dllPath;
+ while (*fp++) *fp = toupper(*fp);
+
+ // Parse the path to its QSYS.LIB file system name: library and service program.
+
+ pathName = (Qlg_Path_Name_T *)pathNameBuffer;
+
+ memset(pathNameBuffer, 0x00, sizeof (pathNameBuffer));
+ pathName->Path_Length = strlen(dllPath);
+ memcpy( &(((char *) pathName)[sizeof(Qlg_Path_Name_T)]), dllPath, pathName->Path_Length);
+ pathName->Path_Name_Delimiter[0] = '/';
+
+ Qp0lCvtPathToQSYSObjName(pathName,&qsys_info,"QSYS0100",sizeof(Qp0l_QSYS_Info_t), 0, &err);
+
+ if (err.Bytes_Available)
+ {
+ dlErrorMessage = "Path to shared library not valid.";
+ return NULL;
+ }
+
+ // blank pad object name and library in order to use on rslvsp().
+
+ sprintf(objectName, "%-10.10s", qsys_info.Obj_Name);
+ sprintf(objectLibrary,"%-10.10s", qsys_info.Lib_Name);
+
+#pragma exception_handler (LBL_RSLV_EH, 0,_C1_ALL,_C2_MH_ESCAPE |_C2_MH_FUNCTION_CHECK, _CTLA_HANDLE)
+
+ // Resolve pointer to DLL.
+ objectType = WLI_SRVPGM;
+ sysP = rslvsp(objectType,objectName, objectLibrary,_AUTH_EXECUTE);
+
+#pragma disable_handler
+
+ // We got a pointer to the DLL. Activate it (i.e. load it).
+ actInfoLen = sizeof(activationInfo);
+ QleActBndPgm (&sysP,&handle,&activationInfo,&actInfoLen,&err);
+ if (err.Bytes_Available)
+ {
+ dlErrorMessage = "Unable to activate shared library.";
+ return NULL;
+ }
+
+ // Return the dlopen object.
+ returnHandle = malloc(sizeof(HMODULE));
+ memcpy(returnHandle, &handle, sizeof(HMODULE));
+ return returnHandle;
+
+ LBL_RSLV_EH:
+ dlErrorMessage = "Unable to resolve to shared library.";
+ return NULL;
+}
+
+/*
+ * dlsym()
+ * Obtain the address to symbol from a dlopen() object.
+ */
+void * os400_dlsym(void *handle, const char * name)
+{
+ void *symbolAddress = NULL;
+ int exportType;
+
+ Qus_EC_t err = {sizeof(err),0 };
+ dlErrorMessage = NULL;
+
+#pragma exception_handler (LBL_RSLV_EH, 0,_C1_ALL,_C2_MH_ESCAPE |_C2_MH_FUNCTION_CHECK, _CTLA_HANDLE)
+
+ // Get the function pointer.
+ // Export type of 1 means that that the pointer is to a procedure.
+
+ QleGetExp ((int *)handle,0,0,(char *)name,&symbolAddress,&exportType,&err);
+ if (err.Bytes_Available)
+ {
+ dlErrorMessage = "Unable to resolve to procedure in shared library.";
+ return NULL;
+ }
+
+ return symbolAddress;
+
+#pragma disable_handler
+
+ LBL_RSLV_EH:
+ dlErrorMessage = "Unable to resolve to procedure in shared library.";
+ return NULL;
+}
+
+
+/*
+ * ==========================================
+ * dlclose()
+ * Close a dlopen() object.
+ * ==========================================
+ */
+int os400_dlclose(void *handle)
+{
+ dlErrorMessage = NULL;
+ *(int *)handle = -1;
+ free(handle);
+ return 0;
+}
+
+/*
+ * ==========================================
+ * dlclose()
+ * Close a dlopen() object.
+ * ==========================================
+ */
+char * os400_dlerror()
+{
+ char *retError = dlErrorMessage;
+ dlErrorMessage = NULL;
+ return retError;
+}
+
+/* ---------------------------------------------------------------------------------*/
+/* ---------------------------------------------------------------------------------*/
+/* Below are routines to handle conversion between ascii and ebcdic */
+/* */
+/* The tables below are used to translate single byte data, and should never */
+/* be used to translate data that is not single byte. */
+/* ---------------------------------------------------------------------------------*/
+/* ---------------------------------------------------------------------------------*/
+
+
+/* constToAsc conversion table generated by ebcdic 37 -> ascii 819 */
+const char EBCDICtoASCII[256] = {
+/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
+ 0, 1, 2, 3, 156, 9, 134, 127, 151, 141, 142, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 157, 133, 8, 135, 24, 25, 146, 143, 28, 29, 30, 31,
+ 128, 129, 130, 131, 132, 10, 23, 27, 136, 137, 138, 139, 140, 5, 6, 7,
+ 144, 145, 22, 147, 148, 149, 150, 4, 152, 153, 154, 155, 20, 21, 158, 26,
+ 32, 160, 226, 228, 224, 225, 227, 229, 231, 241, 162, 46, 60, 40, 43, 124,
+ 38, 233, 234, 235, 232, 237, 238, 239, 236, 223, 33, 36, 42, 41, 59, 172,
+ 45, 47, 194, 196, 192, 193, 195, 197, 199, 209, 166, 44, 37, 95, 62, 63,
+ 248, 201, 202, 203, 200, 205, 206, 207, 204, 96, 58, 35, 64, 39, 61, 34,
+ 216, 97, 98, 99, 100, 101, 102, 103, 104, 105, 171, 187, 240, 253, 254, 177,
+ 176, 106, 107, 108, 109, 110, 111, 112, 113, 114, 170, 186, 230, 184, 198, 164,
+ 181, 126, 115, 116, 117, 118, 119, 120, 121, 122, 161, 191, 208, 221, 222, 174,
+ 94, 163, 165, 183, 169, 167, 182, 188, 189, 190, 91, 93, 175, 168, 180, 215,
+ 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, 173, 244, 246, 242, 243, 245,
+ 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, 185, 251, 252, 249, 250, 255,
+ 92, 247, 83, 84, 85, 86, 87, 88, 89, 90, 178, 212, 214, 210, 211, 213,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 179, 219, 220, 217, 218, 159
+};
+
+/* ascToString conversion table generated by ascii 819 -> ebcdic 37 */
+const char ASCIItoEBCDIC[256] = {
+/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
+ 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31,
+ 64, 90, 127, 123, 91, 108, 80, 125, 77, 93, 92, 78, 107, 96, 75, 97,
+ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 122, 94, 76, 126, 110, 111,
+ 124, 193, 194, 195, 196, 197, 198, 199, 200, 201, 209, 210, 211, 212, 213, 214,
+ 215, 216, 217, 226, 227, 228, 229, 230, 231, 232, 233, 186, 224, 187, 176, 109,
+ 121, 129, 130, 131, 132, 133, 134, 135, 136, 137, 145, 146, 147, 148, 149, 150,
+ 151, 152, 153, 162, 163, 164, 165, 166, 167, 168, 169, 192, 79, 208, 161, 7,
+ 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27,
+ 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62, 255,
+ 65, 170, 74, 177, 159, 178, 106, 181, 189, 180, 154, 138, 95, 202, 175, 188,
+ 144, 143, 234, 250, 190, 160, 182, 179, 157, 218, 155, 139, 183, 184, 185, 171,
+ 100, 101, 98, 102, 99, 103, 158, 104, 116, 113, 114, 115, 120, 117, 118, 119,
+ 172, 105, 237, 238, 235, 239, 236, 191, 128, 253, 254, 251, 252, 173, 174, 89,
+ 68, 69, 66, 70, 67, 71, 156, 72, 84, 81, 82, 83, 88, 85, 86, 87,
+ 140, 73, 205, 206, 203, 207, 204, 225, 112, 221, 222, 219, 220, 141, 142, 223
+};
+
+
+/* converts an existing non constant character buffer from Ebcdic ( 37 ) */
+/* to Ascii ( 819 ). */
+char* strtoasc( char *string )
+{
+ char* pch = string;
+ if( string == NULL ) return NULL;
+
+ /* while not EOL... */
+ while( *pch != (char)0 )
+ {
+ *pch = EBCDICtoASCII[*pch];
+ pch++;
+ }
+ return string;
+}
+char* buftoasc( char *b, int len )
+{
+ char* pch = b;
+ if( b == NULL ) return NULL;
+
+ /* while not EOL... */
+ while( len > 0 )
+ {
+ *pch = EBCDICtoASCII[*pch];
+ pch++;len--;
+ }
+ return b;
+}
+
+/* converts an existing non-constant character buffer from ASCII ( 819 ) */
+/* to EBCDIC ( 37 ). */
+char* asctostr( char *string )
+{
+ char* pch = string;
+ if( string == NULL ) return NULL;
+
+ /* while not EOL... */
+ while( *pch != (char)0 )
+ {
+ *pch = ASCIItoEBCDIC[*pch];
+ pch++;
+ }
+ return string;
+}
+char* asctobuf( char *b, int len )
+{
+ char* pch = b;
+ if( b == NULL ) return NULL;
+
+ /* while not EOL... */
+ while( len > 0 )
+ {
+ *pch = ASCIItoEBCDIC[*pch];
+ pch++;len--;
+ }
+ return b;
+}
+
+
+char PLATFORM_DOUBLE_QUOTE_S[] = "\"";
+char PLATFORM_DOUBLE_QUOTE_C = '\"';
+char PLATFORM_XML_ENTITY_REFERENCE_CHARS_S[] = "<>&\"\'";
+
+static int initializePlatform(void)
+{
+ char *language= "En_US";
+ char langID[3] = {'E' , 'N' , 'U'};
+ int jobCCSID = 37;
+
+ int rc = retrieveJobCcsid(&jobCCSID, langID);
+ if (rc == 0)
+ {
+ // double quote character is not invariant when running
+ // turkish ccsid (1026). That is, the hexadecimal value
+ // of double quote is different than when running in
+ // any other language. So use correct double quote character.
+ if (jobCCSID == 1026)
+ {
+ strcpy(PLATFORM_DOUBLE_QUOTE_S, "\xFC");
+ PLATFORM_DOUBLE_QUOTE_C = '\xFC';
+ strcpy(PLATFORM_XML_ENTITY_REFERENCE_CHARS_S, "<>&\xFC\'");
+ }
+ }
+
+ return rc;
+}
+
+// TODO-AMRA static int platformRc = initializePlatform();
+
+
int
os400_alphasort(
const struct dirent **__d1,
diff --git a/util/src/platforms/windows/axutil_windows.c b/util/src/platforms/windows/axutil_windows.c
index e2abb5d..5e37abb 100644
--- a/util/src/platforms/windows/axutil_windows.c
+++ b/util/src/platforms/windows/axutil_windows.c
@@ -1,93 +1,93 @@
-/*
- * 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.
- */
-
-#include <windows/axutil_windows.h>
-#include <stdio.h>
-
-
-/*
-
-std::string* getPlatformErrorMessage(long errorNumber)
-{
- std::string* returningString = new std::string();
- LPVOID lpMsgBuf;
-
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- errorNumber,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR) &lpMsgBuf,
- 0, NULL );
-
- returningString->append((LPTSTR)lpMsgBuf);
- LocalFree(lpMsgBuf);
-
- return returningString;
-}
- */
-AXIS2_EXTERN HMODULE AXIS2_CALL
-callLoadLib(
- char *lib)
-{
- /* Disable display of the critical-error-handler message box */
- SetErrorMode(SEM_FAILCRITICALERRORS);
- return LoadLibraryEx(lib, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
-}
-
-AXIS2_EXTERN struct tm *AXIS2_CALL
-axis2_win_gmtime(
- const time_t * timep,
- struct tm *result)
-{
- return gmtime(timep);
-}
-
-AXIS2_EXTERN void AXIS2_CALL
-axutil_win32_get_last_error(
- axis2_char_t *buf,
- unsigned int buf_size)
-{
- LPVOID lpMsgBuf;
- int rc = GetLastError();
- sprintf(buf, "DLL Load Error %d: ", rc);
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, rc, 0,
- (LPTSTR) & lpMsgBuf, 0, NULL);
- if(lpMsgBuf)
- {
- strncat(buf, (char*)lpMsgBuf, buf_size - strlen(buf) - 1);
- }
- LocalFree(lpMsgBuf);
-}
-
-AXIS2_EXTERN void AXIS2_CALL
-axutil_win32_get_last_wsa_error(
- axis2_char_t *buf,
- unsigned int buf_size)
-{
- LPVOID lpMsgBuf;
- int rc = WSAGetLastError();
- sprintf(buf, "Winsock error %d: ", rc);
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, rc, 0,
- (LPTSTR) & lpMsgBuf, 0, NULL);
- if(lpMsgBuf)
- {
- strncat(buf, (char*)lpMsgBuf, buf_size - strlen(buf) - 1);
- }
- LocalFree(lpMsgBuf);
-}
+/*
+ * 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.
+ */
+
+#include <windows/axutil_windows.h>
+#include <stdio.h>
+
+
+/*
+
+std::string* getPlatformErrorMessage(long errorNumber)
+{
+ std::string* returningString = new std::string();
+ LPVOID lpMsgBuf;
+
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ errorNumber,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR) &lpMsgBuf,
+ 0, NULL );
+
+ returningString->append((LPTSTR)lpMsgBuf);
+ LocalFree(lpMsgBuf);
+
+ return returningString;
+}
+ */
+AXIS2_EXTERN HMODULE AXIS2_CALL
+callLoadLib(
+ char *lib)
+{
+ /* Disable display of the critical-error-handler message box */
+ SetErrorMode(SEM_FAILCRITICALERRORS);
+ return LoadLibraryEx(lib, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+}
+
+AXIS2_EXTERN struct tm *AXIS2_CALL
+axis2_win_gmtime(
+ const time_t * timep,
+ struct tm *result)
+{
+ return gmtime(timep);
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axutil_win32_get_last_error(
+ axis2_char_t *buf,
+ unsigned int buf_size)
+{
+ LPVOID lpMsgBuf;
+ int rc = GetLastError();
+ sprintf(buf, "DLL Load Error %d: ", rc);
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, rc, 0,
+ (LPTSTR) & lpMsgBuf, 0, NULL);
+ if(lpMsgBuf)
+ {
+ strncat(buf, (char*)lpMsgBuf, buf_size - strlen(buf) - 1);
+ }
+ LocalFree(lpMsgBuf);
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axutil_win32_get_last_wsa_error(
+ axis2_char_t *buf,
+ unsigned int buf_size)
+{
+ LPVOID lpMsgBuf;
+ int rc = WSAGetLastError();
+ sprintf(buf, "Winsock error %d: ", rc);
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, rc, 0,
+ (LPTSTR) & lpMsgBuf, 0, NULL);
+ if(lpMsgBuf)
+ {
+ strncat(buf, (char*)lpMsgBuf, buf_size - strlen(buf) - 1);
+ }
+ LocalFree(lpMsgBuf);
+}