Recent

Author Topic: JHttpClient send json to rest server  (Read 2399 times)

schumi

  • New Member
  • *
  • Posts: 43
JHttpClient send json to rest server
« on: May 30, 2021, 11:07:01 pm »
hi,
it's possiple to send json data (not property) to rest server with jHttpServer? I'm looking for an example


thank's

jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: JHttpClient send json to rest server
« Reply #1 on: May 31, 2021, 04:53:13 am »
I found this code (in my attempts) about SOAP...  maybe can help you, but I don't remember if it works ....

(and you can try some "demos":  AppHttpClient****)

Code: Pascal  [Select][+][-]
  1. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  2. var
  3.   clientConn: jObjectRef;
  4. begin
  5.   clientConn:= jHttpClient1.OpenConnection('http://192.168.1.3');
  6.  
  7.   jHttpClient1.AddClientHeader('Content-Type','text/xml; charset=utf-8');
  8.   jHttpClient1.AddClientHeader('SOAPAction', '"urn:OSWIntf-IOSW#Wersja"');
  9.  
  10.   content:='<?xml version="1.0" encoding="UTF-8"?>'#13#10
  11.   +'<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:OSWIntf-IOSW" '
  12.   +'xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" '
  13.   +'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
  14.   +'<SOAP-ENV:Body><ns1:Wersja/></SOAP-ENV:Body></SOAP-ENV:Envelope>';
  15.  
  16.  
  17.   jHttpClient1.PostSOAPDataAsync(content, 'http://192.168.1.3/soap/IOSW');
  18.  
  19. end;
  20.  
« Last Edit: May 31, 2021, 04:59:58 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

schumi

  • New Member
  • *
  • Posts: 43
Re: JHttpClient send json to rest server
« Reply #2 on: July 09, 2021, 06:11:51 pm »
hi,
I have try with PostSOAPDataAsync but dosn't work to send JSON to rest server.

I want to use fpHTTPclient, so I have copy fphttpclient.pp, httpprotocol.pp, httppdefs.pp in ..\jni but when call GET or POST, app crash.

What I'm wrong ?


jmpessoa

  • Hero Member
  • *****
  • Posts: 2302
Re: JHttpClient send json to rest server
« Reply #3 on: July 09, 2021, 06:28:17 pm »
Quote
I want to use fpHTTPclient................ but when call GET or POST, app crash.

Can you send me your test project in "off" mode (by e-mail?)? so I can test your soap API and maybe I can, olso,  improve the jHttpClient.....

Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

 

TinyPortal © 2005-2018