#include "soapH.h" #include "calc.nsmap" char *server; int main(int argc, char **argv) { struct soap soap; double a, b, result; if (!(server = getenv("CALC_URL"))) { fprintf(stderr, "Requires: $ CALC_URL = \"http://the.host.name/the/path\"\n"); exit(0); } if (argc < 4) { fprintf(stderr, "Usage: [add|sub|mul|div|pow] num num\n"); exit(0); } printf("%s\n", server); soap_init(&soap); #ifdef SOAP_DEBUG soap_set_recv_logfile(&soap, "recv.log"); soap_set_sent_logfile(&soap, "sent.log"); soap_set_test_logfile(&soap, "test.log"); #endif a = strtod(argv[2], NULL); b = strtod(argv[3], NULL); switch (*argv[1]) { case 'a': soap_call_ns__add(&soap, server, "", a, b, &result); break; case 's': soap_call_ns__sub(&soap, server, "", a, b, &result); break; case 'm': soap_call_ns__mul(&soap, server, "", a, b, &result); break; case 'd': soap_call_ns__div(&soap, server, "", a, b, &result); break; case 'p': soap_call_ns__pow(&soap, server, "", a, b, &result); break; default: fprintf(stderr, "Unknown command\n"); exit(0); } if (soap.error) { soap_print_fault(&soap, stderr); exit(1); } else printf("result = %g\n", result); soap_destroy(&soap); soap_end(&soap); soap_done(&soap); return 0; }