edutraini Posted April 8, 2022 Report Share Posted April 8, 2022 Bom dia Pessoal EU uso essa rotina que pega aqui no forum que pega os dados do cliente na receita e alguns computadores esta dando erro e outros vao normal Alguem poderia dar uma dica Obrigado Error description: Error MSXML2.serverxmlhttp.6.0/3 disp_e_membernotfound: send Function GetCNPJ(cOnde,cCnpj,cNome,cEndereco,cNro,cComplemento,cBairro,cCidade,cEstado,cCep,cTelefone) Local oServerWS, cUrl, aArray, x1, erro if len(alltrim(cCnpj))<14 msginfo("Somente Pessoa Juridica para consultar os dados na Receita !!!","Atenção ") retur(.t.) endif cUrl := "https://www.receitaws.com.br/v1/cnpj/"+cCnpj Try oServerWS := CreateObject( 'MSXML2.ServerXMLHTTP.6.0' ) Catch erro ? erro:Description return nil End oServerWS:open('GET', cUrl, .f.) oServerWS:setRequestHeader("Content-Type", "text/xml; charset=utf-8") oServerWS:send() If oServerWS:Status != 200 MsgStop(Alltrim(STR(oServerWS:Status))+" - "+oServerWS:StatusText , "Erro") Return nil Endif While oServerWS:readyState != 4 oServerWS:WaitForResponse(1000) End x1 := hb_jsondecode( oServerWS:responseText, @aArray ) If aArray == nil MsgStop("Erro ao retornar os dados. Tente novamente.") Return nil Endif If aArray['status'] != 'OK' MsgStop(aArray['message'], "Erro") Return nil Endif MsgInfo("NOME: "+Alltrim(aArray['nome'])+CRLF+; "FANTASIA: "+Alltrim(aArray['fantasia'])+CRLF+; "ENDEREÇO: "+Alltrim(aArray['logradouro'])+", "+Alltrim(aArray['numero'])+" "+Alltrim(aArray['complemento'])+CRLF+; "BAIRRO: "+Alltrim(aArray['bairro'])+" CEP: "+Alltrim(aArray['cep'])+CRLF+; "CIDADE: "+Alltrim(aArray['municipio'])+"-"+Alltrim(aArray['uf'])+CRLF+; "TELEFONE: "+Alltrim(aArray['telefone'])+CRLF+CRLF+; "NATUREZA JURÍDICA: "+Alltrim(aArray['natureza_juridica'])+CRLF+; "TIPO: "+Alltrim(aArray['tipo'])+CRLF+; "SITUAÇÃO: "+Alltrim(aArray['situacao'])+CRLF+; "DATA SITUAÇÃO: "+Alltrim(aArray['data_situacao'])+CRLF+; "ULTIMA ATUALIZAÇÃO: "+Alltrim(aArray['ultima_atualizacao']), "CNPJ CONSULTA") cNome = alltrim(aArray['nome']) cEndereco = alltrim(aArray['logradouro']) cNro = Alltrim(aArray['numero']) cNro = StrTran(cNro,".","",1,10) cNro = val(cNro) cComplemento = alltrim(aArray['complemento']) cBairro = alltrim(aArray['bairro']) cCep = Alltrim(aArray['cep']) cCidade = Alltrim(aArray['municipio']) cEstado = Alltrim(aArray['uf']) cTelefone = Alltrim(aArray['telefone']) * if cOnde = "T" cEndereco = cEndereco+" "+alltrim(str(cNro,10))+" "+alltrim(cComplemento) Endif cNome = cNome+spac(100-len(cNome)) cEndereco = cEndereco+spac(100-len(cEndereco)) cComplemento = cComplemento+spac(100-len(cComplemento)) cBairro = cBairro+spac(100-len(cBairro)) cCep = cCep+spac(10-len(cCep)) cCep := StrTran(cCep,".","",1,10) cCidade = cCidade+spac(50-len(cCidade)) cTelefone = cTelefone+spac(20-len(cTelefone)) Return nil Quote Link to comment Share on other sites More sharing options...
kapiaba Posted April 8, 2022 Report Share Posted April 8, 2022 I am phoda. kkkkkkkk - Modificado by kapiabafwh@gmail.com - 08/04/2022. #Include "FiveWin.ch" FUNCTION Main() LOCAL cOnde, cCnpj, cNome, cEndereco, cNro, cComplemento, cBairro, cCidade, ; cEstado, cCep, cTelefone cOnde := SPACE(10) cCnpj := "48209381000140" // TEST ONLY cNome := SPACE(50) cEndereco := SPACE(40) cNro := SPACE(10) cComplemento := SPACE(10) cBairro := SPACE(20) cCidade := SPACE(30) cEstado := SPACE(02) cCep := SPACE(08) cTelefone := SPACE(17) GetCNPJ( cOnde, cCnpj, cNome, cEndereco, cNro, cComplemento, cBairro, cCidade, cEstado, cCep, cTelefone ) RETURN NIL FUNCTION GetCNPJ( cOnde, cCnpj, cNome, cEndereco, cNro, cComplemento, cBairro, cCidade, cEstado, cCep, cTelefone ) LOCAL oServerWS, cUrl, aArray, x1, erro, oADODBStream IF Len( AllTrim( cCnpj ) ) < 14 MsgInfo( "Somente Pessoa Juridica para consultar os dados na Receita !!!", "Atenção " ) RETURN( .T. ) ENDIF cUrl := "https://www.receitaws.com.br/v1/cnpj/" + cCnpj #ifdef __XHARBOUR__ // PERFEITO COM XHARBOUR( I Like ) Try Try oServerWS := CreateObject( 'MSXML2.XMLHTTP' ) Catch oServerWS := CreateObject( 'Microsoft.XMLHTTP' ) End Catch MsgInfo( 'Erro na Criação do Serviço' ) RETURN NIL End #else // PERFEITO COM HARBOUR. ( no Like. kkkkk ) Try Try oServerWS := win_OleCreateObject( 'MSXML2.XMLHTTP' ) Catch oServerWS := win_OleCreateObject( 'Microsoft.XMLHTTP' ) End Catch MsgInfo( 'Erro na Criação do Serviço! Com Harbour', 'Atenção!' ) RETURN NIL End #endif oServerWS:Open( 'GET', cUrl, .F. ) oServerWS:setRequestHeader( "Content-Type", "text/xml; charset=utf-8" ) oServerWS:Send() IF oServerWS:STATUS != 200 MsgStop( AllTrim( Str( oServerWS:Status ) ) + " - " + oServerWS:StatusText, "Erro" ) RETURN NIL ENDIF WHILE oServerWS:readyState != 4 SYSREFRESH() oServerWS:WaitForResponse( 1000 ) END x1 := hb_jsonDecode( oServerWS:responseText, @aArray ) IF aArray == nil MsgStop( "Erro ao retornar os dados. Tente novamente." ) RETURN NIL ENDIF IF aArray[ 'status' ] != 'OK' MsgStop( aArray[ 'message' ], "Erro" ) RETURN NIL ENDIF MsgInfo( "NOME: " + AllTrim( aArray[ 'nome' ] ) + CRLF + ; "FANTASIA: " + AllTrim( aArray[ 'fantasia' ] ) + CRLF + ; "ENDEREÇO: " + AllTrim( aArray[ 'logradouro' ] ) + ", " + AllTrim( aArray[ 'numero' ] ) + " " + AllTrim( aArray[ 'complemento' ] ) + CRLF + ; "BAIRRO: " + AllTrim( aArray[ 'bairro' ] ) + " CEP: " + AllTrim( aArray[ 'cep' ] ) + CRLF + ; "CIDADE: " + AllTrim( aArray[ 'municipio' ] ) + "-" + AllTrim( aArray[ 'uf' ] ) + CRLF + ; "TELEFONE: " + AllTrim( aArray[ 'telefone' ] ) + CRLF + CRLF + ; "NATUREZA JURÍDICA: " + AllTrim( aArray[ 'natureza_juridica' ] ) + CRLF + ; "TIPO: " + AllTrim( aArray[ 'tipo' ] ) + CRLF + ; "SITUAÇÃO: " + AllTrim( aArray[ 'situacao' ] ) + CRLF + ; "DATA SITUAÇÃO: " + AllTrim( aArray[ 'data_situacao' ] ) + CRLF + ; "ULTIMA ATUALIZAÇÃO: " + AllTrim( aArray[ 'ultima_atualizacao' ] ), "CNPJ CONSULTA" ) cNome := AllTrim( aArray[ 'nome' ] ) cEndereco := AllTrim( aArray[ 'logradouro' ] ) cNro := AllTrim( aArray[ 'numero' ] ) cNro := StrTran( cNro, ".", "", 1, 10 ) cNro := Val( cNro ) cComplemento := AllTrim( aArray[ 'complemento' ] ) cBairro := AllTrim( aArray[ 'bairro' ] ) cCep := AllTrim( aArray[ 'cep' ] ) cCidade := AllTrim( aArray[ 'municipio' ] ) cEstado := AllTrim( aArray[ 'uf' ] ) cTelefone := AllTrim( aArray[ 'telefone' ] ) IF cOnde = "T" cEndereco := cEndereco + " " + AllTrim( Str( cNro, 10 ) ) + " " + AllTrim( cComplemento ) ENDIF cNome := cNome + spac( 100 - Len( cNome ) ) cEndereco := cEndereco + spac( 100 - Len( cEndereco ) ) cComplemento := cComplemento + spac( 100 - Len( cComplemento ) ) cBairro := cBairro + spac( 100 - Len( cBairro ) ) cCep := cCep + spac( 10 - Len( cCep ) ) cCep := StrTran( cCep, ".", "", 1, 10 ) cCidade := cCidade + spac( 50 - Len( cCidade ) ) cTelefone := cTelefone + spac( 20 - Len( cTelefone ) ) RETURN NIL // FIN / END by kapiabafwh@gmail.com - 08/04/2022 - João Santos - São Paulo. Regards, saludos. Quote Link to comment Share on other sites More sharing options...
edutraini Posted April 8, 2022 Author Report Share Posted April 8, 2022 Tinha que ser corinthiano Vai curinthians Obrigado Quote Link to comment Share on other sites More sharing options...
Ladinilson Posted April 8, 2022 Report Share Posted April 8, 2022 1 minuto atrás, edutraini disse: Tinha que ser corinthiano Vai curinthians Obrigado Ele poderia defender o time dele como defende este forum porque o Cássio ta sendo ate ameaçado para sair. kkkkkkkkkkk Quote Link to comment Share on other sites More sharing options...
kapiaba Posted April 8, 2022 Report Share Posted April 8, 2022 12 minutos atrás, Ladinilson disse: Ele poderia defender o time dele como defende este forum porque o Cássio ta sendo ate ameaçado para sair. kkkkkkkkkkk kkkk, covardia de algum bandido da Gaviões da Fiel. Sou totalmente contra torcidas organizadas. Gostoso é poder brincar com os Adversários. Seria uma chatice da pohhha se só existissem Corinthianus. Sou Corinthiano roxo, mas não sou fanático. Em tempo: esse forum é tudodebom.com. Abraços. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.