summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorGravatar snowdrop2006-01-10 11:21:55 +0000
committerGravatar snowdrop2006-01-10 11:21:55 +0000
commitc24e5b5135d745098ea6e5c4664a88ada6b99225 (patch)
tree5a699cafd54fe64e08c10f2a2912f1d800cc0a6b /examples
parent56841f81e5c0082ec7c36e44737d07f60fada535 (diff)
downloadcsoap-c24e5b5135d745098ea6e5c4664a88ada6b99225.tar.gz
csoap-c24e5b5135d745098ea6e5c4664a88ada6b99225.tar.bz2
indent with 'indent -nut -bli0 -fca' command
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/csoap/echoattachments-client.c227
-rwxr-xr-xexamples/csoap/echoattachments-server.c64
-rw-r--r--examples/csoap/simpleclient.c61
-rw-r--r--examples/csoap/simpleserver.c64
-rw-r--r--examples/csoap/soapclient.c301
5 files changed, 404 insertions, 313 deletions
diff --git a/examples/csoap/echoattachments-client.c b/examples/csoap/echoattachments-client.c
index 0d8e9dc..353e1d2 100755
--- a/examples/csoap/echoattachments-client.c
+++ b/examples/csoap/echoattachments-client.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: echoattachments-client.c,v 1.8 2004/11/02 23:09:19 snowdrop Exp $
+ * $Id: echoattachments-client.c,v 1.9 2006/01/10 11:21:55 snowdrop Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -31,66 +31,79 @@ static const char *url = "http://localhost:10000/echoattachments";
static const char *method = "echo";
-void compareFiles(const char* received, const char *sent)
+void
+compareFiles (const char *received, const char *sent)
{
FILE *f1, *f2;
char c1, c2;
- long s1,s2;
+ 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);
+ 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);
+ 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);
+ fseek (f1, 0, SEEK_END);
+ fseek (f2, 0, SEEK_END);
- s1 = ftell(f1);
- s2 = ftell(f2);
+ s1 = ftell (f1);
+ s2 = ftell (f2);
- fseek(f1, 0, SEEK_SET);
- fseek(f2, 0, SEEK_SET);
+ fseek (f1, 0, SEEK_SET);
+ fseek (f2, 0, SEEK_SET);
- if (s1 > s2) {
+ if (s1 > s2)
+ {
- printf("ERROR: files are not equal! Received file is bigger\n");
- fclose(f1); fclose(f2);
- return;
+ printf ("ERROR: files are not equal! Received file is bigger\n");
+ fclose (f1);
+ fclose (f2);
+ return;
- } else if (s2 > s1) {
+ }
+ else if (s2 > s1)
+ {
- printf("ERROR: files are not equal! Sent file is bigger\n");
- fclose(f1); fclose(f2);
- return;
+ 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);
+ 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);
-
+
+ printf ("OK: files are equal!\n");
+ fclose (f1);
+ fclose (f2);
+
}
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
SoapCtx *ctx, *ctx2;
char href[MAX_HREF_SIZE];
@@ -98,86 +111,88 @@ int main(int argc, char *argv[])
herror_t err;
- if (argc < 2) {
- fprintf(stderr, "usage: %s <filename> [url]\n", argv[0]);
- exit(1);
+ 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;
}
- /*
- 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;
}
- /*
- 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 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");
+
+ /*
+ 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], "");
+ 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;
+ 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);
+ /*
+ 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);
+ /*
+ Clean up */
+ soap_ctx_free (ctx2);
+ soap_ctx_free (ctx);
- soap_client_destroy();
+ soap_client_destroy ();
return 0;
}
-
-
-
-
-
diff --git a/examples/csoap/echoattachments-server.c b/examples/csoap/echoattachments-server.c
index 01299b4..151d020 100755
--- a/examples/csoap/echoattachments-server.c
+++ b/examples/csoap/echoattachments-server.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: echoattachments-server.c,v 1.5 2004/11/02 23:09:19 snowdrop Exp $
+ * $Id: echoattachments-server.c,v 1.6 2006/01/10 11:21:55 snowdrop Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -31,55 +31,59 @@ static const char *method = "echo";
-herror_t echo_attachments(SoapCtx *req, SoapCtx* res)
+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;
+ err = soap_env_new_with_response (req->env, &res->env);
+ if (err != H_OK)
+ {
+ return err;
}
- if (req->attachments)
+ 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);
+ 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[])
+int
+main (int argc, char *argv[])
{
- herror_t err;
+ 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;
+
+ 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();
+ router = soap_router_new ();
+ soap_router_register_service (router, echo_attachments, method, urn);
+ soap_server_register_router (router, url);
- log_info1("shutting down\n");
- soap_server_destroy();
+ 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 29c4c1e..4e0e843 100644
--- a/examples/csoap/simpleclient.c
+++ b/examples/csoap/simpleclient.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: simpleclient.c,v 1.9 2004/11/02 23:09:19 snowdrop Exp $
+ * $Id: simpleclient.c,v 1.10 2006/01/10 11:21:55 snowdrop Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -29,44 +29,51 @@ static const char *urn = "urn:examples";
static const char *method = "sayHello";
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
SoapCtx *ctx, *ctx2;
herror_t err;
-
- /*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;
+
+ /* 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;
}
- 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");
-
+ soap_env_add_item (ctx->env, "xsd:string", "name", "Jonny B. Good");
+
if (argc > 1)
- err = soap_client_invoke(ctx, &ctx2, argv[1], "");
+ err = soap_client_invoke (ctx, &ctx2, argv[1], "");
else
- err = soap_client_invoke(ctx, &ctx2, url, "");
+ 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_xml_doc_print (ctx2->env->root->doc);
+ soap_ctx_free (ctx2);
+ soap_ctx_free (ctx);
- soap_client_destroy();
+ soap_client_destroy ();
return 0;
}
diff --git a/examples/csoap/simpleserver.c b/examples/csoap/simpleserver.c
index 90c62db..b0d37f9 100644
--- a/examples/csoap/simpleserver.c
+++ b/examples/csoap/simpleserver.c
@@ -1,5 +1,5 @@
/******************************************************************
- * $Id: simpleserver.c,v 1.14 2005/07/22 13:27:26 snowdrop Exp $
+ * $Id: simpleserver.c,v 1.15 2006/01/10 11:21:55 snowdrop Exp $
*
* CSOAP Project: CSOAP examples project
* Copyright (C) 2003-2004 Ferhat Ayaz
@@ -29,7 +29,8 @@ static const char *urn = "urn:examples";
static const char *method = "sayHello";
-herror_t say_hello(SoapCtx *req, SoapCtx* res)
+herror_t
+say_hello (SoapCtx * req, SoapCtx * res)
{
herror_t err;
@@ -37,49 +38,54 @@ herror_t say_hello(SoapCtx *req, SoapCtx* res)
xmlNodePtr method, node;
- err = soap_env_new_with_response(req->env, &res->env);
- if (err != H_OK) {
- return err;
+ 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);
+ 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(res->env,"xsd:string", "echo", "Hello '%s'", name);
- node = soap_xml_get_next(node);
+ while (node)
+ {
+ name =
+ (char *) xmlNodeListGetString (node->doc, node->xmlChildrenNode, 1);
+ soap_env_add_itemf (res->env, "xsd:string", "echo", "Hello '%s'", name);
+ node = soap_xml_get_next (node);
}
return H_OK;
}
-int main(int argc, char *argv[])
+int
+main (int argc, char *argv[])
{
herror_t err;
SoapRouter *router;
-
- log_set_level(HLOG_INFO);
-
- 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;
+
+ log_set_level (HLOG_INFO);
+
+ 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();
+ router = soap_router_new ();
+ soap_router_register_service (router, say_hello, method, urn);
+ soap_server_register_router (router, url);
- log_info1("shutting down\n");
- soap_server_destroy();
+ log_info1 ("send SIGTERM to shutdown");
+ soap_server_run ();
+
+ log_info1 ("shutting down\n");
+ soap_server_destroy ();
return 0;
}
-
diff --git a/examples/csoap/soapclient.c b/examples/csoap/soapclient.c
index 5603da1..826d518 100644
--- a/examples/csoap/soapclient.c
+++ b/examples/csoap/soapclient.c
@@ -10,185 +10,244 @@
#define MAX_LINE_LENGTH 65535
// stripcslashes - unescapes the string
-void stripcslashes(char *str, int *len) {
+void
+stripcslashes (char *str, int *len)
+{
char *source, *target, *end;
- int nlen = *len, i;
+ int nlen = *len, i;
char numtmp[4];
- for (source=str, end=str+nlen, target=str; source < end; source++) {
- if (*source == '\\' && source+1 < end) {
+ for (source = str, end = str + nlen, target = str; source < end; source++)
+ {
+ if (*source == '\\' && source + 1 < end)
+ {
source++;
- switch (*source) {
- case 'n': *target++='\n'; nlen--; break;
- case 'r': *target++='\r'; nlen--; break;
- case 'a': *target++='\a'; nlen--; break;
- case 't': *target++='\t'; nlen--; break;
- case 'v': *target++='\v'; nlen--; break;
- case 'b': *target++='\b'; nlen--; break;
- case 'f': *target++='\f'; nlen--; break;
- case '\\': *target++='\\'; nlen--; break;
+ switch (*source)
+ {
+ case 'n':
+ *target++ = '\n';
+ nlen--;
+ break;
+ case 'r':
+ *target++ = '\r';
+ nlen--;
+ break;
+ case 'a':
+ *target++ = '\a';
+ nlen--;
+ break;
+ case 't':
+ *target++ = '\t';
+ nlen--;
+ break;
+ case 'v':
+ *target++ = '\v';
+ nlen--;
+ break;
+ case 'b':
+ *target++ = '\b';
+ nlen--;
+ break;
+ case 'f':
+ *target++ = '\f';
+ nlen--;
+ break;
+ case '\\':
+ *target++ = '\\';
+ nlen--;
+ break;
case 'x':
- if (source+1 < end && isxdigit((int)(*(source+1)))) {
- numtmp[0] = *++source;
- if (source+1 < end && isxdigit((int)(*(source+1)))) {
- numtmp[1] = *++source;
- numtmp[2] = '\0';
- nlen-=3;
- } else {
- numtmp[1] = '\0';
- nlen-=2;
- }
- *target++=(char)strtol(numtmp, NULL, 16);
- break;
- }
- default:
- i=0;
- while (source < end && *source >= '0' && *source <= '7' && i<3) {
- numtmp[i++] = *source++;
- }
- if (i) {
- numtmp[i]='\0';
- *target++=(char)strtol(numtmp, NULL, 8);
- nlen -= i;
- source--;
- } else {
- *target++ = *source;
- nlen--;
- }
+ if (source + 1 < end && isxdigit ((int) (*(source + 1))))
+ {
+ numtmp[0] = *++source;
+ if (source + 1 < end && isxdigit ((int) (*(source + 1))))
+ {
+ numtmp[1] = *++source;
+ numtmp[2] = '\0';
+ nlen -= 3;
+ }
+ else
+ {
+ numtmp[1] = '\0';
+ nlen -= 2;
+ }
+ *target++ = (char) strtol (numtmp, NULL, 16);
+ break;
+ }
+ default:
+ i = 0;
+ while (source < end && *source >= '0' && *source <= '7' && i < 3)
+ {
+ numtmp[i++] = *source++;
+ }
+ if (i)
+ {
+ numtmp[i] = '\0';
+ *target++ = (char) strtol (numtmp, NULL, 8);
+ nlen -= i;
+ source--;
+ }
+ else
+ {
+ *target++ = *source;
+ nlen--;
+ }
}
- } else {
+ }
+ else
+ {
*target++ = *source;
}
}
- if (nlen != 0) *target='\0';
+ if (nlen != 0)
+ *target = '\0';
*len = nlen;
-}
+}
// ParseLine - gets a line, finds the commas, unescapes the value and adds it
// to the SOAP request
-void ParseLine(SoapCtx *ctx, char * Buffer, int LineLen) {
+void
+ParseLine (SoapCtx * ctx, char *Buffer, int LineLen)
+{
// if wrong line length, return
- if (LineLen <= 0) return;
-
+ if (LineLen <= 0)
+ return;
+
// alloc buffer for the line, copy it
- char * Line = (char *)malloc(LineLen + 1);
- memcpy(Line, Buffer, LineLen);
+ char *Line = (char *) malloc (LineLen + 1);
+ memcpy (Line, Buffer, LineLen);
Line[LineLen] = '\0';
-
+
// find first comma
- char * FirstCommaPos = strchr(Line, ',');
- if (!FirstCommaPos) return;
-
+ char *FirstCommaPos = strchr (Line, ',');
+ if (!FirstCommaPos)
+ return;
+
// find second comma
- char * SecondCommaPos = strchr(FirstCommaPos + 1, ',');
- if (!SecondCommaPos) return;
-
+ char *SecondCommaPos = strchr (FirstCommaPos + 1, ',');
+ if (!SecondCommaPos)
+ return;
+
// separate the three strings
FirstCommaPos[0] = '\0';
SecondCommaPos[0] = '\0';
-
+
// unescape
- int len = strlen(SecondCommaPos + 1);
- stripcslashes(SecondCommaPos + 1, &len);
-
+ int len = strlen (SecondCommaPos + 1);
+ stripcslashes (SecondCommaPos + 1, &len);
+
// add to the request
- soap_env_add_item(ctx->env, Line, FirstCommaPos + 1, SecondCommaPos
- + 1);
-
+ soap_env_add_item (ctx->env, Line, FirstCommaPos + 1, SecondCommaPos + 1);
+
// free the buffer
- free(Line);
+ free (Line);
}
-void printusage(char *FileName) {
- printf("Usage: %s [URL] [URN] [SOAPMETHOD]\n\n", FileName);
- printf("- [URL] is the url of the SOAP server.\n");
- printf("- [URN] is the namespace for the method/webservice.\n");
- printf("- [SOAPMETHOD] is the method to call.\n\n");
- printf("All commandline paramaters are mandatory.\n\n");
- printf("%s reads the parameters for the SOAPMETHOD from STDIN as a comma-separated list\n\n", FileName);
- printf("Each line is one parameter and has the following form:\n\n");
- printf("xsd:[TYPE],[PARAMETERNAME],[PARAMETERVALUE]\n\n");
- printf("- [TYPE] is a basic type for SOAP or a complex type defined by the WSDL.\n");
- printf("- [PARAMETERNAME] is the name for the parameter of the SOAPMETHOD on this line.\n");
- printf("- [PARAMETERVALUE] is the value for the parameter. N.B. \nand other escapes are recognized.\n");
+void
+printusage (char *FileName)
+{
+ printf ("Usage: %s [URL] [URN] [SOAPMETHOD]\n\n", FileName);
+ printf ("- [URL] is the url of the SOAP server.\n");
+ printf ("- [URN] is the namespace for the method/webservice.\n");
+ printf ("- [SOAPMETHOD] is the method to call.\n\n");
+ printf ("All commandline paramaters are mandatory.\n\n");
+ printf
+ ("%s reads the parameters for the SOAPMETHOD from STDIN as a comma-separated list\n\n",
+ FileName);
+ printf ("Each line is one parameter and has the following form:\n\n");
+ printf ("xsd:[TYPE],[PARAMETERNAME],[PARAMETERVALUE]\n\n");
+ printf
+ ("- [TYPE] is a basic type for SOAP or a complex type defined by the WSDL.\n");
+ printf
+ ("- [PARAMETERNAME] is the name for the parameter of the SOAPMETHOD on this line.\n");
+ printf
+ ("- [PARAMETERVALUE] is the value for the parameter. N.B. \nand other escapes are recognized.\n");
}
-int main(int argc, char *argv[]) {
+int
+main (int argc, char *argv[])
+{
SoapCtx *ctx, *ctx2;
herror_t err;
-
+
// check the parameter count
- if (argc != 4) {
- printusage(argv[0]);
+ if (argc != 4)
+ {
+ printusage (argv[0]);
return 1;
}
-
+
// init cSOAP client
- 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);
+ 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;
}
// create a SoapCtx object
- err = soap_ctx_new_with_method(argv[2], argv[3], &ctx);
- if (err != H_OK) {
- log_error4("%s():%s [%d]", herror_func(err),
- herror_message(err), herror_code(err));
- herror_release(err);
+ err = soap_ctx_new_with_method (argv[2], argv[3], &ctx);
+ if (err != H_OK)
+ {
+ log_error4 ("%s():%s [%d]", herror_func (err),
+ herror_message (err), herror_code (err));
+ herror_release (err);
return 1;
}
-
+
// create buffer
char Buffer[MAX_LINE_LENGTH];
int bytes_read, bytes_left;
-
+
// read from stdin until EOF
- while (!feof(stdin)) {
- bytes_read = fread(Buffer, 1, MAX_LINE_LENGTH, stdin);
+ while (!feof (stdin))
+ {
+ bytes_read = fread (Buffer, 1, MAX_LINE_LENGTH, stdin);
// pass each line into ParseLine
- char * EndLinePos;
- while (EndLinePos = strchr(Buffer, '\n')) {
- ParseLine(ctx, Buffer, EndLinePos - Buffer);
- memmove(Buffer, EndLinePos + 1, bytes_read - (EndLinePos -
- Buffer + 1));
+ char *EndLinePos;
+ while (EndLinePos = strchr (Buffer, '\n'))
+ {
+ ParseLine (ctx, Buffer, EndLinePos - Buffer);
+ memmove (Buffer, EndLinePos + 1, bytes_read - (EndLinePos -
+ Buffer + 1));
Buffer[bytes_read - (EndLinePos - Buffer + 1)] = '\0';
}
-
+
// no '\n' found in the whole Buffer, that means line's too
-long
- bytes_left = strlen(Buffer);
- if (bytes_left == MAX_LINE_LENGTH) {
- log_error1("The parameter line is too long.");
- herror_release(err);
- soap_ctx_free(ctx);
- return 1;
- }
+ long bytes_left = strlen (Buffer);
+ if (bytes_left == MAX_LINE_LENGTH)
+ {
+ log_error1 ("The parameter line is too long.");
+ herror_release (err);
+ soap_ctx_free (ctx);
+ return 1;
+ }
}
// invoke
- err = soap_client_invoke(ctx, &ctx2, argv[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);
+ err = soap_client_invoke (ctx, &ctx2, argv[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;
}
-
+
// print the result
- soap_xml_doc_print(ctx2->env->root->doc);
-
+ soap_xml_doc_print (ctx2->env->root->doc);
+
// free the objects
- soap_ctx_free(ctx2);
- soap_ctx_free(ctx);
+ soap_ctx_free (ctx2);
+ soap_ctx_free (ctx);
// destroy the cSOAP client
- soap_client_destroy();
-
+ soap_client_destroy ();
+
return 0;
}