Ejemplo sin parámetros
var serverUrl = "http://localhost/DuplicateDetection/Service1.asmx";
var xmlObj = new ActiveXObject("Msxml2.DOMDocument");
var sXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
sXml += "<soap:Envelope "
sXml += "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ";
sXml += "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" ";
sXml += "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
sXml += "<soap:Body>";
sXml += "<Hola xmlns=\"http://SRVGYECRM/MSCRMCustomer/\" />";
//sXml = sXml + "<entity>" + crmForm.ObjectId + "</entity>";
//sXml += "</NotifyEnter></soap:Body></soap:Envelope>";
sXml += "</soap:Body></soap:Envelope>";
// Try to parse the XML string into DOM object
xmlObj.loadXML(sXml);
// Instantiate at connection to the Web service and call the get method.
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("Post", serverUrl , false);
xmlhttp.setRequestHeader("Host", "localhost");
xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
//xmlhttp.setRequestHeader("Content-Lenght", "length" );
xmlhttp.setRequestHeader("SOAPAction", "http://SRVGYECRM/MSCRMCustomer/Hola");
xmlhttp.send(xmlObj.xml);
var xmlResponse = xmlhttp.responseXML;
var result = xmlResponse.selectSingleNode("soap:Envelope/soap:Body/HolaResponse/HolaResult").text;
//window.document.all.firstname.innerText= xmlhttp.responseText;
//alert(xmlhttp.responseText);
alert(result);
Ejemplo con parámetros
var serverUrl = "http://localhost/DuplicateDetection/Service1.asmx";
var xmlObj = new ActiveXObject("Msxml2.DOMDocument");
var sXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
sXml += "<soap:Envelope "
sXml += "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ";
sXml += "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" ";
sXml += "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
sXml += "<soap:Body>";
sXml += "<CheckDuplicateContactEmail xmlns=\"http://SRVGYECRM/MSCRMCustomer/\" >";
sXml += "<objectguid>null</objectguid>";
sXml += "<emailaddress1>" +window.document.all.emailaddress1.value + "</emailaddress1>";
sXml += "</CheckDuplicateContactEmail></soap:Body></soap:Envelope>";
// Try to parse the XML string into DOM object
xmlObj.loadXML(sXml);
// Instantiate at connection to the Web service and call the get method.
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("Post", serverUrl , false);
xmlhttp.setRequestHeader("Host", "localhost");
xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlhttp.setRequestHeader("SOAPAction", "http://SRVGYECRM/MSCRMCustomer/CheckDuplicateContactEmail");
xmlhttp.send(xmlObj.xml);
var xmlResponse = xmlhttp.responseXML;
//var result = xmlResponse.selectSingleNode("soap:Envelope/soap:Body/CheckDuplicateContactEmailResponse/CheckDuplicateContactEmailResult").text;
var inicio =0;
var fin=0;
cadenainicio="<CheckDuplicateContactEmailResult>";
cadenafin="</CheckDuplicateContactEmailResult>";
var cadena = xmlResponse.xml;
inicio = cadena.indexOf(cadenainicio)+ cadenainicio.length;
fin = cadena.indexOf(cadenafin,inicio);
cadena = cadena.substring(inicio,fin);
//alert(result);
if(cadena=="true")
event.returnValue = false;
No hay comentarios:
Publicar un comentario