/* * * ProLinga-Run * * Copyright (C) 2002-2008 Xobas Software. * All rights reserved. * * This file is part of ProLinga-Run. * * ProLinga-Run is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ProLinga-Run is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ProLinga-Run. If not, see . * * More information is available at the following addresses: * * Website : http://www.prolinga.org * * Email : prolinga-list@prolinga.org * * */ #include "RunCommon.h" #include #include "RunConfig.hpp" int main (int argc, char* argv[]) { xmlDocPtr docIn, docOut; xmlNodePtr curOut; xmlBufferPtr bufOut; char *response, serviceEndpoint[255], *clientHost; int clientPort, clientCompressionLevel; FILE *fpOut; PlSoapClient sclient; ConfigRunPtr confRunPtr; if (argc != 3) { printf("Usage: %s \n", argv[0]); exit (1); } /* Get Config */ confRunPtr = new ConfigRun(DEF_CONFIG_FILE); /* Get service end point */ clientHost = confRunPtr->getStringValue("ClientHost", DEF_CLIENT_HOST); clientPort = confRunPtr->getNumberValue("ClientPort", DEF_CLIENT_PORT); sprintf(serviceEndpoint, "%s:%d", clientHost, clientPort); /* Get client compression level */ clientCompressionLevel = confRunPtr->getNumberValue("ClientCompressionLevel", DEF_CLIENT_COMP_LEVEL); /* Don't need Config any longer */ delete confRunPtr; /* Load request file */ docIn = xmlParseFile(argv[1]); if (docIn == NULL) { printf("Error reading doc.\n"); exit (1); } /* Process Request */ docOut = sclient.soapCall(docIn, serviceEndpoint, clientCompressionLevel); /* Dump response as string */ bufOut = xmlBufferCreate(); curOut = xmlDocGetRootElement(docOut); xmlNodeDump(bufOut, docOut, curOut, 0, 1); //printf("%s\n", (char *)xmlBufferContent(bufOut)); response = (char *)xmlBufferContent(bufOut); /* Write response to file */ fpOut = fopen(argv[2], "w"); fprintf(fpOut, "%s", response); fclose(fpOut); /* Clean up */ xmlBufferFree(bufOut); xmlFreeDoc(docOut); xmlFreeDoc(docIn); xmlCleanupParser(); /* Return */ return 0; }