axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject svn commit: r369315 - in /webservices/axis2/trunk/c/modules/core/receivers: Makefile.am msg_recv.c raw_xml_in_out_msg_recv.c
Date Mon, 16 Jan 2006 02:34:35 GMT
Author: damitha
Date: Sun Jan 15 18:34:29 2006
New Revision: 369315

URL: http://svn.apache.org/viewcvs?rev=369315&view=rev
Log:
Added raw_xml_in_out_msg_recv.c

Added:
    webservices/axis2/trunk/c/modules/core/receivers/raw_xml_in_out_msg_recv.c
Modified:
    webservices/axis2/trunk/c/modules/core/receivers/Makefile.am
    webservices/axis2/trunk/c/modules/core/receivers/msg_recv.c

Modified: webservices/axis2/trunk/c/modules/core/receivers/Makefile.am
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/receivers/Makefile.am?rev=369315&r1=369314&r2=369315&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/receivers/Makefile.am (original)
+++ webservices/axis2/trunk/c/modules/core/receivers/Makefile.am Sun Jan 15 18:34:29 2006
@@ -1,12 +1,15 @@
 lib_LTLIBRARIES = libaxis2_receivers.la
 AM_CPPFLAGS = $(CPPFLAGS)
 
-libaxis2_receivers_la_SOURCES = msg_recv.c
+libaxis2_receivers_la_SOURCES = msg_recv.c \
+                                raw_xml_in_out_msg_recv.c
 
 libaxis2_receivers_la_LIBADD = 
 INCLUDES = -I$(top_builddir)/include \
             -I$(top_builddir)/modules/util \
-            -I$(top_builddir)/modules/core/description \
             -I$(top_builddir)/modules/wsdl \
+            -I$(top_builddir)/modules/core/context \
             -I$(top_builddir)/modules/core/transport \
+            -I$(top_builddir)/modules/core/description \
+            -I$(top_builddir)/modules/xml/parser \
             -I$(top_builddir)/modules/platforms

Modified: webservices/axis2/trunk/c/modules/core/receivers/msg_recv.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/receivers/msg_recv.c?rev=369315&r1=369314&r2=369315&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/receivers/msg_recv.c (original)
+++ webservices/axis2/trunk/c/modules/core/receivers/msg_recv.c Sun Jan 15 18:34:29 2006
@@ -7,6 +7,8 @@
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
+ *      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.
@@ -15,6 +17,11 @@
  */
  
 #include <axis2_msg_recv.h>
+#include <axis2_param.h>
+#include <axis2_description.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <axis2_class_loader.h>
 
 /** 
@@ -33,32 +40,20 @@
 
 axis2_status_t AXIS2_CALL
 axis2_msg_recv_free (axis2_msg_recv_t *msg_recv,
-                            axis2_env_t **env);
+                        axis2_env_t **env);
 
 axis2_status_t AXIS2_CALL
 axis2_msg_recv_receive (axis2_msg_recv_t *msg_recv,
-                                axis2_env_t **env,
-		                        struct axis2_msg_ctx *msg_ctx);
-                                
-/**
- * Method makeNewServiceObject
- *
- * @param msgContext
- * @return
- */
+                        axis2_env_t **env,
+                        struct axis2_msg_ctx *in_msg_ctx);
+
 axis2_svc_skeleton_t * AXIS2_CALL
-axis2_msg_recv_make_new_svc_obj(void *msg_recv,
+axis2_msg_recv_make_new_svc_obj(axis2_msg_recv_t *msg_recv,
                                     axis2_env_t **env,
                                     struct axis2_msg_ctx *msg_ctx);
 
-/**
- * Method getTheImplementationObject
- *
- * @param msgContext
- * @return
- */
 axis2_svc_skeleton_t * AXIS2_CALL
-axis2_msg_recv_get_impl_obj(void *msg_recv,
+axis2_msg_recv_get_impl_obj(axis2_msg_recv_t *msg_recv,
                             axis2_env_t **env,
                             struct axis2_msg_ctx *msg_ctx); 
 
@@ -66,7 +61,7 @@
 axis2_msg_recv_set_scope(axis2_msg_recv_t *msg_recv,
                             axis2_env_t **env,
                             axis2_char_t *scope);
-
+                                   
 axis2_char_t * AXIS2_CALL
 axis2_msg_recv_get_scope(axis2_msg_recv_t *msg_recv,
                             axis2_env_t **env);                            
@@ -80,8 +75,7 @@
     
     AXIS2_ENV_CHECK(env, NULL);
     
-	msg_recv_impl = (axis2_msg_recv_impl_t *) AXIS2_MALLOC ((*env)->allocator
-		    , sizeof (axis2_msg_recv_impl_t));
+	msg_recv_impl = (axis2_msg_recv_impl_t *) malloc (sizeof (axis2_msg_recv_impl_t));
     
 	if(NULL == msg_recv_impl)
     {
@@ -89,16 +83,17 @@
         return NULL;
     }
     
-    msg_recv_impl->scope = NULL;
+    /*msg_recv_impl->scope = AXIS2_STRDUP(AXIS2_APPLICATION_SCOPE, env);*/
+    msg_recv_impl->scope = AXIS2_STRDUP("app*", env);;
     msg_recv_impl->msg_recv.ops = NULL;
     
-    msg_recv_impl->msg_recv.ops = (axis2_msg_recv_ops_t *) AXIS2_MALLOC(
-        (*env)->allocator, sizeof(axis2_msg_recv_ops_t));
+    msg_recv_impl->msg_recv.ops = (axis2_msg_recv_ops_t *) malloc(sizeof(axis2_msg_recv_ops_t));
     
 	if(NULL == msg_recv_impl->msg_recv.ops)
 	{
-        axis2_msg_recv_free(&(msg_recv_impl->msg_recv), env);
         AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        axis2_msg_recv_free(&(msg_recv_impl->msg_recv), env);
+        
         return NULL;
 	}
     
@@ -127,38 +122,33 @@
         AXIS2_FREE((*env)->allocator, recv_impl->scope);
         recv_impl->scope = NULL;
     }
-    
+
     if(NULL != msg_recv->ops)
     {
-		AXIS2_FREE((*env)->allocator, msg_recv->ops);
+        AXIS2_FREE((*env)->allocator, msg_recv->ops);
         msg_recv->ops = NULL;
     }
-    
+
     if(recv_impl)
     {
         AXIS2_FREE((*env)->allocator, recv_impl);
         recv_impl = NULL;
     }
-    
+
 	return AXIS2_SUCCESS;
 }
 
 axis2_status_t AXIS2_CALL
 axis2_msg_recv_receive (axis2_msg_recv_t *msg_recv,
-                    axis2_env_t **env,
-		            struct axis2_msg_ctx *msg_ctx)
+                        axis2_env_t **env,
+                        struct axis2_msg_ctx *in_msg_ctx)
 {
 	return AXIS2_SUCCESS;
 }
 
-/**
- * Method makeNewServiceObject
- *
- * @param msgContext
- * @return
- */
+
 axis2_svc_skeleton_t * AXIS2_CALL
-axis2_msg_recv_make_new_svc_obj(void *msg_recv,
+axis2_msg_recv_make_new_svc_obj(axis2_msg_recv_t *msg_recv,
                                     axis2_env_t **env,
                                     struct axis2_msg_ctx *msg_ctx)
 {
@@ -167,10 +157,10 @@
     struct axis2_svc_ctx *svc_ctx = NULL;
     axis2_param_t *impl_info_param = NULL;
     void *impl_class = NULL;
-    
+
     AXIS2_FUNC_PARAM_CHECK(msg_recv, env, NULL);
     AXIS2_PARAM_CHECK((*env)->error, msg_ctx, NULL);
-    
+
     op_ctx = AXIS2_MSG_CTX_GET_OP_CTX(msg_ctx, env);
     svc_ctx = AXIS2_OP_CTX_GET_PARENT(op_ctx, env);
     svc = AXIS2_SVC_CTX_GET_SVC(svc_ctx, env);
@@ -178,30 +168,25 @@
     {
         return NULL;
     }
-    
+
     impl_info_param = AXIS2_SVC_GET_PARAM(svc, env, AXIS2_SERVICE_CLASS);
     if(!impl_info_param)
     {
-        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_INVALID_STATE_SVC, 
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_INVALID_STATE_SVC,
             AXIS2_FAILURE);
         return NULL;
     }
-    
+
     axis2_class_loader_init(env);
-    
+
     impl_class = axis2_class_loader_create_dll(env, impl_info_param);
-    
+
     return impl_class;
 }
 
-/**
- * Method getTheImplementationObject
- *
- * @param msgContext
- * @return
- */
+
 axis2_svc_skeleton_t * AXIS2_CALL
-axis2_msg_recv_get_impl_obj(void *msg_recv,
+axis2_msg_recv_get_impl_obj(axis2_msg_recv_t *msg_recv,
                             axis2_env_t **env,
                             struct axis2_msg_ctx *msg_ctx)
 {
@@ -302,6 +287,5 @@
 axis2_msg_recv_get_scope(axis2_msg_recv_t *msg_recv,
                             axis2_env_t **env)
 {
-    AXIS2_FUNC_PARAM_CHECK(msg_recv, env, NULL);
     return AXIS2_INTF_TO_IMPL(msg_recv)->scope;
 }

Added: webservices/axis2/trunk/c/modules/core/receivers/raw_xml_in_out_msg_recv.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/receivers/raw_xml_in_out_msg_recv.c?rev=369315&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/receivers/raw_xml_in_out_msg_recv.c (added)
+++ webservices/axis2/trunk/c/modules/core/receivers/raw_xml_in_out_msg_recv.c Sun Jan 15
18:34:29 2006
@@ -0,0 +1,305 @@
+/*
+ * 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.
+ */
+ 
+#include <axis2_raw_xml_in_out_msg_recv.h>
+#include <string.h>
+#include <axis2_om_element.h>
+#include <axis2_soap_envelope.h>
+#include <axis2_soap_body.h>
+#include <axis2_core_utils.h>
+#include <axis2_engine.h>
+
+/************************* Function prototypes ********************************/
+
+axis2_status_t AXIS2_CALL
+axis2_raw_xml_in_out_msg_recv_invoke_business_logic(axis2_msg_recv_t *msg_recv,
+                                                    axis2_env_t **env,
+                                                    axis2_msg_ctx_t *msg_ctx,
+                                                    axis2_msg_ctx_t *new_msg_ctx);
+
+axis2_status_t AXIS2_CALL
+axis2_raw_xml_in_out_msg_recv_receive(axis2_msg_recv_t *msg_recv,
+                                    axis2_env_t **env,
+                                    axis2_msg_ctx_t *msg_ctx);
+                                
+/************************** End of function prototypes ************************/
+
+axis2_msg_recv_t *AXIS2_CALL 
+axis2_raw_xml_in_out_msg_recv_create(axis2_env_t **env)
+{
+    axis2_msg_recv_t *msg_recv = NULL;
+    axis2_status_t status = AXIS2_FAILURE;
+    
+	AXIS2_ENV_CHECK(env, NULL);
+	msg_recv = axis2_msg_recv_create(env);
+	if(NULL == msg_recv)
+    {
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); 
+        return NULL;
+    }
+    status = AXIS2_MSG_RECV_SET_SCOPE(msg_recv, env, AXIS2_APPLICATION_SCOPE);
+    if(AXIS2_TRUE != status)
+    {
+        AXIS2_MSG_RECV_FREE(msg_recv, env);
+        return NULL;
+    }
+    msg_recv->ops->invoke_in_out_business_logic = 
+        axis2_raw_xml_in_out_msg_recv_invoke_business_logic;
+    msg_recv->ops->receive = axis2_raw_xml_in_out_msg_recv_receive;
+	return msg_recv;
+}
+
+/***************************Function implementation****************************/
+
+axis2_status_t AXIS2_CALL
+axis2_raw_xml_in_out_msg_recv_invoke_business_logic(axis2_msg_recv_t *msg_recv,
+                                                    axis2_env_t **env,
+                                                    axis2_msg_ctx_t *msg_ctx,
+                                                    axis2_msg_ctx_t *new_msg_ctx)
+{
+    axis2_svc_skeleton_t *svc_obj = NULL;
+    axis2_op_ctx_t *op_ctx = NULL;
+    axis2_op_t *op_desc = NULL;
+    axis2_char_t *style = NULL;
+    axis2_om_node_t *om_node = NULL;
+    axis2_om_element_t *om_element = NULL;
+    axis2_char_t *local_name = NULL;
+    axis2_om_node_t *result_node = NULL;
+    axis2_om_node_t *body_content_node = NULL;
+    axis2_om_element_t *body_content_element = NULL;
+    axis2_soap_envelope_t *default_envelope = NULL;
+    axis2_soap_body_t *out_body = NULL;
+    axis2_om_node_t *out_node = NULL;
+    
+    /* get the implementation class for the Web Service */
+    svc_obj = AXIS2_MSG_RECV_GET_IMPL_OBJ(msg_recv, env, msg_ctx);
+    op_ctx = AXIS2_MSG_CTX_GET_OP_CTX(msg_ctx, env);
+    op_desc = AXIS2_OP_CTX_GET_OP(op_ctx, env);
+    
+    svc_obj = AXIS2_MSG_RECV_GET_IMPL_OBJ(msg_recv, env, msg_ctx);
+    /* find the WebService method */
+    /*Object obj = getTheImplementationObject(msgContext);
+
+    // find the WebService method
+    Class ImplClass = obj.getClass();
+
+    //Inject the Message Context if it is asked for
+    DependencyManager.configureBusinessLogicProvider(obj, msgContext, newmsgContext);
+
+    AxisOperation opDesc = msgContext.getOperationContext()
+            .getAxisOperation();
+    Method method = findOperation(opDesc, ImplClass);
+    if (method != null) {
+        String style = msgContext.getOperationContext()
+                .getAxisOperation()
+                .getStyle();
+
+        Class[] parameters = method.getParameterTypes();
+        Object[] args = null;
+
+        if (parameters == null || parameters.length == 0) {
+            args = new Object[0];
+        } else if (parameters.length == 1) 
+        {
+        */
+    
+    style = AXIS2_OP_GET_STYLE(op_desc, env);
+    if(0 == AXIS2_STRCMP(AXIS2_STYLE_DOC, style))
+    {
+        axis2_soap_envelope_t *envelope = NULL;
+        axis2_soap_body_t *body = NULL;
+        
+        envelope = AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(msg_ctx, env);
+        body = AXIS2_SOAP_ENVELOPE_GET_BODY(envelope, env);
+        om_node = AXIS2_SOAP_BODY_GET_BASE_NODE(body, env);
+        om_element = AXIS2_OM_NODE_GET_DATA_ELEMENT(om_node, env);
+        
+    }
+    else if(0 == AXIS2_STRCMP(AXIS2_STYLE_RPC, style))
+    {
+        axis2_soap_envelope_t *envelope = NULL;
+        axis2_soap_body_t *body = NULL;
+        axis2_om_node_t *op_node = NULL;
+        axis2_om_element_t *op_element = NULL;
+        
+        envelope = AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(msg_ctx, env);
+        body = AXIS2_SOAP_ENVELOPE_GET_BODY(envelope, env);
+        op_node = AXIS2_SOAP_BODY_GET_BASE_NODE(body, env);
+        op_element = AXIS2_OM_NODE_GET_DATA_ELEMENT(op_node, env);
+        if(NULL != op_element)
+        {
+            local_name = AXIS2_OM_ELEMENT_GET_LOCALNAME(op_element, env);
+            if(NULL != local_name)
+            {
+                axis2_array_list_t *function_arr = NULL;
+                int i = 0;
+                int size = 0;
+                axis2_bool_t matches = AXIS2_FALSE;
+                
+                function_arr = svc_obj->func_array;
+                size = AXIS2_ARRAY_LIST_SIZE(function_arr, env);
+                if(AXIS2_TRUE != AXIS2_ERROR_GET_STATUS_CODE((*env)->error))
+                {
+                    return AXIS2_FAILURE;
+                }
+                
+                for (i = 0; i < size; i++) 
+                {
+                    axis2_char_t *function_name = NULL;
+                    
+                    function_name = (axis2_char_t *) AXIS2_ARRAY_LIST_GET(
+                        function_arr, env, i);
+                    if(0 == AXIS2_STRCMP(function_name, local_name))
+                    {
+                        matches = AXIS2_TRUE;
+                        
+                    }
+                }
+                if(AXIS2_TRUE == matches)
+                {
+                    om_node = AXIS2_OM_NODE_GET_FIRST_CHILD(op_node, env);
+                    om_element = AXIS2_OM_NODE_GET_DATA_ELEMENT(om_node, env);   
+                }
+                else
+                {
+                    AXIS2_ERROR_SET((*env)->error, 
+                        AXIS2_ERROR_OM_ELEMENT_MISMATCH, AXIS2_FAILURE);
+                    return AXIS2_FAILURE;
+                }
+            }
+            else
+            {
+                AXIS2_ERROR_SET((*env)->error, 
+                    AXIS2_ERROR_OM_ELEMENT_INVALID_STATE, AXIS2_FAILURE);
+                return AXIS2_FAILURE;
+            }
+        }
+        else
+        {
+            AXIS2_ERROR_SET((*env)->error, 
+                    AXIS2_ERROR_RPC_NEED_MATCHING_CHILD, AXIS2_FAILURE);
+            return AXIS2_FAILURE;
+        }
+    }
+    else
+    {
+        AXIS2_ERROR_SET((*env)->error, 
+                AXIS2_ERROR_UNKNOWN_STYLE, AXIS2_FAILURE);
+        return AXIS2_FAILURE;
+    }
+    result_node = AXIS2_SVC_SKELETON_INVOKE(svc_obj, env, om_node);
+    if(0 == AXIS2_STRCMP(style, AXIS2_STYLE_RPC))
+    {
+        axis2_om_namespace_t *ns = NULL;
+        axis2_char_t *res_name = NULL;
+        
+        default_envelope = axis2_soap_envelope_create_null(env);
+        out_body = AXIS2_SOAP_ENVELOPE_GET_BODY(default_envelope, env);
+        if(!default_envelope)
+        {
+            return AXIS2_FAILURE;
+        }
+        res_name = AXIS2_STRACAT(local_name, "Response", env);
+        ns = axis2_om_namespace_create(env, "http://soapenc/", "res");
+        if(!ns)
+        {
+            return AXIS2_FAILURE;
+        }
+        out_node = AXIS2_SOAP_BODY_GET_BASE_NODE(out_body, env);
+        body_content_element = axis2_om_element_create(env, out_node, res_name, 
+            ns, &body_content_node);
+        
+        AXIS2_OM_NODE_ADD_CHILD(body_content_node, env, result_node);
+        
+    }
+    else
+    {
+        body_content_node = result_node;
+    }
+    return AXIS2_MSG_CTX_SET_SOAP_ENVELOPE(new_msg_ctx, env, default_envelope);
+}
+
+axis2_status_t AXIS2_CALL
+axis2_raw_xml_in_out_msg_recv_receive(axis2_msg_recv_t *msg_recv,
+                                    axis2_env_t **env,
+                                    axis2_msg_ctx_t *msg_ctx)
+{
+    axis2_msg_ctx_t *out_msg_ctx = NULL;
+    axis2_engine_t *engine = NULL;
+    axis2_conf_ctx_t *conf_ctx = NULL;
+    axis2_op_ctx_t *op_ctx = NULL;
+    axis2_svc_ctx_t *svc_ctx = NULL;
+    
+    AXIS2_FUNC_PARAM_CHECK(msg_recv, env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, msg_ctx, AXIS2_FAILURE);
+    
+    out_msg_ctx = axis2_core_utils_create_out_msg_ctx(env, msg_ctx);
+    axis2_raw_xml_in_out_msg_recv_invoke_business_logic(msg_recv, env, msg_ctx,
+        out_msg_ctx);
+    op_ctx = AXIS2_MSG_CTX_GET_OP_CTX(msg_ctx, env);
+    svc_ctx = AXIS2_OP_CTX_GET_PARENT(op_ctx, env);
+    conf_ctx = AXIS2_SVC_CTX_GET_CONF_CTX(svc_ctx, env);
+    engine = axis2_engine_create(env, conf_ctx);
+    if(!engine)
+    {
+        return AXIS2_FAILURE;
+    }        
+    return AXIS2_ENGINE_SEND(engine, env, out_msg_ctx);
+    
+}
+
+/*
+public Method findOperation(AxisOperation op, Class ImplClass) {
+    Method method = null;
+    String methodName = op.getName().getLocalPart();
+    Method[] methods = ImplClass.getMethods();
+    for (int i = 0; i < methods.length; i++) {
+        if (methods[i].getName().equals(methodName)) {
+            method = methods[i];
+            break;
+        }
+    }
+    return method;
+}
+*/
+
+/**
+ * Following block distinguish the exposed part of the dll.
+ */
+
+
+int axis2_get_instance(struct axis2_msg_recv **inst,
+                        axis2_env_t **env)
+{
+    *inst = axis2_raw_xml_in_out_msg_recv_create(env);
+    if(!(*inst))
+    {
+        return AXIS2_FAILURE;
+    }
+
+    return AXIS2_SUCCESS;
+}
+
+int axis2_remove_instance(axis2_svc_skeleton_t *inst,
+                            axis2_env_t **env)
+{
+    axis2_status_t status = AXIS2_FAILURE;
+    if (inst)
+    {
+        status = AXIS2_MSG_RECV_FREE(inst, env);
+    }
+    return status;
+}



Mime
View raw message