client.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   file : $URL: http://svn.code.sf.net/p/frepple/code/trunk/modules/webservice/client.cpp $
00003   version : $LastChangedRevision: 1713 $  $LastChangedBy: jdetaeye $
00004   date : $LastChangedDate: 2012-07-18 11:46:01 +0200 (Wed, 18 Jul 2012) $
00005  ***************************************************************************/
00006 
00007 /***************************************************************************
00008  *                                                                         *
00009  * Copyright (C) 2007-2012 by Johan De Taeye, frePPLe bvba                 *
00010  *                                                                         *
00011  * This library is free software; you can redistribute it and/or modify it *
00012  * under the terms of the GNU Affero General Public License as published   *
00013  * by the Free Software Foundation; either version 3 of the License, or    *
00014  * (at your option) any later version.                                     *
00015  *                                                                         *
00016  * This library is distributed in the hope that it will be useful,         *
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
00019  * GNU Affero General Public License for more details.                     *
00020  *                                                                         *
00021  * You should have received a copy of the GNU Affero General Public        *
00022  * License along with this program.                                        *
00023  * If not, see <http://www.gnu.org/licenses/>.                             *
00024  *                                                                         *
00025  ***************************************************************************/
00026 
00027 #include "soapfreppleProxy.h"
00028 #include "frepple.nsmap"
00029 
00030 
00031 int main(int argc, char *argv[])
00032 {
00033   if  (argc <= 2 || (strcmp(argv[1],"get") && strcmp(argv[1],"post")))
00034   {
00035     std::cout << "Usage:" << std::endl;
00036     std::cout << "  " << argv[0] << " get <demand name>" << std::endl << std::endl;
00037     std::cout << "  " << argv[0] << " post <data>" << std::endl << std::endl;
00038     return 1;
00039   }
00040 
00041   frepple svc;
00042 
00043   // Return demand information
00044   if (!strcmp(argv[1],"get"))
00045   {
00046     struct frepple__DemandInfoResponse result;
00047     if (svc.frepple__demand(argv[2], result) == SOAP_OK)
00048     {
00049       std::cout << "Name: " << result._return.name << std::endl
00050           << "Item: " << result._return.item << std::endl
00051           << "Quantity: " << result._return.quantity << std::endl
00052           << "Due date: " << asctime(gmtime(&result._return.due))
00053           << "Priority: " << result._return.priority << std::endl;
00054     }
00055     else
00056       soap_print_fault(svc.soap, stderr);
00057   }
00058 
00059   // Post new XML data
00060   if (!strcmp(argv[1],"post"))
00061   {
00062     struct frepple__PostResponse result;
00063     if (svc.frepple__post(argv[2], result) == SOAP_OK)
00064     {
00065       std::cout << "answer: " << result._return << std::endl;
00066     }
00067     else
00068       soap_print_fault(svc.soap, stderr);
00069   }
00070 
00071   return 0;
00072 }
00073 

Documentation generated for frePPLe by  doxygen