Skip to content

Instantly share code, notes, and snippets.

@jjesusfilho
Last active August 26, 2023 23:52
Show Gist options
  • Save jjesusfilho/aeb11a4384a1dc92d21830c551d1393f to your computer and use it in GitHub Desktop.
Save jjesusfilho/aeb11a4384a1dc92d21830c551d1393f to your computer and use it in GitHub Desktop.
tpus webservice
tpu_ultima_versao <- function(){
url1 <- "https://www.cnj.jus.br/sgt/sgt_ws.php"
corpo <- '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sgt="https://www.cnj.jus.br/sgt/sgt_ws.php">
<soapenv:Header/>
<soapenv:Body>
<sgt:getDataUltimaVersao/>
</soapenv:Body>
</soapenv:Envelope>'
httr::POST(url1, body = corpo) |>
httr::content() |>
xml2::xml_find_first("//return") |>
xml2::xml_text() |>
lubridate::dmy()
}
tpu_pesquisa_item_publico <- function(tabela, tipo, valor){
url1 <- "https://www.cnj.jus.br/sgt/sgt_ws.php"
corpo <- glue::glue('
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sgt="https://www.cnj.jus.br/sgt/sgt_ws.php">
<soapenv:Header/>
<soapenv:Body>
<sgt:pesquisarItemPublicoWS>
<tipoTabela>{tabela}</tipoTabela>
<tipoPesquisa>{tipo}</tipoPesquisa>
<valorPesquisa>{valor}</valorPesquisa>
</sgt:pesquisarItemPublicoWS>
</soapenv:Body>
</soapenv:Envelope>'
)
r1 <- httr::POST(url1, body = corpo)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment