En realidad hay muchos ejemplos y he usado uno de ellos. Pero funciona de forma asíncrona, quiero decir que no está esperando la función a la que llamé para finalizar.¿Cómo llamar al servicio web utilizando vbscript (sincrónico)?
function ProcessSend()
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.4.0")
Set oXMLDoc = CreateObject("MSXML2.DOMDocument")
oXMLHTTP.onreadystatechange = getRef("HandleStateChange")
strEnvelope = "callNo="&callNo&"&exp="&exp
call oXMLHTTP.open("POST","http://localhost:11883/ServiceCall.asmx/"&posFirm,true)
call oXMLHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
call oXMLHTTP.send(strEnvelope)
end function
Sub HandleStateChange
if(oXMLHTTP.readyState = 4) then
dim szResponse: szResponse = oXMLHTTP.responseText
call oXMLDoc.loadXML(szResponse)
if(oXMLDoc.parseError.errorCode <> 0) then
'call msgbox("ERROR")
response = oXMLHTTP.responseText&" "&oXMLDoc.parseError.reason
'call msgbox(oXMLDoc.parseError.reason)
else
response = oXMLDoc.getElementsByTagName("string")(0).childNodes(0).text
end if
end if
End Sub
Llamo a la función ProcessSend en una función javascript. Se conecta al servicio web y devuelve la variable "respuesta". Pero mi función javascript no espera el resultado de la función ProcessSend. ¿Cómo puedo hacer que sea sincrónico?
¿Estás en un navegador o en Windows Scripting ¿Anfitrión? Si está en un navegador, ¿por qué usa la mitad de JavaScript, la mitad de VBScript? – Tomalak