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/echoattachments-client.c | 6 ++- examples/csoap/echoattachments-server.c | 14 ++++--- examples/csoap/simpleclient.c | 45 ++++++++++++---------- examples/csoap/simpleserver.c | 68 +++++++++++++++++++++++---------- examples/csoap/soapclient.c | 9 ++++- examples/nanohttp/http_client.c | 6 +-- examples/nanohttp/http_server.c | 3 +- 7 files changed, 95 insertions(+), 56 deletions(-) (limited to 'examples') diff --git a/examples/csoap/echoattachments-client.c b/examples/csoap/echoattachments-client.c index 49d1931..b128563 100755 --- a/examples/csoap/echoattachments-client.c +++ b/examples/csoap/echoattachments-client.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: echoattachments-client.c,v 1.12 2006/11/19 09:40:14 m0gg Exp $ + * $Id: echoattachments-client.c,v 1.13 2006/11/21 20:58:59 m0gg Exp $ * * CSOAP Project: CSOAP examples project * Copyright (C) 2003-2004 Ferhat Ayaz @@ -24,6 +24,8 @@ #include #include +#include + #include #include #include @@ -32,6 +34,8 @@ #include #include +#include +#include #include diff --git a/examples/csoap/echoattachments-server.c b/examples/csoap/echoattachments-server.c index 5543984..a065cc5 100755 --- a/examples/csoap/echoattachments-server.c +++ b/examples/csoap/echoattachments-server.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: echoattachments-server.c,v 1.9 2006/11/19 09:40:14 m0gg Exp $ + * $Id: echoattachments-server.c,v 1.10 2006/11/21 20:58:59 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,16 +34,16 @@ #include #include +#include +#include +#include +#include #include - static const char *url = "/echoattachments"; static const char *urn = "urn:examples"; static const char *method = "echo"; - - - herror_t echo_attachments(SoapCtx * req, SoapCtx * res) { diff --git a/examples/csoap/simpleclient.c b/examples/csoap/simpleclient.c index 47ffd32..6a4451e 100644 --- a/examples/csoap/simpleclient.c +++ b/examples/csoap/simpleclient.c @@ -1,5 +1,5 @@ /****************************************************************** - * $Id: simpleclient.c,v 1.13 2006/11/19 09:40:14 m0gg Exp $ + * $Id: simpleclient.c,v 1.14 2006/11/21 20:58:59 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 @@ -34,11 +36,9 @@ #include - -static const char *url = "http://localhost:10000/csoapserver"; -static const char *urn = "urn:examples"; -static const char *method = "sayHello"; - +static char *url = "http://localhost:10000/csoapserver"; +static char *urn = "urn:examples"; +static char *method = "sayHello"; int main(int argc, char *argv[]) @@ -46,45 +46,48 @@ main(int argc, char *argv[]) SoapCtx *ctx, *ctx2; herror_t err; - /* log_set_level(HLOG_VERBOSE); */ + // hlog_set_level(HLOG_VERBOSE); + err = soap_client_init_args(argc, argv); if (err != H_OK) { - log_error4("%s():%s [%d]", herror_func(err), herror_message(err), - herror_code(err)); + printf("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err)); herror_release(err); - return 1; + exit(1); } err = soap_ctx_new_with_method(urn, method, &ctx); if (err != H_OK) { - log_error4("%s():%s [%d]", herror_func(err), herror_message(err), - herror_code(err)); + printf("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err)); herror_release(err); - return 1; + exit(1); } soap_env_add_item(ctx->env, "xsd:string", "name", "Jonny B. Good"); + printf("**** sending ****\n"); + soap_xml_doc_print(ctx->env->root->doc); + if (argc > 1) - err = soap_client_invoke(ctx, &ctx2, argv[1], ""); - else - err = soap_client_invoke(ctx, &ctx2, url, ""); + url = argv[1]; + printf("destination: \"%s\"\n", url); - if (err != H_OK) + if ((err = soap_client_invoke(ctx, &ctx2, url, "")) != H_OK) { - log_error4("[%d] %s(): %s ", herror_code(err), herror_func(err), - herror_message(err)); + printf("[%d] %s(): %s ", herror_code(err), herror_func(err), herror_message(err)); herror_release(err); soap_ctx_free(ctx); - return 1; + exit(1); } + printf("**** received ****\n"); soap_xml_doc_print(ctx2->env->root->doc); + soap_ctx_free(ctx2); soap_ctx_free(ctx); soap_client_destroy(); + return 0; } 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; diff --git a/examples/csoap/soapclient.c b/examples/csoap/soapclient.c index 131ceac..c7d55f3 100644 --- a/examples/csoap/soapclient.c +++ b/examples/csoap/soapclient.c @@ -4,21 +4,26 @@ */ /* Author: Adrianus Warmenhoven */ -#include #include #include #include #include +#include +#include + #include #include #include #include #include #include - #include + +#include +#include +#include #include #define MAX_LINE_LENGTH 65535 diff --git a/examples/nanohttp/http_client.c b/examples/nanohttp/http_client.c index d2ff4c9..4fa5bed 100644 --- a/examples/nanohttp/http_client.c +++ b/examples/nanohttp/http_client.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: http_client.c,v 1.3 2006/11/19 09:40:14 m0gg Exp $ +* $Id: http_client.c,v 1.4 2006/11/21 20:59:02 m0gg Exp $ * * CSOAP Project: A http client/server library in C (example) * Copyright (C) 2003-2004 Ferhat Ayaz @@ -22,8 +22,8 @@ * Email: hero@persua.de ******************************************************************/ #include +#include #include -#include #include #include @@ -116,7 +116,7 @@ int main(int argc, char **argv) { /* Initialize httpc module */ if (httpc_init(argc, argv)) { - log_error1("Can not init httpc"); + log_error1("Cannot init httpc"); exit(1); } diff --git a/examples/nanohttp/http_server.c b/examples/nanohttp/http_server.c index 5801312..420c32f 100644 --- a/examples/nanohttp/http_server.c +++ b/examples/nanohttp/http_server.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: http_server.c,v 1.5 2006/11/19 09:40:14 m0gg Exp $ +* $Id: http_server.c,v 1.6 2006/11/21 20:59:02 m0gg Exp $ * * CSOAP Project: A http client/server library in C (example) * Copyright (C) 2003 Ferhat Ayaz @@ -21,7 +21,6 @@ * * Email: hero@persua.de ******************************************************************/ -#include #include #include #include -- cgit v1.1-32-gdbae