1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br
rhemati

Ler webservice REST 1.0

Ler webservice REST

  1. rhemati
    Pessoal, bom dia.

    Segue um código para ler webservice REST.

    Código:
    /* Variaveis da consulta ao webservice */
    DEFINE VARIABLE http     AS COM-HANDLE.
    DEFINE VARIABLE strURL   AS CHARACTER.
    DEFINE VARIABLE strRET   AS CHARACTER.
    DEFINE VARIABLE iNumEntries AS INTEGER NO-UNDO.
    DEFINE VARIABLE iLoop AS INTEGER NO-UNDO.
    
    assign  strURL  =   'http://www4.bcb.gov.br/pec/taxas/batch/cotacaomoedas.asp?id=txtodas'.
    
    /* Le a informação do Retorno */
    CREATE "MSXML2.XMLHTTP.3.0" http NO-ERROR.
    http:OPEN("GET", strURL, FALSE).
    http:setRequestHeader("Translate", "f").
    
    /*http:setRequestHeader("Content-Type", "text/xml"). */
    http:setRequestHeader("Depth", "0").
    http:SEND() NO-ERROR.
    
    /* Armazena o retorno */
    strRET = http:responseText.
    
    MESSAGE strRET
        VIEW-AS ALERT-BOX INFO BUTTONS OK.
    
    /* Se tiver erro, retorna o erro */
    if strRET begins "Houve erro" then do:
       /* Trata */
    end.
    else do:
       /* Trata o retorno */
    end.
    

Recent Reviews

  1. rafael.andrade
    rafael.andrade
    5/5,
    Version: 1.0
    A URL não funcionava, mas peguei outra e o código funciona bem
    1. rhemati
      Author's Response
      Olá, bom dia. Tudo bem. Você lembra qual URL utilizou? Porque eu acredito que a minha URL que está no código não funcionou , por estar muito antiga.
      Você tem em mãos aí a nova URL que utilizou? Podes compartilhar por gentileza?
      Obrigado. Abraço.
      Cristiano Amaral