/*
*
* ProLinga-Soap
*
* Copyright (C) 2002-2008 Xobas Software.
* All rights reserved.
*
* This file is part of ProLinga-Soap.
*
* ProLinga-Soap 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-Soap 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-Soap. If not, see .
*
* More information is available at the following addresses:
*
* Website : http://www.prolinga.org
*
* Email : prolinga-list@prolinga.org
*
*
*/
#include "SoapCommon.h"
#include "SoapConfig.hpp"
#include "soapH.h"
#include
PlSoapClient::PlSoapClient()
{
/* Init */
}
PlSoapClient::~PlSoapClient()
{
/* Free */
}
xmlDocPtr PlSoapClient::soapCall(const xmlDocPtr docRequest, const char *serviceEndPoint, const int compression)
{
xmlDocPtr docResponse;
xmlNodePtr curDoc = NULL;
xmlBufferPtr bufDoc;
struct soap gSoapEnv;
XML request, response;
/* Dump request to SOAP string */
bufDoc = xmlBufferCreate();
curDoc = xmlDocGetRootElement(docRequest);
xmlNodeDump(bufDoc, docRequest, curDoc, 0, 1);
request = (XML)xmlBufferContent(bufDoc);
/* Init soap environment */
soap_init(&gSoapEnv);
gSoapEnv.encodingStyle = NULL;
/* Set compression */
if (compression > 0)
{
soap_set_omode(&gSoapEnv, SOAP_ENC_ZLIB);
/* compression 9 = best */
gSoapEnv.z_level = compression;
}
else
soap_clr_omode(&gSoapEnv, SOAP_ENC_ZLIB);
/* Process call */
if (soap_call_ns1__GetProLingaDocument(&gSoapEnv, serviceEndPoint, SOAP_ACTION, request, response) != SOAP_OK)
{
/* Generate generic error */
response = new char[1024];
sprintf(response, "\n\t\n\t\t\n\t\t\t\n\t\t\t\tError\n\t\t\t\tCan not contact Soap Host\n\t\t\t\t%s\n\t\t\t\n\t\t\n\t\n", (const char *)gSoapEnv.fault->faultstring);
}
/* DEBUG */
//printf("Compression ratio: %f%% (in) %f%% (out)\n", 100*gSoapEnv.z_ratio_out, 100*gSoapEnv.z_ratio_in);
/* Load response into xml doc */
docResponse = xmlParseMemory(response, strlen(response));
/* Clean up */
// Clean up now takes place within gsoap engine
//delete response;
/* Return */
return docResponse;
}