Jump to content
Fivewin Brasil

Ajuda com try catch - Resolvido


betovsp

Recommended Posts

Olá pessoal.

Dêem uma olhada na função abaixo:

STATIC FUNCTION EnviaAgeSmsFinal(vSms,oBrwEmail)
LOCAL cHTML,oHTTP

cMensagem := 'TESTE DE ENVIO DE SMS AUTOMATICO PELO SISTEMA'

// abre qualquer navegador de internet
IF(!IsInternet())
MsgInfo("Necessário Uma Conexão com Internet !"+CRLF+"Operação cancelada",SISTEMA)
lEnvio:=.F.
ELSE
cURL:=https://www.mpgateway.com/v_3_00/sms/smspush/enviasms.aspx?Credencial=XXXX110B1B8723382XXXX793A74B5BC08D12266E&Token=123456&Principal_User=FF&Aux_User=F1&Mobile=552194797025&Send_Project=S&Message=teste

TRY
oHTTP:=TIPCLIENTHTTP():NEW( cURL ) // aqui envia
oHTTP:OPEN()
cHTML := oHTTP:READALL() // aqui pega o retorno
oHTTP:CLOSE()
CATCH
? "aqui"
lENVIO:=.F.
END
ENDIF
? chtml
SysWait(2)
return(lEnvio)

O problema: onde está errado porque ele não entre no try, já cai direto no catch e não envia a mensagem.

Obrigado.

Beto.

Link to comment
Share on other sites

Meu caro, retire o try e veja aonde o erro acontece.

Ou coloque mensagens para depurar pra ver até aonde aparece:

msginfo("1")
oHTTP:=TIPCLIENTHTTP():NEW( cURL )  // aqui envia
msginfo("2")
oHTTP:OPEN()
msginfo("3")
cHTML := oHTTP:READALL() // aqui pega o retorno
msginfo("4")
oHTTP:CLOSE()
msginfo("5")

Eu vi que você fez uma colocação de que a mensagem não é enviada, então provavelmente só vai aparecer a primeira mensagem de depuração, mas mesmo assim é interessante se certificar.Eu tiraria o TRY CATCH pra ver o que acontece.

Link to comment
Share on other sites

//cURL:=https://www.mpgateway.com/v_3_00/sms/smspush/enviasms.aspx?Credencial=XXXX110B1B8723382XXXX793A74B5BC08D12266E&Token=123456&Principal_User=FF&Aux_User=F1&Mobile=552194797025&Send_Project=S&Message=teste

//-- Estava atribuindo a variável sem ASPAS
cURL := "https://www.mpgateway.com/v_3_00/sms/smspush/enviasms.aspx?Credencial=XXXX110B1B8723382XXXX793A74B5BC08D12266E&Token=123456&Principal_User=FF&Aux_User=F1&Mobile=552194797025&Send_Project=S&Message=teste"

E tente assim:



Try
   ? "Entrou no Try"
   //-- Sua rotina
   nNumero := 1/0
Catch
   ? "Foi para o catch"
End
Link to comment
Share on other sites

Meu caro, retire o try e veja aonde o erro acontece.

Ou coloque mensagens para depurar pra ver até aonde aparece:

msginfo("1")
oHTTP:=TIPCLIENTHTTP():NEW( cURL )  // aqui envia
msginfo("2")
oHTTP:OPEN()
msginfo("3")
cHTML := oHTTP:READALL() // aqui pega o retorno
msginfo("4")
oHTTP:CLOSE()
msginfo("5")

Eu vi que você fez uma colocação de que a mensagem não é enviada, então provavelmente só vai aparecer a primeira mensagem de depuração, mas mesmo assim é interessante se certificar.Eu tiraria o TRY CATCH pra ver o que acontece.

Samir, ja tirei o try catch e olha o erro:

Application
===========
Path and name: C:\Desenvolvimento\PontoB32\PBCLI32.EXE (32 bits)
Size: 4,866,048 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20141106)
FiveWin Version: FWHX 14.12
Windows version: 6.1, Build 7601 Service Pack 1
Time from start: 0 hours 0 mins 26 secs
Error occurred at: 03/09/2015, 10:15:08
Error description: Error BASE/1081 Operation not supported: TIPCLIENTHTTP:New()
Args:
[ 1] = O TIPCLIENTHTTP
[ 2] = C https
Link to comment
Share on other sites

Faz um teste mais simples então com outra URL HTTP ao invés de HTTPS pra ver se funciona.

Eu uso esse cara apenas com HTTP, nunca utilizei com HTTPS, mas não sei te dizer se isso faria alguma diferença.

Bindo Ana, sem o https funciona.

Como posso utilizar o mesmo url tanto HTTP quanto HTTPS, foi resolvido o problema.

Obrigado.

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...