summaryrefslogtreecommitdiffstats
path: root/samples/server/notify
diff options
context:
space:
mode:
Diffstat (limited to 'samples/server/notify')
-rw-r--r--samples/server/notify/Makefile.am9
-rw-r--r--samples/server/notify/notify.c77
-rw-r--r--samples/server/notify/notify.h32
-rw-r--r--samples/server/notify/notify.mk8
-rw-r--r--samples/server/notify/notify_skeleton.c167
-rw-r--r--samples/server/notify/services.xml13
6 files changed, 306 insertions, 0 deletions
diff --git a/samples/server/notify/Makefile.am b/samples/server/notify/Makefile.am
new file mode 100644
index 0000000..2e2bf2c
--- /dev/null
+++ b/samples/server/notify/Makefile.am
@@ -0,0 +1,9 @@
+prglibdir=$(prefix)/services/notify
+prglib_LTLIBRARIES = libnotify.la
+prglib_DATA= services.xml
+EXTRA_DIST = services.xml notify.mk notify.h
+noinst_HEADERS = notify.h
+SUBDIRS =
+libnotify_la_SOURCES = notify.c notify_skeleton.c
+libnotify_la_LIBADD =
+INCLUDES = @AXIS2INC@
diff --git a/samples/server/notify/notify.c b/samples/server/notify/notify.c
new file mode 100644
index 0000000..80dc5bd
--- /dev/null
+++ b/samples/server/notify/notify.c
@@ -0,0 +1,77 @@
+
+/*
+ * 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 "notify.h"
+#include <stdio.h>
+
+void
+axis2_notify_notify(
+ const axutil_env_t * env,
+ axiom_node_t * node)
+{
+ axiom_node_t *text_node = NULL;
+
+ if (!env || !env)
+ {
+ return;
+ }
+
+ /* Expected request format is :-
+ <m:notify xmlns:m="http://example.org/notify">Message 3</m:notify>
+ */
+ if (!node) /* 'notify' node */
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SVC_SKEL_INPUT_OM_NODE_NULL,
+ AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Echo client ERROR: input parameter NULL");
+ return;
+ }
+
+ text_node = axiom_node_get_first_child(node, env);
+ if (!text_node) /* actual text to notify */
+ {
+ AXIS2_ERROR_SET(env->error,
+ AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
+ AXIS2_FAILURE);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Echo client ERROR: invalid XML in request");
+ 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 =
+ (axis2_char_t *) axiom_text_get_value(text, env);
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Notification received : %s", text_str);
+ }
+ }
+ else
+ {
+ AXIS2_ERROR_SET(env->error,
+ AXIS2_ERROR_SVC_SKEL_INVALID_XML_FORMAT_IN_REQUEST,
+ AXIS2_FAILURE);
+ printf("\n");
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Echo client ERROR: invalid XML in request");
+ return;
+ }
+
+ return;
+}
+
diff --git a/samples/server/notify/notify.h b/samples/server/notify/notify.h
new file mode 100644
index 0000000..5a175a0
--- /dev/null
+++ b/samples/server/notify/notify.h
@@ -0,0 +1,32 @@
+
+/*
+ * 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 CALC_H
+#define CALC_H
+
+#include <axis2_svc_skeleton.h>
+#include <axutil_log_default.h>
+#include <axutil_error_default.h>
+#include <axiom_text.h>
+#include <axiom_node.h>
+#include <axiom_element.h>
+
+void axis2_notify_notify(
+ const axutil_env_t * env,
+ axiom_node_t * node);
+
+#endif /* CALC_H */
diff --git a/samples/server/notify/notify.mk b/samples/server/notify/notify.mk
new file mode 100644
index 0000000..9f3d533
--- /dev/null
+++ b/samples/server/notify/notify.mk
@@ -0,0 +1,8 @@
+echo:
+ @cl.exe /nologo /D "WIN32" /D "_WINDOWS" /D "_MBCS" *.C /I.\..\..\..\include /c
+ @link.exe /nologo *.obj /LIBPATH:.\..\..\..\lib axiom.lib axutil.lib axis2_engine.lib axis2_parser.lib /DLL /OUT:notify.dll
+
+
+
+
+
diff --git a/samples/server/notify/notify_skeleton.c b/samples/server/notify/notify_skeleton.c
new file mode 100644
index 0000000..82acf49
--- /dev/null
+++ b/samples/server/notify/notify_skeleton.c
@@ -0,0 +1,167 @@
+
+/*
+ * 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_svc_skeleton.h"
+#include "notify.h"
+#include <axutil_array_list.h>
+
+int AXIS2_CALL notify_free(
+ axis2_svc_skeleton_t * svc_skeleton,
+ const axutil_env_t * env);
+
+/*
+ * This method invokes the right service method
+ */
+axiom_node_t *AXIS2_CALL notify_invoke(
+ axis2_svc_skeleton_t * svc_skeleton,
+ const axutil_env_t * env,
+ axiom_node_t * node,
+ axis2_msg_ctx_t * msg_ctx);
+
+int AXIS2_CALL notify_init(
+ axis2_svc_skeleton_t * svc_skeleton,
+ const axutil_env_t * env);
+
+axiom_node_t *AXIS2_CALL notify_on_fault(
+ axis2_svc_skeleton_t * svc_skeli,
+ const axutil_env_t * env,
+ axiom_node_t * node);
+
+static const axis2_svc_skeleton_ops_t notify_svc_skeleton_ops_var = {
+ notify_init,
+ notify_invoke,
+ notify_on_fault,
+ notify_free
+};
+
+/*Create function */
+axis2_svc_skeleton_t *
+axis2_notify_create(
+ const axutil_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 = &notify_svc_skeleton_ops_var;
+
+ svc_skeleton->func_array = NULL;
+
+ return svc_skeleton;
+}
+
+/* Initialize the service */
+int AXIS2_CALL
+notify_init(
+ axis2_svc_skeleton_t * svc_skeleton,
+ const axutil_env_t * env)
+{
+ /* Any initialization stuff of notify service should go here */
+ return AXIS2_SUCCESS;
+}
+
+/*
+ * This method invokes the right service method
+ */
+axiom_node_t *AXIS2_CALL
+notify_invoke(
+ axis2_svc_skeleton_t * svc_skeleton,
+ const axutil_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 notify in this sample, hence invoke notify method.
+ * To see how to deal with multiple impl methods, have a look at the
+ * math sample.
+ */
+ axis2_notify_notify(env, node);
+ return NULL;
+}
+
+/* On fault, handle the fault */
+axiom_node_t *AXIS2_CALL
+notify_on_fault(
+ axis2_svc_skeleton_t * svc_skeli,
+ const axutil_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, "NotifyServiceError", NULL,
+ &error_node);
+ axiom_element_set_text(error_ele, env, "Notify service failed ", text_node);
+ return error_node;
+}
+
+/* Free the resources used */
+int AXIS2_CALL
+notify_free(
+ axis2_svc_skeleton_t * svc_skeleton,
+ const axutil_env_t * env)
+{
+ /* Free the function array */
+ if (svc_skeleton->func_array)
+ {
+ axutil_array_list_free(svc_skeleton->func_array, env);
+ svc_skeleton->func_array = 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 axutil_env_t * env)
+{
+ *inst = axis2_notify_create(env);
+ if (!(*inst))
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int
+axis2_remove_instance(
+ axis2_svc_skeleton_t * inst,
+ const axutil_env_t * env)
+{
+ axis2_status_t status = AXIS2_FAILURE;
+ if (inst)
+ {
+ status = AXIS2_SVC_SKELETON_FREE(inst, env);
+ }
+ return status;
+}
diff --git a/samples/server/notify/services.xml b/samples/server/notify/services.xml
new file mode 100644
index 0000000..ff2be47
--- /dev/null
+++ b/samples/server/notify/services.xml
@@ -0,0 +1,13 @@
+<service name="notify">
+ <parameter name="ServiceClass" locked="xsd:false">notify</parameter>
+
+ <description>
+ This is a testing service , to test one way service support
+ </description>
+
+ <operation name="notify" mep="http://www.w3.org/2004/08/wsdl/in-only">
+ <!--messageReceiver class="axis2_receivers" /-->
+ <parameter name="wsamapping" >http://example.org/action/notify</parameter>
+ </operation>
+
+</service>