1/* 2 calcclient.cpp 3 4 Example calculator service client in C++ 5 6 soapcpp2 -i calc.h 7 cc -o calcclient calcclient.cpp stdsoap2.cpp soapC.cpp soapcalcProxy.cpp 8 9-------------------------------------------------------------------------------- 10gSOAP XML Web services tools 11Copyright (C) 2001-2008, Robert van Engelen, Genivia, Inc. All Rights Reserved. 12This software is released under one of the following two licenses: 13GPL or Genivia's license for commercial use. 14-------------------------------------------------------------------------------- 15GPL license. 16 17This program is free software; you can redistribute it and/or modify it under 18the terms of the GNU General Public License as published by the Free Software 19Foundation; either version 2 of the License, or (at your option) any later 20version. 21 22This program is distributed in the hope that it will be useful, but WITHOUT ANY 23WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 24PARTICULAR PURPOSE. See the GNU General Public License for more details. 25 26You should have received a copy of the GNU General Public License along with 27this program; if not, write to the Free Software Foundation, Inc., 59 Temple 28Place, Suite 330, Boston, MA 02111-1307 USA 29 30Author contact information: 31engelen@genivia.com / engelen@acm.org 32-------------------------------------------------------------------------------- 33A commercial use license is available from Genivia, Inc., contact@genivia.com 34-------------------------------------------------------------------------------- 35*/ 36 37#include "soapcalcProxy.h" 38#include "calc.nsmap" 39 40const char server[] = "http://websrv.cs.fsu.edu/~engelen/calcserver.cgi"; 41 42int main(int argc, char **argv) 43{ if (argc < 4) 44 { fprintf(stderr, "Usage: [add|sub|mul|div|pow] num num\n"); 45 exit(0); 46 } 47 double a, b, result; 48 a = strtod(argv[2], NULL); 49 b = strtod(argv[3], NULL); 50 calcProxy calc; 51 calc.soap_endpoint = server; 52 switch (*argv[1]) 53 { case 'a': 54 calc.add(a, b, &result); 55 break; 56 case 's': 57 calc.sub(a, b, &result); 58 break; 59 case 'm': 60 calc.mul(a, b, &result); 61 break; 62 case 'd': 63 calc.div(a, b, &result); 64 break; 65 case 'p': 66 calc.pow(a, b, &result); 67 break; 68 default: 69 fprintf(stderr, "Unknown command\n"); 70 exit(0); 71 } 72 if (calc.error) 73 calc.soap_stream_fault(std::cerr); 74 else 75 printf("result = %g\n", result); 76 return 0; 77} 78 79