Search the Knowledge Base Report a bug
Post new topic   Reply to topic   printer-friendly view   .    ArchiCAD-Talk Forum Index >>> Developer Forum >>> [SLVD] Prefered way to make a http request and parse xml doc
View previous topic :: View next topic
Author Message
vuego
New member
New member

Joined: 19 Sep 2006
Posts: 28

PostPosted: Wed Aug 30, 2017 6:55 pm    Post subject: [SLVD] Prefered way to make a http request and parse xml doc Reply with quote

I've noticed that there is a XML engine included with AC Api in GSRoot module.

Unfortunately there are no examples nor is it mentioned in the documentation. Is it just undocumented section or are there any examples for us to use?

Secondly, is there a preferred "AC API" way to execute a http request from a plugin? An example would be great too.

_________________
ARCHICAD 21, Dell Studio i7, 16Gb Ram, Win10 64bit
Back to top
View user's profile Send private message    
andrews
Guest
Guest

Joined: 31 Aug 2017
Posts: 1
Location: Australia

PostPosted: Thu Aug 31, 2017 10:18 pm    Post subject: Re: Prefered way to make a http request and parse xml docume Reply with quote

Hey Vuego,

I don't have an answer for you, I'm just joining this thread because I'd like to know how to make HTTP requests. HTTPS requests would be even better.
Back to top
View user's profile Send private message    
Mihály Palenik
Graphisoft

Joined: 25 Apr 2017
Posts: 6
Location: Budapest

PostPosted: Tue Sep 12, 2017 1:24 pm    Post subject: Re: Prefered way to make a http request and parse xml docume Reply with quote

Hello,
vuego wrote:
I've noticed that there is a XML engine included with AC Api in GSRoot module.

There is more than one XML Engine which you can use. For what purpose would you like to use it?

vuego wrote:
Secondly, is there a preferred "AC API" way to execute a http request from a plugin? An example would be great too.

You can find examples about http/https request in API DevKit's Examples/Goodie_Functions/Src/Goodie_Functions.cpp.
One of them is Do_DownloadWebpage function.

Best,
Mihály
Back to top
View user's profile Send private message    
vuego
New member
New member

Joined: 19 Sep 2006
Posts: 28

PostPosted: Tue Sep 12, 2017 2:09 pm    Post subject: Re: Prefered way to make a http request and parse xml docume Reply with quote

Thanks Mihály for pointing me in the right direction.

Besides Do_DownloadWebpage, there are also Do_XML_From_String() and Do_XML_Write(), that are all I needed.

_________________
ARCHICAD 21, Dell Studio i7, 16Gb Ram, Win10 64bit
Back to top
View user's profile Send private message    
vuego
New member
New member

Joined: 19 Sep 2006
Posts: 28

PostPosted: Mon Sep 18, 2017 10:28 am    Post subject: Re: Prefered way to make a http request and parse xml Reply with quote

I have another question. I am getting binary data with my http request into GS::IChannelX. My binary data is a gsm object.


Code:
Response response;
   GS::IChannelX channel(clientConnection.BeginReceive(response), GS::GetNetworkByteOrderIProtocolX());


I would like to store binary response to a file object IO::File..
Code:

   IO::Location rab("C:/GDLTest/11204.gsm2");
   IO::File targetFile(rab, IO::File::Create);


How can I store data from GS::ChanelX into IO::File?
Or, is it possible to use IO::File as IChannel and store request directly to file using clientConnection.BeginReceive(response) ?

Thank you in advance.

_________________
ARCHICAD 21, Dell Studio i7, 16Gb Ram, Win10 64bit
Back to top
View user's profile Send private message    
Akos Somorjai
Graphisoft

Joined: 26 May 2004
Posts: 186
Location: Budapest

PostPosted: Mon Sep 18, 2017 10:35 am    Post subject: Re: Prefered way to make a http request and parse xml Reply with quote

vuego wrote:
I have another question. I am getting binary data with my http request into GS::IChannelX. My binary data is a gsm object.


How can I store data from GS::ChanelX into IO::File?
Or, is it possible to use IO::File as IChannel and store request directly to file using clientConnection.BeginReceive(response) ?

Thank you in advance.


The 'I' in IChannel stands for input channel. You have to open an output channel (GS::OChannel), which can be an IO::File, then write the data directly into it.

Best, Akos
Back to top
View user's profile Send private message    
vuego
New member
New member

Joined: 19 Sep 2006
Posts: 28

PostPosted: Mon Sep 18, 2017 11:10 am    Post subject: Re: [SLVD] Prefered way to make a http request and parse xml Reply with quote

Sorry, I ment IO::File as output channel.

I am having trouble receiving/writing data from HTTP::ClientConnection directly into IO::File (GS::OChannel)... how do I achieve that?

_________________
ARCHICAD 21, Dell Studio i7, 16Gb Ram, Win10 64bit
Back to top
View user's profile Send private message    
Akos Somorjai
Graphisoft

Joined: 26 May 2004
Posts: 186
Location: Budapest

PostPosted: Mon Sep 18, 2017 11:56 am    Post subject: Re: [SLVD] Prefered way to make a http request and parse xml Reply with quote

vuego wrote:
Sorry, I ment IO::File as output channel.

I am having trouble receiving/writing data from HTTP::ClientConnection directly into IO::File (GS::OChannel)... how do I achieve that?


Again: IChannels are for input OChannel are for output. The http connection is the input channel, and you yourself have to write that information to the output channel (== IO::File). So the pseudo code:

read bytes from input
write bytes to output

Best, Akos
Back to top
View user's profile Send private message    
vuego
New member
New member

Joined: 19 Sep 2006
Posts: 28

PostPosted: Mon Sep 18, 2017 12:09 pm    Post subject: Re: [SLVD] Prefered way to make a http request and parse xml Reply with quote

Ok, Akos, thanks.

I thought there would be a more elegant way of connecting input and output channels than that Smile

_________________
ARCHICAD 21, Dell Studio i7, 16Gb Ram, Win10 64bit
Back to top
View user's profile Send private message    
Display posts from previous:   
View previous topic :: View next topic
Post new topic   Reply to topic   printer-friendly view       ArchiCAD-Talk Forum Index >>> Developer Forum >>> [SLVD] Prefered way to make a http request and parse xml doc All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2012 - Graphisoft SE. All rights reserved worldwide. Terms of Use | Privacy Policy