|
Exemplos de uso do Httprequest/HttpGetResult |
Iniciado por adrianoboller, 27,feb. 2015 22:06 - 1 respuesta |
| |
| | | |
|
| |
Miembro registrado 3.655 mensajes Popularité : +175 (223 votes) |
|
Publicado el 27,febrero 2015 - 22:06 |
Examples Ex01: Retorna Html ##################################################### Code Button:
Url is string = "http://www.informaticon.com.br" ok is boolean = HTTPRequest(Url) IF ok = True Info(ok ) retorno is string = HTTPGetResult() ELSE Info(ErrorInfo()) END
Ex02: Retorna Header DO Html ##################################################### Code Button:
Url is string = "http://www.informaticon.com.br" ok is boolean = HTTPRequest(Url) IF ok = True Info(ok ) retorno is string = HTTPGetResult(httpHeader) ELSE Info(ErrorInfo()) END
Ex03: Retorna Cookie ##################################################### Code Button:
Url is string = "http://www.informaticon.com.br" ok is boolean = HTTPRequest(Url) IF ok = True Info(ok ) retorno is string = HTTPGetResult(httpCookie) ELSE Info(ErrorInfo()) END
Ex04: Retorna html ##################################################### Code Button:
Url is string = "http://www.informaticon.com.br" ok is boolean = HTTPRequest(Url) IF ok = True Info(ok ) retorno is string = HTTPGetResult(httpResult) ELSE Info(ErrorInfo()) END
Ex05: Retorna uma imagem (download de arquivo) ##################################################### Code Button:
ArquivoBaixado is Buffer
Url is string = "http://www.informaticon.com.br/j/images/stories/neri.jpg"
ok is boolean = HTTPRequest(Url)
IF ok = True ArquivoBaixado = HTTPGetResult() ELSE Info(ErrorInfo()) END
fSaveBuffer("c:\fotodonerigaldeiro.jpg",ArquivoBaixado)
Ex06: Retorna uma executavel (download de arquivo) ##################################################### Code Button:
ArquivoBaixado is Buffer
Url is string = "http://www.7-zip.org/a/7z920.exe"
ok is boolean = HTTPRequest(Url)
IF ok = True ArquivoBaixado = HTTPGetResult() ELSE Info(ErrorInfo()) END
fSaveBuffer("7z920.exe",ArquivoBaixado)
Ex07: Envelope SOAP ##################################################### Code Button: Procedure WS_Taxi_AtualizarCartoes(LOCAL DebugSN)
IF GloDebugSN = "S" THEN Info("WS_Taxi_AtualizarCartoes") DebugSN = "S" END
ok is boolean = False
Contador is int = 0
bAtualizar is boolean = False
IpSaladaFruta01 is string = Morango_01 +"."+ Abacaxi_02 +"."+ Limao_03 +"."+ Melancia_04 +":"+ Laranja_05 IpSaladaFruta02 is string = Morango_01 +"."+ Abacaxi_02 +"."+ Limao_03 +"."+ Melancia_04 +":"+ Manga_06
ChangeCharset(charsetOccidental)
HReadSeekFirst(t001_cliente,t001_cliente.t001_seq_cliente,1) IF HFound(t001_cliente) = True THEN
erro is int = 0 CodClienteCelula, nRetornoCodigo is int = 0 bRet is boolean = False XML_Retorno, NumProces is string = ""
HReadSeekFirst(t001_cliente,t001_cliente.t001_seq_cliente,1) IF HFound(t001_cliente) = True THEN
NumProces = WS_Taxi_ValidaRequisicao(t001_cliente.t001_ddd_telefone,... t001_cliente.t001_num_telefone,... 0,... 0,... "N")
IF CodClienteCelula = "" OR CodClienteCelula = 0 THEN CodClienteCelula = t001_cliente.t001_cod_clientecelula END
Xml_SEND is string = [ <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:act297_RtPlusSSDM-IRtPlusSSDM#AtualizarCartoes"> <soapenv:Header/> <soapenv:Body> <urn:AtualizarCartoes soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <cod_client_celula xsi:type="xsd:int">v001</cod_client_celula> <dat_hora_proces xsi:type="xsd:string">v002</dat_hora_proces> <num_proces xsi:type="xsd:int">v003</num_proces> </urn:AtualizarCartoes> </soapenv:Body> </soapenv:Envelope> ]
Xml_SEND = Replace(Xml_SEND,"v001",CodClienteCelula,IgnoreCase) Xml_SEND = Replace(Xml_SEND,"v002",GloDataHora,IgnoreCase) Xml_SEND = Replace(Xml_SEND,"v003",NumProces,IgnoreCase)
IF DebugSN = "S" THEN Info("/mnt/sdcard/TaxiFv/Arquivos/EnvioCartoes.TXT", Xml_SEND) IF InAndroidMode() = True IF InSimulatorMode() = False fSaveBuffer("/mnt/sdcard/TaxiFv/Arquivos/EnvioCartoes.TXT", Xml_SEND) ELSE fSaveBuffer("c:\EnvioCartoes.TXT", Xml_SEND) END END END
HTTPTimeOut(GloHTTPTimeOut)
ok = HTTPRequest("http://"+IpSaladaFruta01+"/soap/IRtPlusSSDM","", "", Xml_SEND, "text/xml","","")
XML_Retorno = WS_Android_IOS_HTTPGetResult()
IF DebugSN = "S" THEN Info("/mnt/sdcard/TaxiFv/Arquivos/RetornoCartoesSemTratamento.TXT", XML_Retorno) IF InAndroidMode() = True IF InSimulatorMode() = False fSaveBuffer("/mnt/sdcard/TaxiFv/Arquivos/RetornoCartoesSemTratamento.TXT", XML_Retorno) ELSE fSaveBuffer("c:\RetornoCartoes.TXT", XML_Retorno) END END END
XML_Retorno = WS_RemoveAcentos(XML_Retorno)
IF Length(XML_Retorno) > 0 THEN
Inicial is int = PositionOccurrence(XML_Retorno,"<NS2:TTipoFormaPagamentoVO",firstRank,FromBeginning) Final is int = PositionOccurrence(XML_Retorno,"</NS2:TTipoFormaPagamentoVO>",lastRank,FromEnd) +Length("</NS2:TTipoFormaPagamentoVO>") XML_Retorno = Middle(XML_Retorno,Inicial,Final - Inicial) XML_Retorno = Replace(XML_Retorno,"NS2:TTipoFormaPagamentoVO","NoXml") XML_Retorno = "<Xml><Recorte>"+XML_Retorno+"</Recorte></Xml>"
IF DebugSN = "S" THEN Info("/mnt/sdcard/TaxiFv/Arquivos/RetornoCartoes.TXT", XML_Retorno) IF InAndroidMode() = True IF InSimulatorMode() = False fSaveBuffer("/mnt/sdcard/TaxiFv/Arquivos/RetornoCartoes.TXT", XML_Retorno) ELSE fSaveBuffer("c:\RetornoCartoes.TXT", XML_Retorno) END END END
IF Length(XML_Retorno) >0 THEN
HExecuteQuery(QRY_T004Cartoes_Del) FOR EACH t004_cartoescreditos HDelete(t004_cartoescreditos) END
IF IniOSMode() = True THEN
NoXml is string i is int = 1
LOOP
NoXml = XMLExtractString(XML_Retorno,"NoXml",i)
IF NoXml = "" THEN BREAK END
DesFormaPagame is string = XMLExtractString(NoXml,"DesFormaPagame") CodFormaPagame is string = XMLExtractString(NoXml,"CodFormaPagame")
IF DebugSN = "S" Info("Cartao",CodFormaPagame,DesFormaPagame) END
HReadSeekFirst(t004_cartoescreditos,t004_cartoescreditos.NomeCartao004,DesFormaPagame)
IF HFound(t004_cartoescreditos) = False THEN
t004_cartoescreditos.CodigoCartao004 = CodFormaPagame IF t004_cartoescreditos.CodigoCartao004 = 0 THEN Contador += 1 t004_cartoescreditos.CodigoCartao004 = Contador END t004_cartoescreditos.NomeCartao004 = DesFormaPagame t004_cartoescreditos.DataAtualizacao004 = DateSys()
IF DebugSN = "S" THEN Info("tabela",t004_cartoescreditos.CodigoCartao004,t004_cartoescreditos.NomeCartao004) END
ok = HAdd(t004_cartoescreditos) IF ok = False THEN
erro += 1 ELSE IF DebugSN = "S" THEN Info("Adicionado com sucesso") END END
END i++ END
ELSE IF InAndroidMode() = True
XmlDoc is XMLDocument
XmlDoc = XMLOpen(XML_Retorno, fromString)
NoXml is xmlNode
FOR EACH NoXml OF XmlDoc.Xml.Recorte on NoXml
IF DebugSN = "S" Info("Cartao",NoXml.CodFormaPagame,NoXml.DesFormaPagame) END
HReadSeekFirst(t004_cartoescreditos,t004_cartoescreditos.NomeCartao004,NoXml.DesFormaPagame)
IF HFound(t004_cartoescreditos) = False THEN
t004_cartoescreditos.CodigoCartao004 = NoXml.CodFormaPagame IF t004_cartoescreditos.CodigoCartao004 = 0 THEN Contador += 1 t004_cartoescreditos.CodigoCartao004 = Contador END t004_cartoescreditos.NomeCartao004 = NoXml.DesFormaPagame t004_cartoescreditos.DataAtualizacao004 = DateSys()
IF DebugSN = "S" THEN Info("tabela",t004_cartoescreditos.CodigoCartao004,t004_cartoescreditos.NomeCartao004) END
ok = HAdd(t004_cartoescreditos) IF ok = False THEN
erro += 1 ELSE IF DebugSN = "S" THEN Info("Adicionado com sucesso") END END
END END
END
IF erro > 0 THEN ok = False ELSE ok = True END
END
END
END
END
RESULT(ok) |
| |
| |
| | | |
|
| | |
| |
Miembro registrado 3.655 mensajes Popularité : +175 (223 votes) |
|
Publicado el 14,enero 2021 - 00:10 |
//Aqui define o layout do XML a ser enviado pelo POST
sXDoc is string = [ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enderecodocliente:TMAtualizaOrdemFrete"> <soapenv:Header/> <soapenv:Body> <urn:MT_AtualizaOrdemFrete_Req_Conc> <ordem> <nr_ordem>?</nr_ordem> <dados_pesagem> <tara_veiculo>?</tara_veiculo> <peso_bruto>?</peso_bruto> <peso_liquido_real>?</peso_liquido_real> </dados_pesagem> <inf_item> <id_etapa>?</id_etapa> <nr_remessa>?</nr_remessa> <item_remessa>?</item_remessa> <id_material>?</id_material> <quantidade>?</quantidade> <unidade_med_qtde>?</unidade_med_qtde> <inf_lote> <lote>?</lote> <qtde>?</qtde> <unidade_lote>?</unidade_lote> </inf_lote> </inf_item> <dados_analise> <temperatura_tanque>?</temperatura_tanque> <ap_veiculo_seta>?</ap_veiculo_seta> <massa_especifica>?</massa_especifica> <fator_reducao_vol>?</fator_reducao_vol> <alcalinidade>?</alcalinidade> <volume_20>?</volume_20> <acidez_total>?</acidez_total> <grau_inpm>?</grau_inpm> <aspecto>?</aspecto> </dados_analise> <checklist> <id_checklist>?</id_checklist> </checklist> <lacres> @LACRE@ </lacres> </ordem> </urn:MT_AtualizaOrdemFrete_Req_Conc> </soapenv:Body> </soapenv:Envelope> ]
//Exemplo de como substituir parte do XML inicial por variáveis
sLacre is string = "<lacre>?</lacre>"
sXDoc = Replace(sXDoc,"@LACRE@",sLacre)
//webservice req is httpRequest
req.URL = "http://servidor.cliente.com.br:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BS_CONCEITTO_D&receiverParty=&receiverService=&interface=SI_AtualizaOrdemFrete_Out&interfaceNamespace=urn:enderecodocliente:TMAtualizaOrdemFrete" req.User = "TESTE" req.Password = "1234" req.Header["SOAPAction"] = "Conceitto/Login" req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.42000)" req.Method = httpPost req.ContentType = "text/xml; charset=utf-8"
req.Content = sXDoc
cMyResponse is httpResponse = HTTPSend(req)
IF ErrorOccurred THEN Error(ErrorInfo(errFullDetails)) ELSE sXDoc = cMyResponse..Content Info(sXDoc) END
-- Adriano José Boller ______________________________________________ Consultor e Representante Oficial da PcSoft no Brasil +55 (41) 99949 1800 adrianoboller@gmail.com skype: adrianoboller http://wxinformatica.com.br/ |
| |
| |
| | | |
|
| | | | |
| | |
|