Author: damitha
Date: Sat Sep  9 20:47:05 2006
New Revision: 441896

URL: http://svn.apache.org/viewvc?view=rev&rev=441896
Log:
new server samples

Added:
    webservices/sandesha/trunk/c/samples/server/rm_ping/
    webservices/sandesha/trunk/c/samples/server/rm_ping/Makefile.am
    webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping.c
    webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping.h
    webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping_skeleton.c
    webservices/sandesha/trunk/c/samples/server/rm_ping/services.xml

Added: webservices/sandesha/trunk/c/samples/server/rm_ping/Makefile.am
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/server/rm_ping/Makefile.am?view=auto&rev=441896
==============================================================================
--- webservices/sandesha/trunk/c/samples/server/rm_ping/Makefile.am (added)
+++ webservices/sandesha/trunk/c/samples/server/rm_ping/Makefile.am Sat Sep  9 
20:47:05 2006
@@ -0,0 +1,13 @@
+prglibdir=$(prefix)/services/rm_ping
+samplesdir=$(prefix)/samples/server/rm_ping
+prglib_LTLIBRARIES = librm_ping.la
+samples_DATA=rm_ping.c rm_ping_skeleton.c rm_ping.h services.xml Makefile.am 
Makefile.in
+prglib_DATA= services.xml
+EXTRA_DIST = services.xml
+noinst_HEADERS = rm_ping.h
+SUBDIRS =
+librm_ping_la_SOURCES = rm_ping.c rm_ping_skeleton.c
+librm_ping_la_LIBADD  =
+INCLUDES = -I$(AXIS2C_HOME)/include \
+                       @UTILINC@ \
+                       @AXIOMINC@

Added: webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping.c?view=auto&rev=441896
==============================================================================
--- webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping.c (added)
+++ webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping.c Sat Sep  9 
20:47:05 2006
@@ -0,0 +1,64 @@
+/*
+ * 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 "rm_ping.h"
+#include <stdio.h>
+
+void
+axis2_rm_ping_ping (const axis2_env_t *env, axiom_node_t *node)
+{
+    axiom_node_t *text_node = NULL;
+
+    if (!env || !env)
+        return;
+   
+    /* Expected request format is :-
+       <m:ping xmlns:m="http://example.org/ping";>Message 3</m:ping>
+     */
+    if (!node) /* 'ping' node */
+    {
+        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL, 
AXIS2_FAILURE);
+        printf("Echo client ERROR: input parameter NULL\n");
+        return;
+    }
+
+    text_node = AXIOM_NODE_GET_FIRST_CHILD(node, env);
+    if (!node) /* actual text to ping */
+    {
+        AXIS2_ERROR_SET(env->error, 
AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, AXIS2_FAILURE);
+        printf("Echo client ERROR: invalid XML in request\n");
+        return;
+    }
+    
+    if (AXIOM_NODE_GET_NODE_TYPE(text_node, env) == AXIOM_TEXT)
+    {
+        axiom_text_t *text = (axiom_text_t 
*)AXIOM_NODE_GET_DATA_ELEMENT(text_node, env);
+        if( text && AXIOM_TEXT_GET_VALUE(text , env))
+        {
+            axis2_char_t *text_str = AXIOM_TEXT_GET_VALUE(text, env);
+            printf("Notification received :  %s \n", text_str);
+        }
+    }
+    else
+    {
+        AXIS2_ERROR_SET(env->error, 
AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST, AXIS2_FAILURE);
+        printf("Echo client ERROR: invalid XML in request\n");
+        return;
+    }
+   
+    return;
+}
+
+

Added: webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping.h
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping.h?view=auto&rev=441896
==============================================================================
--- webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping.h (added)
+++ webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping.h Sat Sep  9 
20:47:05 2006
@@ -0,0 +1,29 @@
+/*
+ * 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 CALC_H
+#define CALC_H
+
+
+#include <axis2_svc_skeleton.h>
+#include <axis2_log_default.h>
+#include <axis2_error_default.h>
+#include <axiom_text.h>
+#include <axiom_node.h>
+#include <axiom_element.h>
+
+void axis2_rm_ping_notify(const axis2_env_t *env, axiom_node_t *node);
+
+#endif /* CALC_H*/

Added: webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping_skeleton.c
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping_skeleton.c?view=auto&rev=441896
==============================================================================
--- webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping_skeleton.c 
(added)
+++ webservices/sandesha/trunk/c/samples/server/rm_ping/rm_ping_skeleton.c Sat 
Sep  9 20:47:05 2006
@@ -0,0 +1,177 @@
+/*
+ * 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_svc_skeleton.h"
+#include "rm_ping.h"
+#include <axis2_array_list.h>
+
+int AXIS2_CALL
+rm_ping_free(axis2_svc_skeleton_t *svc_skeleton,
+            const axis2_env_t *env);
+
+axis2_status_t AXIS2_CALL
+rm_ping_free_void_arg(void *svc_skeleton,
+                    const axis2_env_t *env);
+
+/*
+ * This method invokes the right service method 
+ */
+axiom_node_t* AXIS2_CALL 
+rm_ping_invoke(axis2_svc_skeleton_t *svc_skeleton,
+            const axis2_env_t *env,
+            axiom_node_t *node,
+            axis2_msg_ctx_t *msg_ctx);
+            
+
+int AXIS2_CALL 
+rm_ping_init(axis2_svc_skeleton_t *svc_skeleton,
+          const axis2_env_t *env);
+
+axiom_node_t* AXIS2_CALL
+rm_ping_on_fault(axis2_svc_skeleton_t *svc_skeli, 
+              const axis2_env_t *env, axiom_node_t *node);
+
+/*Create function */
+axis2_svc_skeleton_t *
+axis2_rm_ping_create(const axis2_env_t *env)
+{
+    axis2_svc_skeleton_t *svc_skeleton = NULL;
+    /* Allocate memory for the structs */
+    svc_skeleton = AXIS2_MALLOC(env->allocator, 
+        sizeof(axis2_svc_skeleton_t));
+
+    svc_skeleton->ops = AXIS2_MALLOC(
+        env->allocator, sizeof(axis2_svc_skeleton_ops_t));
+
+    svc_skeleton->func_array = NULL;
+
+    /* Assign function pointers */
+    svc_skeleton->ops->free = rm_ping_free;
+    svc_skeleton->ops->init = rm_ping_init;
+    svc_skeleton->ops->invoke = rm_ping_invoke;
+    svc_skeleton->ops->on_fault = rm_ping_on_fault;
+
+    return svc_skeleton;
+}
+
+/* Initialize the service */
+int AXIS2_CALL
+rm_ping_init(axis2_svc_skeleton_t *svc_skeleton,
+                        const axis2_env_t *env)
+{
+    svc_skeleton->func_array = axis2_array_list_create(env, 0);
+    /* Add the implemented operation names of the service to  
+     * the array list of functions 
+     */
+    AXIS2_ARRAY_LIST_ADD(svc_skeleton->func_array, env, "ping");
+    /* Any initialization stuff of ping service should go here */
+    return AXIS2_SUCCESS;
+}
+
+/*
+ * This method invokes the right service method 
+ */
+axiom_node_t* AXIS2_CALL
+rm_ping_invoke(axis2_svc_skeleton_t *svc_skeleton,
+            const axis2_env_t *env,
+            axiom_node_t *node,
+            axis2_msg_ctx_t *msg_ctx)
+{
+    /* Invoke the business logic.
+     * Depending on the function name invoke the correct impl method.
+     * We have only ping in this sample, hence invoke ping method.
+     * To see how to deal with multiple impl methods, have a look at the
+     * math sample.
+     */
+    axis2_rm_ping_ping(env, node);
+    return NULL;
+}
+
+/* On fault, handle the fault */
+axiom_node_t* AXIS2_CALL
+rm_ping_on_fault(axis2_svc_skeleton_t *svc_skeli, 
+              const axis2_env_t *env, axiom_node_t *node)
+{
+   /* Here we are just setting a simple error message inside an element 
+    * called 'EchoServiceError' 
+    */
+    axiom_node_t *error_node = NULL;
+    axiom_node_t* text_node = NULL;
+    axiom_element_t *error_ele = NULL;
+    error_ele = axiom_element_create(env, node, "EchoServiceError", NULL, 
+        &error_node);
+    AXIOM_ELEMENT_SET_TEXT(error_ele, env, "Echo service failed ", 
+        text_node);
+    return error_node;
+}
+
+/* Free the resources used */
+int AXIS2_CALL
+rm_ping_free(axis2_svc_skeleton_t *svc_skeleton,
+            const axis2_env_t *env)
+{
+    /* Free the function array */
+    if(svc_skeleton->func_array)
+    {
+        AXIS2_ARRAY_LIST_FREE(svc_skeleton->func_array, env);
+        svc_skeleton->func_array = NULL;
+    }
+    
+    /* Free the function array */
+    if(svc_skeleton->ops)
+    {
+        AXIS2_FREE(env->allocator, svc_skeleton->ops);
+        svc_skeleton->ops = NULL;
+    }
+    
+    /* Free the service skeleton */
+    if(svc_skeleton)
+    {
+        AXIS2_FREE(env->allocator, svc_skeleton);
+        svc_skeleton = NULL;
+    }
+
+    return AXIS2_SUCCESS; 
+}
+
+
+/**
+ * Following block distinguish the exposed part of the dll.
+ */
+AXIS2_EXPORT int 
+axis2_get_instance(axis2_svc_skeleton_t **inst,
+                   const axis2_env_t *env)
+{
+   *inst = axis2_rm_ping_create(env);
+    if(!(*inst))
+    {
+        return AXIS2_FAILURE;
+    }
+
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int 
+axis2_remove_instance(axis2_svc_skeleton_t *inst,
+                      const axis2_env_t *env)
+{
+    axis2_status_t status = AXIS2_FAILURE;
+   if (inst)
+   {
+        status = AXIS2_SVC_SKELETON_FREE(inst, env);
+    }
+    return status;
+}
+

Added: webservices/sandesha/trunk/c/samples/server/rm_ping/services.xml
URL: 
http://svn.apache.org/viewvc/webservices/sandesha/trunk/c/samples/server/rm_ping/services.xml?view=auto&rev=441896
==============================================================================
--- webservices/sandesha/trunk/c/samples/server/rm_ping/services.xml (added)
+++ webservices/sandesha/trunk/c/samples/server/rm_ping/services.xml Sat Sep  9 
20:47:05 2006
@@ -0,0 +1,14 @@
+<service name="rm_ping">
+    <module ref="sandesha2"/>
+    <parameter name="ServiceClass" locked="xsd:false">rm_ping</parameter>
+
+   <description>
+        This is a testing service , to test one way service support
+   </description>
+
+    <operation name="ping">
+            <!--messageReceiver class="axis2_receivers" /-->
+            <parameter name="wsamapping" 
>http://example.org/action/ping</parameter>
+    </operation>
+
+</service>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to