Last active
January 9, 2018 08:30
-
-
Save fwuensche/a203380765938ed67557 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function getValor(seriesId As Integer, refDate As Date) | |
Dim sURL As String | |
Dim sEnv As String | |
Dim xmlhtp As New MSXML2.XMLHTTP60 | |
Dim xmlDoc As New DOMDocument60 | |
sURL = "https://www3.bcb.gov.br/wssgs/services/FachadaWSSGS?method=getValor" | |
sEnv = "<?xml version=""1.0"" encoding=""utf-8""?>" | |
sEnv = sEnv & "<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">" | |
sEnv = sEnv & " <soapenv:Body>" | |
sEnv = sEnv & " <getValor xmlns=""https://www3.bcb.gov.br/wssgs/services/FachadaWSSGS"">" | |
sEnv = sEnv & " <codigoSerie>" & seriesId & "</codigoSerie>" | |
sEnv = sEnv & " <data>" & refDate & "</data>" | |
sEnv = sEnv & " </getValor>" | |
sEnv = sEnv & " </soapenv:Body>" | |
sEnv = sEnv & "</soapenv:Envelope>" | |
With xmlhtp | |
.Open "post", sURL, False | |
.setRequestHeader "Host", "https://www3.bcb.gov.br/sgspub/JSP/sgsgeral/FachadaWSSGS.wsdl" | |
.setRequestHeader "Content-Type", "text/xml; charset=utf-8" | |
.setRequestHeader "soapAction", "https://www3.bcb.gov.br/wssgs/services/FachadaWSSGS/getValor" | |
.setRequestHeader "Accept-encoding", "zip" | |
.send sEnv | |
xmlDoc.LoadXML .responseText | |
End With | |
Set NodeList = xmlhtp.responseXML.SelectSingleNode("//multiRef") | |
getValor = NodeList.Text * 1 | |
End Function | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment