4
Example calculator service client in C
6
Compilation in C (see samples/calc/calc.h):
8
> cc -o calcclient calcclient.c stdsoap2.c soapC.c soapClient.c
10
--------------------------------------------------------------------------------
11
gSOAP XML Web services tools
12
Copyright (C) 2001-2010, Robert van Engelen, Genivia, Inc. All Rights Reserved.
13
This software is released under one of the following two licenses:
14
GPL or Genivia's license for commercial use.
15
--------------------------------------------------------------------------------
18
This program is free software; you can redistribute it and/or modify it under
19
the terms of the GNU General Public License as published by the Free Software
20
Foundation; either version 2 of the License, or (at your option) any later
23
This program is distributed in the hope that it will be useful, but WITHOUT ANY
24
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
25
PARTICULAR PURPOSE. See the GNU General Public License for more details.
27
You should have received a copy of the GNU General Public License along with
28
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
29
Place, Suite 330, Boston, MA 02111-1307 USA
31
Author contact information:
32
engelen@genivia.com / engelen@acm.org
33
--------------------------------------------------------------------------------
34
A commercial use license is available from Genivia, Inc., contact@genivia.com
35
--------------------------------------------------------------------------------
43
const char server[] = "http://websrv.cs.fsu.edu/~engelen/calcserver.cgi";
45
int main(int argc, char **argv)
49
{ fprintf(stderr, "Usage: [add|sub|mul|div|pow] num num\n");
53
tandem_init(&soap, argv[0]);
54
socket_set_inet_name(argv[0]); /* ? See Tandem TCP/IP programming */
55
soap.send_timeout = 10; /* 10 sec */
56
soap.recv_timeout = 10; /* 10 sec */
57
a = strtod(argv[2], NULL);
58
b = strtod(argv[3], NULL);
61
soap_call_ns__add(&soap, server, "", a, b, &result);
64
soap_call_ns__sub(&soap, server, "", a, b, &result);
67
soap_call_ns__mul(&soap, server, "", a, b, &result);
70
soap_call_ns__div(&soap, server, "", a, b, &result);
73
soap_call_ns__pow(&soap, server, "", a, b, &result);
76
fprintf(stderr, "Unknown command\n");
80
{ soap_print_fault(&soap, stderr);
84
printf("result = %g\n", result);