
function SoapRequest(functionName, myServer) {
// loads an xml object. It must be proper xml or the call will fail

	this.myFunctionName=functionName;
	this.myServer = myServer || GSCCCA.defaultURL
	
	this.myEnvelope; 
	this.functionBody;
		
	this.addArgument=addArgument_;
	this.exec=exec_;
	this.initSoapEnvelope=initSoapEnvelope_;
	
	function initSoapEnvelope_() {
	var soapHeader=	//'<?xml version="1.0" encoding="utf-8"?>' + 
					"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + 
						"<soap:Body>" +
							"<" + this.myFunctionName + " xmlns=\"" + GSCCCA.mySoapNamespace + "\">" +
							"</" + this.myFunctionName + ">" +
						"</soap:Body>" + 
					"</soap:Envelope>";
		try {		
			this.myEnvelope.loadXML(soapHeader);
	//		this.functionBody = this.myEnvelope.createDocumentFragment();
//			this.functionBody = this.myEnvelope.createElementNS(GSCCCA.mySoapNamespace,this.myFunctionName);
//			this.myEnvelope.getElementsByTagName("Body")[0].appendChild(this.functionBody);
//			alert(this.myEnvelope.xml);
		}
		catch (e) {
			alert("Error in initEnvelope: " + e.message);
		}
	}
	
	function addArgument_(argName, argValue) {
		var aNewElement;
		var bodyElement;
	
		argValue= argValue || null;
//		if (document.captureEvents) 
			aNewElement = this.myEnvelope.createElementNS(GSCCCA.mySoapNamespace, argName);
//		else
//			aNewElement = this.myEnvelope.createNode(1,argName,GSCCCA.mySoapNamespace);
			if(!argValue.replace) {
				aNewElement.appendChild(argValue);
				bodyElement = this.myEnvelope.getElementsByTagName(this.myFunctionName)[0];
//erroring on line below in IE 5.5
				bodyElement.appendChild(aNewElement);
//				this.functionBody.appendChild(aNewElement);
			} else {
				aNewElement = this.myEnvelope.createTextNode(argValue);
				this.addArgument(argName, aNewElement);
			}
	}
	
	function exec_() {
		xmlhttp = XmlHttp.create();
//alert(xmlhttp.readyState);
		//var xmlhttp = new xmlHTTP();
		xmlhttp.open("POST", this.myServer, false);
		xmlhttp.setRequestHeader("SOAPAction", GSCCCA.mySoapNamespace + this.myFunctionName ); 
		//xmlhttp.setRequestHeader("SOAPAction",this.myFunctionName ); 
		xmlhttp.setRequestHeader("Content-Type", "text/xml");
//alert("requesting: " + this.myEnvelope.xml());



		var xmlHead;
		var newString = '';
		xmlHead = this.myEnvelope.xml();
		var i = 0;
		while (i < xmlHead.length) {
			newString += xmlHead.substr(i, 75) + '\n';
			i += 75;	
		}
		newString += xmlHead.substr(i);
		//newString = xmlHead.substr(0, 20) + '\n' + xmlHead.substr(20);
		//alert(newString);


		xmlhttp.send(this.myEnvelope.xml());
//alert(xmlhttp.responseXML.xml);
		while (xmlhttp.readyState != 4);
		try {		
			return xmlhttp.responseXML;
		} catch (e) {
			alert( "exec failed: " + xmlhttp.responseXML.text);
		}
	}

	this.myEnvelope = new XmlDoc();
	
	this.initSoapEnvelope();
	

}

function Transport() {
	var xmlhttp = XmlHttp.create();
	
	this.getXmlFile = function(sFilename) {
		xmlhttp.open("GET", sFilename, false);
		xmlhttp.send(null);
		var d = new XmlDoc();
		d.loadXML(xmlhttp.responseText);
		return d;
	}
	
	this.getRawFile = function(sFilename) {
		xmlhttp.open("GET", sFilename, false);
		xmlhttp.send(null);
		return xmlhttp.responseText;
	}

}

