﻿
function CreateWSSoapMessage(methodName,params)
{
    var rtnValue = BeginSoapMessage();
    rtnValue += BuildMethodElement(methodName,params);
    rtnValue += EndSoapMessage();
    return rtnValue;
    
}
function CreateWSRequest() 
{
  var request = false;
  try 
  {
    request = new XMLHttpRequest();
  } 
  catch (trymicrosoft) 
  {
    try 
    {
        request = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (othermicrosoft) 
    {
        try 
        {
            request = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (failed) 
        {
            request = false;
        }
    }
  }
  if (!request)
    alert("Error initializing XMLHttpRequest!");

	
  return request;
}
function BeginSoapMessage()
{
    var soapMess = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; 
    soapMess += "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "; 
    soapMess += "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "; 
    soapMess += "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"; 
    soapMess += "<soap:Body>";
    return soapMess;
}
function BuildSoapParameter(name, value)
{
    return "<" + name + ">" + value + "</" + name + ">";
}

function BuildMethodElement(methodName, params)
{
    var rtnValue = "<" + methodName + " xmlns=\"http://www.650North.com/\">";
    
    for(var i = 0; i < params.length; i++)
      rtnValue+= BuildSoapParameter(params[i][0],params[i][1]);
        
    return rtnValue += "</" + methodName + ">";
}

function EndSoapMessage()
{
    return "</soap:Body></soap:Envelope>"; 
}
