client.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   file : $URL: https://frepple.svn.sourceforge.net/svnroot/frepple/tags/0.9.1/modules/webservice/client.cpp $
00003   version : $LastChangedRevision: 1656 $  $LastChangedBy: jdetaeye $
00004   date : $LastChangedDate: 2012-03-27 19:05:34 +0200 (Tue, 27 Mar 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 Lesser General Public License as published   *
00013  * by the Free Software Foundation; either version 2.1 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 GNU Lesser *
00019  * General Public License for more details.                                *
00020  *                                                                         *
00021  * You should have received a copy of the GNU Lesser General Public        *
00022  * License along with this library; if not, write to the Free Software     *
00023  * Foundation Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,*
00024  * USA                                                                     *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00028 #include "soapfreppleProxy.h"
00029 #include "frepple.nsmap"
00030 
00031 
00032 int main(int argc, char *argv[])
00033 {
00034   if  (argc <= 2 || (strcmp(argv[1],"get") && strcmp(argv[1],"post")))
00035   {
00036     std::cout << "Usage:" << std::endl;
00037     std::cout << "  " << argv[0] << " get <demand name>" << std::endl << std::endl;
00038     std::cout << "  " << argv[0] << " post <data>" << std::endl << std::endl;
00039     return 1;
00040   }
00041 
00042   frepple svc;
00043 
00044   // Return demand information
00045   if (!strcmp(argv[1],"get"))
00046   {
00047     struct frepple__DemandInfoResponse result;
00048     if (svc.frepple__demand(argv[2], result) == SOAP_OK)
00049     {
00050       std::cout << "Name: " << result._return.name << std::endl
00051           << "Item: " << result._return.item << std::endl
00052           << "Quantity: " << result._return.quantity << std::endl
00053           << "Due date: " << asctime(gmtime(&result._return.due))
00054           << "Priority: " << result._return.priority << std::endl;
00055     }
00056     else
00057       soap_print_fault(svc.soap, stderr);
00058   }
00059 
00060   // Post new XML data
00061   if (!strcmp(argv[1],"post"))
00062   {
00063     struct frepple__PostResponse result;
00064     if (svc.frepple__post(argv[2], result) == SOAP_OK)
00065     {
00066       std::cout << "answer: " << result._return << std::endl;
00067     }
00068     else
00069       soap_print_fault(svc.soap, stderr);
00070   }
00071 
00072   return 0;
00073 }
00074 

Documentation generated for frePPLe by  doxygen