From c3fd98b25607d0f7f5977586d188f88ab226a9b8 Mon Sep 17 00:00:00 2001 From: m0gg Date: Tue, 21 Nov 2006 20:58:59 +0000 Subject: decoupling of nanohttp/libcsoap --- examples/csoap/simpleserver.c | 68 ++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 21 deletions(-) (limited to 'examples/csoap/simpleserver.c') diff --git a/examples/csoap/simpleserver.c b/examples/csoap/simpleserver.c index 33e1a3c..a433783 100644 --- a/examples/csoap/simpleserver.c +++ b/examples/csoap/simpleserver.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: simpleserver.c,v 1.20 2006/11/19 09:40:14 m0gg Exp $ + * $Id: simpleserver.c,v 1.21 2006/11/21 20:59:02 m0gg Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -20,10 +20,12 @@ * * Email: ferhatayaz@yahoo.com ******************************************************************/ -#include #include +#include #include +#include + #include #include #include @@ -32,21 +34,25 @@ #include #include +#include +#include +#include +#include +#include #include - -static const char *url = "/csoapserver"; -static const char *urn = "urn:examples"; -static const char *method = "sayHello"; - +static const char const *url = "/csoapserver"; +static const char const *urn = "urn:examples"; +static const char const *method = "sayHello"; herror_t say_hello(SoapCtx * req, SoapCtx * res) { - herror_t err; char *name; + log_verbose1("service request"); + xmlNodePtr method, node; err = soap_env_new_with_response(req->env, &res->env); @@ -69,7 +75,6 @@ say_hello(SoapCtx * req, SoapCtx * res) return H_OK; } - int main(int argc, char *argv[]) { @@ -77,25 +82,46 @@ main(int argc, char *argv[]) herror_t err; SoapRouter *router; - hlog_set_level(HLOG_INFO); + // hlog_set_level(HLOG_VERBOSE); - err = soap_server_init_args(argc, argv); - if (err != H_OK) + if ((err = soap_server_init_args(argc, argv)) != H_OK) + { + printf("%s(): %s [%d]\n", herror_func(err), herror_message(err), herror_code(err)); + herror_release(err); + exit(1); + } + + if (!(router = soap_router_new())) { - log_error4("%s():%s [%d]", herror_func(err), herror_message(err), - herror_code(err)); + printf("soap_router_new failed (%p)\n", router); herror_release(err); - return 1; + exit(1); } - router = soap_router_new(); - soap_router_register_service(router, say_hello, method, urn); - soap_server_register_router(router, url); + if ((err = soap_router_register_service(router, say_hello, method, urn)) != H_OK) + { + printf("%s(): %s [%d]\n", herror_func(err), herror_message(err), herror_code(err)); + herror_release(err); + exit(1); + } - log_info1("press ctrl-c to shutdown"); - soap_server_run(); + if ((err = soap_server_register_router(router, url))) + { + printf("%s(): %s [%s]\n", herror_func(err), herror_message(err), herror_code(err)); + herror_release(err); + exit(1); + } + printf("router (%p) registered for \"%s\"\n", router, url); - log_info1("shutting down\n"); + printf("press ctrl-c to shutdown\n"); + if ((err = soap_server_run()) != H_OK) + { + printf("%s(): %s [%s]\n", herror_func(err), herror_message(err), herror_code(err)); + herror_release(err); + exit(1); + } + + printf("shutting down\n"); soap_server_destroy(); return 0; -- cgit v1.1-32-gdbae