Atozed Forums
how to post to another server - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: how to post to another server (/thread-1049.html)



how to post to another server - amit.walters - 04-27-2019

we have Firewall which gives option for external portal authentication.
for this I have created one Intraweb application. it shows one page for username an password, verifies it with data base and if found ok then
(required to post username and password to firewall for authorization and accounting.
but because i don't know any option to post data by programming in Intraweb I am writing a html file with auto post to Firewall. this way it is working but I want to know

is their any way to post parameters to another server in my case firewall.


RE: how to post to another server - Jose Nilton Pace - 04-28-2019

Hi. I have one IW project needs to consume (GET/POST) an API from another site. I use indy to handle this for me very well.


RE: how to post to another server - amit.walters - 04-29-2019

(04-28-2019, 12:19 PM)Jose Nilton Pace Wrote: Hi. I have one IW project needs to consume (GET/POST) an API from another site. I use indy to handle this for me very well.

but it send from server side not from client side so distention server receives parameters from server ip not from client IP.


RE: how to post to another server - Jose Nilton Pace - 04-29-2019

Hi, in your IW application you can get Client IP.
WebApplication.IP is your Client IP.


RE: how to post to another server - amit.walters - 04-29-2019

(04-29-2019, 11:23 AM)Jose Nilton Pace Wrote: Hi, in your IW application you can get Client IP.
WebApplication.IP is your Client IP.
sir, Can i get an example project for this how to use indy in IW Application for client IP


RE: how to post to another server - MJS@mjs.us - 11-04-2020

This method has been working for well for me.

In my case I need client of IW app 1 to retrieve information from IW app 2.  This method may work where app 2 is a non IW server as long as the POST is formatted correctly but I haven't tried it.


Method A:  Retrieve info from IW app 2 that only needs to be displayed in an IW control of client of IW app 1.


Code:
1.  Create a custom content handler like '/customapp2content' in IW app 2 to respond
    to requests from client of IW app 1.
2.  Send async request to IW app 2 like so:
    WebApplication->CallBackResponse->AddJavaScriptToExecuteAsCDATA("$.post(\"https://www.app2.com/customapp2content\", \"REQUST MESSAGE\", function(data,  status) { $('#MEMO').val(data); } );");

    IW control 'MEMO' will now display IW app 2 response. "REQUST MESSAGE" is your optional message you may want to send to IW app 2.

Method B:  Retrieve info from IW app 2 that needs to update an IW control of client of IW app 1.

Code:
1.  Create a custom content handler like '/customapp2content' in IW app 2 to respond
    to requests from client of IW app 1.
2.  Create an ajax callback in IW app 1 to process response from IW app e.g.

    ExtraHeader->Add("<script language=\"javascript\" type=\"text/javascript\">function CB(d) { ajaxCall(\"CB\",\"&1=\"+encodeURIComponent(d), true); }</script>");
    RegisterCallBack("CB",CB);
    void __fastcall TTestForm::CB(TStringList *EventParams) { MEMO->Text = EventParams->Values["1"]; }

3.  Send async request to IW app 2 like so:
    WebApplication->CallBackResponse->AddJavaScriptToExecuteAsCDATA("$.post(\"https://www.app2.com/customapp2content\", \"REQUST MESSAGE\", function(data, status) { CB(d); } );");
    IW control 'MEMO' will now update IW app 1 with IW app 2 response. "REQUST MESSAGE" is your optional message you may want to send to IW app 2.