JSON ENCODE DECODE SEND RECEIVE (resuelto)

Post Reply
User avatar
Maggiro
Posts: 76
Joined: Thu Oct 14, 2010 3:26 am
Location: LIMA - PERU
Contact:

JSON ENCODE DECODE SEND RECEIVE (resuelto)

Post by Maggiro »

Buenos Dias Comunidad:
Me preguntaba si éste tipo de rutina puede hacerse en xharbour + fivewin ...

Code: Select all

    Private Function EnviarJson(ByVal documento As String, ByVal documento64bytes As String) As String
       Dim respuesta As String = ""
       Dim user As String = "20557103920ad_escon"
       Dim pass As String = "Escon2018"
       
       Dim rss_datos As JObject =
           New JObject(New JProperty("customer",
                           New JObject(
                               New Jproperty("username", user),
                               New Jproperty("password", pass))),
                       New JProperty("filename", documento),
                       New JProperty("filecontent", documento64bytes))
       Try
           Dim uri As New Uri("http://calidad.escondatagate.net/wsparser/rest/parserWS")
           Dim data As String = rss_datos.ToString()
           If (uri.Scheme = uri.SchemeHttp) Then
           
               Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
               request.Method = WebRequestMethods.Http.Post
               request.ContentLength = data.length
               request.ContentType = "application/json"
               
               Dim writer As New StreamWriter(Request.GetRequestStream())
               writer.write(data)
               writer.Close()
               
               Dim Response As HttpWebResponse = request.GetResponse()
               Dim reader As New StreamReader(response.GetResponsestream())
               Dim tmp As String = reader.ReadToEnd()
               response.Close()
           End If
       
       Catch ex As Exception
           respuesta = "-1"
       End Try
       
       Return respuesta
 
Desde ya muchas gracias por vuestro alcance ...
Saludos
Julio César Gómez Cortéz
Jultzem Experiencias
Lima - Perú
Last edited by Maggiro on Tue Jul 24, 2018 4:05 am, edited 1 time in total.
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: JSON ENCODE DECODE SEND RECEIVE

Post by anserkk »

User avatar
Maggiro
Posts: 76
Joined: Thu Oct 14, 2010 3:26 am
Location: LIMA - PERU
Contact:

Re: JSON ENCODE DECODE SEND RECEIVE (resuelto)

Post by Maggiro »

... muchas gracias anserkk ... con tu dato pude resolver
cerrando las pruebas publico el code ...
Muchos Saludos
Julio César Gómez Cortéz
Jultzem Experiencias
Lima - Perú
Post Reply