A continuacion pongo mi codigo esperando les sirva para este proposito o cualquier otro que requiera el uso de webservices:
Código ASP:
Ver original
<% 'Parámetros de la función 'este es el texto que se envia como peticion al webservice cadenaXML = "<?xml version=""1.0"" encoding=""utf-8""?>" & vbCrLf cadenaXML = cadenaXML & "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" " cadenaXML = cadenaXML & "xmlns:xsd=""http://www.w3.org/2001/XMLSchema""" cadenaXML = cadenaXML & " xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">" & vbCrLf cadenaXML = cadenaXML & " <soap12:Body>" & vbCrLf cadenaXML = cadenaXML & " <ConversionRate xmlns=""http://www.webserviceX.NET/"">" & vbCrLf cadenaXML = cadenaXML & " <FromCurrency>USD</FromCurrency>" & vbCrLf cadenaXML = cadenaXML & " <ToCurrency>MXN</ToCurrency>" & vbCrLf cadenaXML = cadenaXML & " </ConversionRate>" & vbCrLf cadenaXML = cadenaXML & "</soap12:Body>" & vbCrLf cadenaXML = cadenaXML & "</soap12:Envelope>" & vbCrLf Function LeeXml(responseText) Dim xmlResponse Dim xnodelist Dim indicadores indicadores = "" If Len(responseText) <> 0 Then Set xmlResponse = CreateObject("MSXML2.DOMDocument") xmlResponse.async = false xmlResponse.loadXml responseText Set xnodelist = xmlResponse.documentElement.selectNodes("/soap12:Envelope/soap12:Body/ConversionRate/ConversionRateResponse") 'asignamos el valor resultante a la variable "valor" valor = formatcurrency(cdbl(xmlResponse.getElementsByTagName("ConversionRateResult").Item(0).Text),2) else valor = "NADA QUE LEER" End If LeeXml = valor End Function 'funcion para el llamado al webservice Function InvocarWebService (strSoap, strSOAPAction, strURL, ByRef xmlResponse) Dim xmlhttp Dim blnSuccess Set xmlhttp = server.CreateObject("WinHttp.WinHttpRequest.5.1") xmlhttp.Open "POST", strURL xmlhttp.setRequestHeader "Man", "POST " & strURL & " HTTP/1.1" xmlhttp.setRequestHeader "Content-Type", "application/soap+xml; charset=utf-8" call xmlhttp.send(strSoap) If xmlhttp.Status = 200 Then blnSuccess = True Else blnSuccess = False End If xmlResponse = xmlhttp.ResponseText InvocarWebService = blnSuccess Set xmlhttp = Nothing End Function strSOAPAction = "http://www.webserviceX.NET/ConversionRate" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>DOLAR - PESO</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <% Dim xmlResponse If InvocarWebService (cadenaXML, strSOAPAction, "http://www.webservicex.net/CurrencyConvertor.asmx?WSDL", xmlResponse) Then Response.Write(LeeXml(xmlResponse)) Else Response.Write "*** Ha ocurrido un Error ***" & "<br>" & xmlResponse End If Set xmlResponse = Nothing %> </body> </html>
Espero les sirva
Pueden ver el resultado en http://www.creandowebs.com/lab/ws.asp
Y otras opciones para tomar el valor del dolar en: http://javimata.blogspot.com/