#include "Soap.h"

Soap& Soap::operator <(Soap&)
{

	return (*this);
}

string Soap::getEndPointUrl() const
{
	return m_EndPointUrl;
}

string Soap::getSoapAction() const
{
	return m_SoapAction;
}

string	Soap::getMethodName() const
{
	return m_MethodName;
}

string	Soap::getMethodNameSpace() const
{
	return m_MethodNameSpace;
}

/*NameValueMap* Soap::getMethodParameters()
{
	return &m_MethodParameters;
}*/

void Soap::setEndPointUrl(string endPointUrl)
{
	m_EndPointUrl = endPointUrl;
}

void Soap::setSoapAction(string soapAction)
{
	m_SoapAction = soapAction;
}

void Soap::setMethodName(string methodName)
{
	m_MethodName = methodName;
}

void Soap::setMethodNameSpace(string methodNameSpace)
{
	m_MethodNameSpace = methodNameSpace;
}

void Soap::setMethodParameterName(StringList& methodParameterName)
{
		m_MethodParameterName = methodParameterName;
}

void Soap::setMethodParameterValue(StringList& methodParameterValue)
{
		m_MethodParameterValue = methodParameterValue;
}

/*void Soap::setMethodParameters(NameValueMap& methodParameters)
{
		m_MethodParameters = methodParameters;
}*/

string Soap::getXmlData() const
{
	//The member variables are checked,if they contain data
	//approriate tags are inserted to convert them into XML
	//and the string value is returned
	int index = 0;
	string XmlData = "\n\t<soap>\n";

   	if(m_EndPointUrl.length())
		XmlData = XmlData + "\t\t<endpointurl>" +  m_EndPointUrl + "</endpointurl>\n";

	if(m_SoapAction.length())
		XmlData = XmlData + "\t\t<soapaction>" +  m_SoapAction + "</soapaction>\n";

    if(m_MethodNameSpace.length())
	{
		XmlData = XmlData + "\t\t<methodnamespace>" +  m_MethodNameSpace + "</methodnamespace>\n";
	}

	if(m_MethodName.length())
	{
		XmlData = XmlData + "\t\t<methodname name = " +  m_MethodName + ">\n";

			if(!m_MethodParameterName.empty()) {

			m_MethodParamIter  = m_MethodParameterName.begin();
			m_MethodParamVIter = m_MethodParameterValue.begin();

			while(m_MethodParamIter != m_MethodParameterName.end() && m_MethodParamIter != m_MethodParameterValue.end())
			{			
				XmlData = XmlData + "\t\t<parametername>"\
					+  m_MethodParamIter->c_str()\
					+ "</parametername>\n";				
				XmlData = XmlData + "\t\t<parametervalue>"\
					+  m_MethodParamVIter->c_str()\
					+ "</parametervalue>\n";				
			}
		}
	XmlData = XmlData + "\t</messagebody>";
	return XmlData;
	}
}