summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorGravatar m0gg2006-11-21 20:58:59 +0000
committerGravatar m0gg2006-11-21 20:58:59 +0000
commitc3fd98b25607d0f7f5977586d188f88ab226a9b8 (patch)
treecc4976a3be9d3984e4ae62c08afd1dcf9530dc5e /examples
parentcd94b25993049a596b163f0ad8b3a2340e024cc3 (diff)
downloadcsoap-c3fd98b25607d0f7f5977586d188f88ab226a9b8.tar.gz
csoap-c3fd98b25607d0f7f5977586d188f88ab226a9b8.tar.bz2
decoupling of nanohttp/libcsoap
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/csoap/echoattachments-client.c6
-rwxr-xr-xexamples/csoap/echoattachments-server.c14
-rw-r--r--examples/csoap/simpleclient.c45
-rw-r--r--examples/csoap/simpleserver.c68
-rw-r--r--examples/csoap/soapclient.c9
-rw-r--r--examples/nanohttp/http_client.c6
-rw-r--r--examples/nanohttp/http_server.c3
7 files changed, 95 insertions, 56 deletions
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 <stdio.h>
#include <netinet/in.h>
+#include <libxml/tree.h>
+
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-socket.h>
#include <nanohttp/nanohttp-stream.h>
@@ -32,6 +34,8 @@
#include <nanohttp/nanohttp-client.h>
#include <nanohttp/nanohttp-logging.h>
+#include <libcsoap/soap-env.h>
+#include <libcsoap/soap-ctx.h>
#include <libcsoap/soap-client.h>
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 <sys/time.h>
#include <stdio.h>
+#include <stdlib.h>
#include <netinet/in.h>
+#include <libxml/tree.h>
+
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-socket.h>
#include <nanohttp/nanohttp-stream.h>
@@ -32,16 +34,16 @@
#include <nanohttp/nanohttp-server.h>
#include <nanohttp/nanohttp-logging.h>
+#include <libcsoap/soap-env.h>
+#include <libcsoap/soap-ctx.h>
+#include <libcsoap/soap-service.h>
+#include <libcsoap/soap-router.h>
#include <libcsoap/soap-server.h>
-
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 <sys/time.h>
#include <stdio.h>
+#include <stdlib.h>
#include <netinet/in.h>
+#include <libxml/tree.h>
+
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-socket.h>
#include <nanohttp/nanohttp-stream.h>
@@ -34,11 +36,9 @@
#include <libcsoap/soap-client.h>
-
-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 <sys/time.h>
#include <stdio.h>
+#include <stdlib.h>
#include <netinet/in.h>
+#include <libxml/tree.h>
+
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-socket.h>
#include <nanohttp/nanohttp-stream.h>
@@ -32,21 +34,25 @@
#include <nanohttp/nanohttp-server.h>
#include <nanohttp/nanohttp-logging.h>
+#include <libcsoap/soap-xml.h>
+#include <libcsoap/soap-env.h>
+#include <libcsoap/soap-ctx.h>
+#include <libcsoap/soap-service.h>
+#include <libcsoap/soap-router.h>
#include <libcsoap/soap-server.h>
-
-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 <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <netinet/in.h>
+#include <libxml/tree.h>
+#include <libxml/uri.h>
+
#include <nanohttp/nanohttp-common.h>
#include <nanohttp/nanohttp-socket.h>
#include <nanohttp/nanohttp-stream.h>
#include <nanohttp/nanohttp-request.h>
#include <nanohttp/nanohttp-response.h>
#include <nanohttp/nanohttp-client.h>
-
#include <nanohttp/nanohttp-logging.h>
+
+#include <libcsoap/soap-fault.h>
+#include <libcsoap/soap-env.h>
+#include <libcsoap/soap-ctx.h>
#include <libcsoap/soap-client.h>
#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 <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <sys/time.h>
#include <netinet/in.h>
#include <nanohttp/nanohttp-common.h>
@@ -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 <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>