Jump to content
Fivewin Brasil

Consultar Web Service


jfaguiar

Recommended Posts

Bom dia.

Estou tentando acessar o web service da Semasa para baixar uma tabela com lista de pontos de coletas e tá embassado rsrsrs

Este token funciona como um login name , de modo que se eu estiver utilizando um navegador, o insiro e me retorna um arquivo com essa lista.

Toda ajuda será bem vinda.

thanks

FUNCTION RecebeServicos()
Local oServerWS, cUrl
Local token := "ababababababababa"

cUrl:= "http://servicos.semasa.sp.gov.br/IServiceWebDRS/ServicosDRS.asmx?op=ReceberServicos" // Retornou 685 linhas
cSoap := "http://ws.semasa.sp.gov.br/ReceberServicos"

Try
    oServerWS := CreateObject( 'MSXML2.ServerXMLHTTP.5.0' )
Catch oError
    try
        oServerWS := CreateObject( 'MSXML2.ServerXMLHTTP.6.0' )
    catch oError
        try
            oServerWS := CreateObject("Microsoft.XMLHTTP")
        catch oError
            ? e:Description
            return nil
        end
    END
end

TRY
    //oServerWS:setOption( 3, 'CURRENT_USER\MY\'+token )
    oServerWS:open('GET', cUrl, .f.)
    oServerWS:setRequestHeader('SOAPAction', cSoap )
    oServerWS:setRequestHeader('Content-Type'    , 'text/xml; charset=utf-8')    // Obtém ou define o valor de cabeçalho de Content-type HTTP.
    oServerWS:send()
CATCH
    ? "Não conseguiu enviar solicitação para requisição dos dados do CNPJ"
    return .t.
END

// Verifica o status do request. Exibe erro se houver
IF oServerWS:Status != 200 // OK
    MsgStop( Alltrim(STR(oServerWS:Status)) +" - "+ oServerWS:StatusText , "Erro")
    RETURN NIL
ENDIF

WHILE oServerWS:readyState != 4
    oServerWS:waitForResponse(1000)
ENDDO

txt:=  oServerWS:responseText

? txt
Arq_1:=ALLTRIM(txt)

ARR0:=HB_ATokens( Arq_1, CHR(10) )

xbrowse(ARR0)

RETURN Nil
****************************************************************************
 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...