summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorGravatar snowdrop2004-11-02 23:09:19 +0000
committerGravatar snowdrop2004-11-02 23:09:19 +0000
commit402e8748593a42cf6d42fda772f207e3e9300a3e (patch)
tree8c87ecde3498891a6de178f2a77dc4d9cf20fe57 /examples
parent15b392f1e21d3dae8f83da401199959e9f0b0db6 (diff)
downloadcsoap-402e8748593a42cf6d42fda772f207e3e9300a3e.tar.gz
csoap-402e8748593a42cf6d42fda772f207e3e9300a3e.tar.bz2
dos2unix
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/csoap/echoattachments-client.c366
-rwxr-xr-xexamples/csoap/echoattachments-server.c170
-rw-r--r--examples/csoap/simpleclient.c48
-rw-r--r--examples/csoap/simpleserver.c170
4 files changed, 377 insertions, 377 deletions
diff --git a/examples/csoap/echoattachments-client.c b/examples/csoap/echoattachments-client.c
index 0f57b6b..0d8e9dc 100755
--- a/examples/csoap/echoattachments-client.c
+++ b/examples/csoap/echoattachments-client.c
@@ -1,183 +1,183 @@
-/******************************************************************
- * $Id: echoattachments-client.c,v 1.7 2004/11/02 22:42:52 snowdrop Exp $
- *
- * CSOAP Project: CSOAP examples project
- * Copyright (C) 2003-2004 Ferhat Ayaz
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
- *
- * Email: ferhatayaz@yahoo.com
- ******************************************************************/
-
-#include <libcsoap/soap-client.h>
-
-
-
-
-static const char *urn = "urn:examples";
-static const char *url = "http://localhost:10000/echoattachments";
-static const char *method = "echo";
-
-
-void compareFiles(const char* received, const char *sent)
-{
- FILE *f1, *f2;
- char c1, c2;
- long s1,s2;
-
- printf("Opening received file to compare: '%s'\n", received);
- f1 = fopen(received, "r");
- if (!f1) {
- fprintf(stderr, "Can not open '%s'\n", received);
- return;
- }
-
- printf("Opening sent file to compare: '%s'\n", sent);
- f2 = fopen(sent, "r");
- if (!f2) {
- fprintf(stderr, "Can not open '%s'\n", sent);
- fclose(f1);
- return;
- }
-
- fseek(f1, 0, SEEK_END);
- fseek(f2, 0, SEEK_END);
-
- s1 = ftell(f1);
- s2 = ftell(f2);
-
- fseek(f1, 0, SEEK_SET);
- fseek(f2, 0, SEEK_SET);
-
- if (s1 > s2) {
-
- printf("ERROR: files are not equal! Received file is bigger\n");
- fclose(f1); fclose(f2);
- return;
-
- } else if (s2 > s1) {
-
- printf("ERROR: files are not equal! Sent file is bigger\n");
- fclose(f1); fclose(f2);
- return;
- }
-
- while (feof(f1)) {
-
- c1= fgetc(f1);
- c2= fgetc(f2);
- if (c1 != c2){
- printf("ERROR: files are not equal! Byte compare failed\n");
- fclose(f1); fclose(f2);
- break;
- }
- }
-
- printf("OK: files are equal!\n");
- fclose(f1); fclose(f2);
-
-}
-
-int main(int argc, char *argv[])
-{
- SoapCtx *ctx, *ctx2;
- char href[MAX_HREF_SIZE];
- xmlNodePtr fault;
- herror_t err;
-
-
- if (argc < 2) {
- fprintf(stderr, "usage: %s <filename> [url]\n", argv[0]);
- exit(1);
- }
-
- /*
- Initialize soap client
- */
- err = soap_client_init_args(argc, argv);
- if (err != H_OK) {
- log_error4("[%d] %s():%s ", herror_code(err), herror_func(err), herror_message(err));
- herror_release(err);
- return 1;
- }
-
- /*
- Create a context object
- */
- err = soap_ctx_new_with_method(urn, method, &ctx);
- if (err != H_OK) {
- log_error4("[%d] %s():%s ", herror_code(err), herror_func(err), herror_message(err));
- herror_release(err);
- return 1;
- }
-
- /*
- Add file to the context
- */
- err = soap_ctx_add_file(ctx, argv[1], "application/octet-stream", href);
- if (err != H_OK) {
- log_error4("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err));
- herror_release(err);
- return 1;
- }
-
- /*
- Add file reference to the envelope
- */
- soap_env_add_attachment(ctx->env,"source", href);
-
- /*
- Send soap request to the server
- */
- printf("sending request ...\n");
- if (argc > 2)
- err = soap_client_invoke(ctx, &ctx2, argv[2], "");
- else
- err = soap_client_invoke(ctx, &ctx2, url, "");
-
- if (err != H_OK) {
- log_error4("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err));
- herror_release(err);
- return 1;
- }
-
- /*
- Handle response (just print to the screen)
- */
- fault = soap_env_get_fault(ctx2->env);
- if (fault) {
- soap_xml_doc_print(ctx2->env->root->doc);
- } else if (ctx2->attachments) {
- compareFiles(ctx2->attachments->parts->filename, argv[1]);
- } else {
- printf("No attachments!");
- soap_xml_doc_print(ctx2->env->root->doc);
- }
-
- /*
- Clean up
- */
- soap_ctx_free(ctx2);
- soap_ctx_free(ctx);
-
- soap_client_destroy();
-
- return 0;
-}
-
-
-
-
-
+/******************************************************************
+ * $Id: echoattachments-client.c,v 1.8 2004/11/02 23:09:19 snowdrop Exp $
+ *
+ * CSOAP Project: CSOAP examples project
+ * Copyright (C) 2003-2004 Ferhat Ayaz
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
+ *
+ * Email: ferhatayaz@yahoo.com
+ ******************************************************************/
+
+#include <libcsoap/soap-client.h>
+
+
+
+
+static const char *urn = "urn:examples";
+static const char *url = "http://localhost:10000/echoattachments";
+static const char *method = "echo";
+
+
+void compareFiles(const char* received, const char *sent)
+{
+ FILE *f1, *f2;
+ char c1, c2;
+ long s1,s2;
+
+ printf("Opening received file to compare: '%s'\n", received);
+ f1 = fopen(received, "r");
+ if (!f1) {
+ fprintf(stderr, "Can not open '%s'\n", received);
+ return;
+ }
+
+ printf("Opening sent file to compare: '%s'\n", sent);
+ f2 = fopen(sent, "r");
+ if (!f2) {
+ fprintf(stderr, "Can not open '%s'\n", sent);
+ fclose(f1);
+ return;
+ }
+
+ fseek(f1, 0, SEEK_END);
+ fseek(f2, 0, SEEK_END);
+
+ s1 = ftell(f1);
+ s2 = ftell(f2);
+
+ fseek(f1, 0, SEEK_SET);
+ fseek(f2, 0, SEEK_SET);
+
+ if (s1 > s2) {
+
+ printf("ERROR: files are not equal! Received file is bigger\n");
+ fclose(f1); fclose(f2);
+ return;
+
+ } else if (s2 > s1) {
+
+ printf("ERROR: files are not equal! Sent file is bigger\n");
+ fclose(f1); fclose(f2);
+ return;
+ }
+
+ while (feof(f1)) {
+
+ c1= fgetc(f1);
+ c2= fgetc(f2);
+ if (c1 != c2){
+ printf("ERROR: files are not equal! Byte compare failed\n");
+ fclose(f1); fclose(f2);
+ break;
+ }
+ }
+
+ printf("OK: files are equal!\n");
+ fclose(f1); fclose(f2);
+
+}
+
+int main(int argc, char *argv[])
+{
+ SoapCtx *ctx, *ctx2;
+ char href[MAX_HREF_SIZE];
+ xmlNodePtr fault;
+ herror_t err;
+
+
+ if (argc < 2) {
+ fprintf(stderr, "usage: %s <filename> [url]\n", argv[0]);
+ exit(1);
+ }
+
+ /*
+ Initialize soap client
+ */
+ err = soap_client_init_args(argc, argv);
+ if (err != H_OK) {
+ log_error4("[%d] %s():%s ", herror_code(err), herror_func(err), herror_message(err));
+ herror_release(err);
+ return 1;
+ }
+
+ /*
+ Create a context object
+ */
+ err = soap_ctx_new_with_method(urn, method, &ctx);
+ if (err != H_OK) {
+ log_error4("[%d] %s():%s ", herror_code(err), herror_func(err), herror_message(err));
+ herror_release(err);
+ return 1;
+ }
+
+ /*
+ Add file to the context
+ */
+ err = soap_ctx_add_file(ctx, argv[1], "application/octet-stream", href);
+ if (err != H_OK) {
+ log_error4("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err));
+ herror_release(err);
+ return 1;
+ }
+
+ /*
+ Add file reference to the envelope
+ */
+ soap_env_add_attachment(ctx->env,"source", href);
+
+ /*
+ Send soap request to the server
+ */
+ printf("sending request ...\n");
+ if (argc > 2)
+ err = soap_client_invoke(ctx, &ctx2, argv[2], "");
+ else
+ err = soap_client_invoke(ctx, &ctx2, url, "");
+
+ if (err != H_OK) {
+ log_error4("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err));
+ herror_release(err);
+ return 1;
+ }
+
+ /*
+ Handle response (just print to the screen)
+ */
+ fault = soap_env_get_fault(ctx2->env);
+ if (fault) {
+ soap_xml_doc_print(ctx2->env->root->doc);
+ } else if (ctx2->attachments) {
+ compareFiles(ctx2->attachments->parts->filename, argv[1]);
+ } else {
+ printf("No attachments!");
+ soap_xml_doc_print(ctx2->env->root->doc);
+ }
+
+ /*
+ Clean up
+ */
+ soap_ctx_free(ctx2);
+ soap_ctx_free(ctx);
+
+ soap_client_destroy();
+
+ return 0;
+}
+
+
+
+
+
diff --git a/examples/csoap/echoattachments-server.c b/examples/csoap/echoattachments-server.c
index 22b5fb2..01299b4 100755
--- a/examples/csoap/echoattachments-server.c
+++ b/examples/csoap/echoattachments-server.c
@@ -1,85 +1,85 @@
-/******************************************************************
- * $Id: echoattachments-server.c,v 1.4 2004/11/01 15:16:22 snowdrop Exp $
- *
- * CSOAP Project: CSOAP examples project
- * Copyright (C) 2003-2004 Ferhat Ayaz
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
- *
- * Email: ferhatayaz@yahoo.com
- ******************************************************************/
-
-#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)
-{
- herror_t err;
-
- part_t *part;
- char href[MAX_HREF_SIZE];
-
- err = soap_env_new_with_response(req->env, &res->env);
- if (err != H_OK) {
- return err;
- }
-
- if (req->attachments)
- {
- for (part = req->attachments->parts; part != NULL; part = part->next)
- {
- soap_ctx_add_file(res, part->filename, part->content_type, href);
- soap_env_add_attachment(res->env, "echoFile", href);
- }
- }
-
- return H_OK;
-}
-
-
-int main(int argc, char *argv[])
-{
- herror_t err;
- SoapRouter *router;
-
- log_set_level(HLOG_VERBOSE);
-
- err = soap_server_init_args(argc, argv);
- if (err != H_OK) {
- log_error4("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err));
- herror_release(err);
- return 1;
- }
-
- router = soap_router_new();
- soap_router_register_service(router, echo_attachments, method, urn);
- soap_server_register_router(router, url);
-
- log_info1("send SIGTERM to shutdown");
- soap_server_run();
-
- log_info1("shutting down\n");
- soap_server_destroy();
-
- return 0;
-}
-
+/******************************************************************
+ * $Id: echoattachments-server.c,v 1.5 2004/11/02 23:09:19 snowdrop Exp $
+ *
+ * CSOAP Project: CSOAP examples project
+ * Copyright (C) 2003-2004 Ferhat Ayaz
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
+ *
+ * Email: ferhatayaz@yahoo.com
+ ******************************************************************/
+
+#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)
+{
+ herror_t err;
+
+ part_t *part;
+ char href[MAX_HREF_SIZE];
+
+ err = soap_env_new_with_response(req->env, &res->env);
+ if (err != H_OK) {
+ return err;
+ }
+
+ if (req->attachments)
+ {
+ for (part = req->attachments->parts; part != NULL; part = part->next)
+ {
+ soap_ctx_add_file(res, part->filename, part->content_type, href);
+ soap_env_add_attachment(res->env, "echoFile", href);
+ }
+ }
+
+ return H_OK;
+}
+
+
+int main(int argc, char *argv[])
+{
+ herror_t err;
+ SoapRouter *router;
+
+ log_set_level(HLOG_VERBOSE);
+
+ err = soap_server_init_args(argc, argv);
+ if (err != H_OK) {
+ log_error4("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err));
+ herror_release(err);
+ return 1;
+ }
+
+ router = soap_router_new();
+ soap_router_register_service(router, echo_attachments, method, urn);
+ soap_server_register_router(router, url);
+
+ log_info1("send SIGTERM to shutdown");
+ soap_server_run();
+
+ log_info1("shutting down\n");
+ soap_server_destroy();
+
+ return 0;
+}
+
diff --git a/examples/csoap/simpleclient.c b/examples/csoap/simpleclient.c
index 8c10d5f..29c4c1e 100644
--- a/examples/csoap/simpleclient.c
+++ b/examples/csoap/simpleclient.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: simpleclient.c,v 1.8 2004/11/02 22:42:52 snowdrop Exp $
+ * $Id: simpleclient.c,v 1.9 2004/11/02 23:09:19 snowdrop Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -31,23 +31,23 @@ static const char *method = "sayHello";
int main(int argc, char *argv[])
{
- SoapCtx *ctx, *ctx2;
+ SoapCtx *ctx, *ctx2;
herror_t err;
- /*log_set_level(HLOG_VERBOSE);*/
+ /*log_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));
- herror_release(err);
- return 1;
- }
+ if (err != H_OK) {
+ log_error4("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err));
+ herror_release(err);
+ return 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));
- herror_release(err);
- return 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));
+ herror_release(err);
+ return 1;
+ }
soap_env_add_item(ctx->env, "xsd:string", "name", "Jonny B. Good");
@@ -55,18 +55,18 @@ int main(int argc, char *argv[])
err = soap_client_invoke(ctx, &ctx2, argv[1], "");
else
err = soap_client_invoke(ctx, &ctx2, url, "");
-
- if (err != H_OK) {
- log_error4("[%d] %s(): %s ", herror_code(err), herror_func(err), herror_message(err));
- herror_release(err);
- soap_ctx_free(ctx);
- return 1;
- }
+
+ if (err != H_OK) {
+ log_error4("[%d] %s(): %s ", herror_code(err), herror_func(err), herror_message(err));
+ herror_release(err);
+ soap_ctx_free(ctx);
+ return 1;
+ }
soap_xml_doc_print(ctx2->env->root->doc);
soap_ctx_free(ctx2);
- soap_ctx_free(ctx);
-
- soap_client_destroy();
+ soap_ctx_free(ctx);
+
+ soap_client_destroy();
return 0;
}
diff --git a/examples/csoap/simpleserver.c b/examples/csoap/simpleserver.c
index a165cfc..fef16f0 100644
--- a/examples/csoap/simpleserver.c
+++ b/examples/csoap/simpleserver.c
@@ -1,85 +1,85 @@
-/******************************************************************
- * $Id: simpleserver.c,v 1.11 2004/10/28 10:30:42 snowdrop Exp $
- *
- * CSOAP Project: CSOAP examples project
- * Copyright (C) 2003-2004 Ferhat Ayaz
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
- *
- * Email: ferhatayaz@yahoo.com
- ******************************************************************/
-
-#include <libcsoap/soap-server.h>
-
-
-static const char *url = "/csoapserver";
-static const char *urn = "urn:examples";
-static const char *method = "sayHello";
-
-
-herror_t say_hello(SoapCtx *req, SoapCtx* res)
-{
-
- herror_t err;
- char *name;
-
- xmlNodePtr method, node;
-
- err = soap_env_new_with_response(req->env, &res->env);
- if (err != H_OK) {
- return err;
- }
-
- method = soap_env_get_method(req->env);
- node = soap_xml_get_children(method);
-
- while (node) {
- name = (char*)xmlNodeListGetString(node->doc, node->xmlChildrenNode, 1);
- soap_env_add_itemf(req->env,"xsd:string", "echo", "Hello '%s'", name);
- node = soap_xml_get_next(node);
- }
-
- return H_OK;
-}
-
-
-int main(int argc, char *argv[])
-{
-
- herror_t err;
- SoapRouter *router;
-
- log_set_level(HLOG_VERBOSE);
-
- err = soap_server_init_args(argc, argv);
- if (err != H_OK) {
- log_error4("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err));
- herror_release(err);
- return 1;
- }
-
- router = soap_router_new();
- soap_router_register_service(router, say_hello, method, urn);
- soap_server_register_router(router, url);
-
- log_info1("send SIGTERM to shutdown");
- soap_server_run();
-
- log_info1("shutting down\n");
- soap_server_destroy();
-
- return 0;
-}
-
+/******************************************************************
+ * $Id: simpleserver.c,v 1.12 2004/11/02 23:09:19 snowdrop Exp $
+ *
+ * CSOAP Project: CSOAP examples project
+ * Copyright (C) 2003-2004 Ferhat Ayaz
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
+ *
+ * Email: ferhatayaz@yahoo.com
+ ******************************************************************/
+
+#include <libcsoap/soap-server.h>
+
+
+static const char *url = "/csoapserver";
+static const char *urn = "urn:examples";
+static const char *method = "sayHello";
+
+
+herror_t say_hello(SoapCtx *req, SoapCtx* res)
+{
+
+ herror_t err;
+ char *name;
+
+ xmlNodePtr method, node;
+
+ err = soap_env_new_with_response(req->env, &res->env);
+ if (err != H_OK) {
+ return err;
+ }
+
+ method = soap_env_get_method(req->env);
+ node = soap_xml_get_children(method);
+
+ while (node) {
+ name = (char*)xmlNodeListGetString(node->doc, node->xmlChildrenNode, 1);
+ soap_env_add_itemf(req->env,"xsd:string", "echo", "Hello '%s'", name);
+ node = soap_xml_get_next(node);
+ }
+
+ return H_OK;
+}
+
+
+int main(int argc, char *argv[])
+{
+
+ herror_t err;
+ SoapRouter *router;
+
+ log_set_level(HLOG_VERBOSE);
+
+ err = soap_server_init_args(argc, argv);
+ if (err != H_OK) {
+ log_error4("%s():%s [%d]", herror_func(err), herror_message(err), herror_code(err));
+ herror_release(err);
+ return 1;
+ }
+
+ router = soap_router_new();
+ soap_router_register_service(router, say_hello, method, urn);
+ soap_server_register_router(router, url);
+
+ log_info1("send SIGTERM to shutdown");
+ soap_server_run();
+
+ log_info1("shutting down\n");
+ soap_server_destroy();
+
+ return 0;
+}
+