EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
Expand all | Collapse all

HTTP POST/GET request and receive how to

Discussion Topic

Discussion TopicFri February 26, 2016 04:02 AM

  • 1.  HTTP POST/GET request and receive how to

    Posted Tue February 09, 2016 10:55 AM

    Hi guys, I'm developing in my RUI application a call to an external credit card payment service.

    The request to this payment service must be done with a POST request with parameters including a url for reply.

    The service responds to me at the url with GET and some parameters. 

    How can I implement a service that listens to a specific address which receives the parameters with GET?

    Any ideas?

     

     

     

    Matteo@MR


  • 2.  Re: HTTP POST/GET request and receive how to

    Posted Tue February 09, 2016 11:22 AM

    @Marcel-D 185ef4e2-58bb-459d-b414-d02f00ff390d​, @markevans 5c01ba43-4f0f-42d9-8c50-ff9ba92b68b7, @Ortwin cbf80e92-bdfd-4bb0-9fdb-221517a47e41​ any ideas?

    Matteo@MR


  • 3.  Re: HTTP POST/GET request and receive how to

    Posted Tue February 09, 2016 12:15 PM

    Matteo,

    I am pretty sure you are describing what could be invoked as a REST service. Please see the following section in the RBD Knowledge Center.

     

    http://www-01.ibm.com/support/knowledgecenter/SSMQ79_9.5.0/com.ibm.egl.pg.doc/topics/pegl_serv_accessing.html

     

    This describes some of the steps to use a 3rd party REST service.

     

    Also, the "do and Learn" Mortgage Tutorial has some steps where it invokes the Google Maps service which would be similar.

     

    take care.

    Mark

    markevans


  • 4.  Re: HTTP POST/GET request and receive how to

    Posted Tue February 16, 2016 06:09 AM

    Hi @markevans 5c01ba43-4f0f-42d9-8c50-ff9ba92b68b7​, thanks for your fast reply.

    I read the Mortgage tutorial and I understand how it works. But I can't seem to apply to my project this thing.

    I try to explain better.

    From my handler RUI I'm load in an IFrame this url with the parameters required by the payment service gateway:

    matteo@mr-srl.it&languageId=ITA&TCONTAB=I&url=http://google.it&url_back=http://google.it&mac=3a612baf8286e94ef73a823957567e9c8615cde2">https://coll-ecommerce.keyclient.it/ecomm/ecomm/DispatcherServlet?alias=3444153&importo=0000001&divisa=EUR&codTrans=0000000000000038&mail=matteo@mr-srl.it&languageId=ITA&TCONTAB=I&url=http://google.it&url_back=http://google.it&mac=3a612baf8286e94ef73a823957567e9c8615cde2

    from this page the user can abort or complete payment. In response to one of two operations carried out by the user manage responds to a url with get method with specific parameters. These URLs are two of the parameters passed in the request. (I put google to both for this test) ...&url=http://google.it&url_back=http://google.it

    Trying the link that I passed you will see that the service will respond with an error at page www.google.it with parameters in url.

    The same thing will do if successful, but at the other url.

    So I should have a service listening at a specific url that receives positive or abort feedback or two different (maybe better).

    From the examples seen I don't know how to do it.

    I hope you understand my scenario....

    Matteo@MR


  • 5.  Re: HTTP POST/GET request and receive how to

    Posted Tue February 16, 2016 10:56 AM

    Hi,

    I think you have surpassed my in-depth knowledge in this area or I am not understanding the scenario.

    I have forwarded to the development team to see if they can provide more insight based on what you have provided.

     

    markevans


  • 6.  Re: HTTP POST/GET request and receive how to

    Posted Tue February 16, 2016 11:28 AM

    hi @markevans 5c01ba43-4f0f-42d9-8c50-ff9ba92b68b7​ excuse me for the lack of clarity.

    The Bank gateway responds at the end of transaction with an http GET to a page.

    I need to know how can I set up a service with specific url that receives http get response  parameters.

    Will be 2 different services, one for positive feedback when the transaction ends and one for errors or user abort.

    Matteo@MR


  • 7.  Re: HTTP POST/GET request and receive how to

    Posted Thu February 18, 2016 06:33 AM

    Hi,

    if I've understood you correctly.

    You have to use a java Servlet.

     

    Something like this:

     

    // Import required java librariesimport java.io.*;import javax.servlet.*;import javax.servlet.http.*;// Extend HttpServlet classpublic class HelloWorld extends HttpServlet {   private String message;  public void init() throws ServletException  {      // Do required initialization      message = "Hello World";  }  public void doGet(HttpServletRequest request,                    HttpServletResponse response)            throws ServletException, IOException  {      // Set response content type      response.setContentType("text/html");      // Actual logic goes here.      PrintWriter out = response.getWriter();      out.println("<h1>" + message + "</h1>");  }  }

     

    Marcel-D


  • 8.  Re: HTTP POST/GET request and receive how to

    Posted Thu February 18, 2016 08:17 AM

    @Marcel-D 185ef4e2-58bb-459d-b414-d02f00ff390d​, Wow thanks might be a good solution!

    But I don't have much experience. Once created, how do I integrate it in my Web project or RUI?

    And how do I notify my RUI handler after processing the response?

    Matteo@MR


  • 9.  Re: HTTP POST/GET request and receive how to

    Posted Fri February 19, 2016 02:11 AM

    Hi,

    i think to notify a RUI handler is not possible from a java Servlet.

     

    Take a look at this: http://stackoverflow.com/questions/7213541/what-is-java-servlet

    and this: http://www.tutorialspoint.com/servlets/servlets-first-example.htm

    Marcel-D


  • 10.  Re: HTTP POST/GET request and receive how to

    Posted Fri February 19, 2016 09:47 AM

    I would like to inform the RUI upon receipt of the response.

    Other way?  Anyone have any ideas? 

    @markevans 5c01ba43-4f0f-42d9-8c50-ff9ba92b68b7​ ​some news from the development team?

    Matteo@MR


  • 11.  Re: HTTP POST/GET request and receive how to

    Posted Wed February 17, 2016 10:03 AM

    @markevans 5c01ba43-4f0f-42d9-8c50-ff9ba92b68b7​, I could use this method:   https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014499758

    But the question is:

    - the user has arrived at the page (handler) XXX and activates the payment process that loads in an iframe the external payment page (fully managed by the payment gateway), complete the data and confirm

    - at the end of the payment process the service calls the handler YYY and passes the response parameters in the url with GET method

    - the handler retrieves the parser performs url and YYY the regalia and you're done

    - the parameters are retrieved in the start function of the handler YYY doing url parser

    - the problem is that in debug the call at the start function of the handler YYY does not arrive, I think because the page is not loaded in the browser

    - ...everything must be done within the session ... 

    Matteo@MR


  • 12.  Re: HTTP POST/GET request and receive how to

    Posted Wed February 17, 2016 10:49 PM

    You don't necessarily put the url parser in the start function. You can make it a library function and invoke it once you can get the url ( Maybe events or timer). 

    HuangJiYong


  • 13.  Re: HTTP POST/GET request and receive how to

    Posted Thu February 18, 2016 08:21 AM

    Thanks @HuangJiYong 4ea89e0e-f102-4cee-83b7-27212c7e3fd0, do you have an example of how to do it? 

    Matteo@MR


  • 14.  Re: HTTP POST/GET request and receive how to

    Posted Fri February 26, 2016 04:02 AM

    Hey guys, some ideas?

    Matteo@MR


  • 15.  Re: HTTP POST/GET request and receive how to

    Posted Fri February 26, 2016 04:44 AM

    Did you receive javascript examples of this from the payment service provider?

    Bram_Callewaert


  • 16.  Re: HTTP POST/GET request and receive how to

    Posted Fri February 26, 2016 08:46 AM

    Matteo,

    I did send to the development team and HuangJiYong in the posts is the one trying to help.  

    If I understand things correctly, the payment gateway is sending a URL that starts up a RUI page.  What you want to then do is parse the remaining part of that URL to get its response.   Is this correct?

    As Bram said...did the payment service provider provide any samples in javascript... if so, you could always use/create an external type if needed to do the work out of the RUI.

    Just as an alternative, are there any service providers you can use that have a pure REST or SOAP web service interface???   This way you can just create an interface to be used by the RUI and all the sending/receiving of parms would be handled automatically for you....and would give you the built-in way to deal with "normal" vs "onException" processing.

     

    Mark

     

     

    markevans


  • 17.  Re: HTTP POST/GET request and receive how to

    Posted Mon February 29, 2016 02:46 AM

    Hi @markevans 5c01ba43-4f0f-42d9-8c50-ff9ba92b68b7, there are no javascript example unfortunately!

    Can I share the technical documentation of the service but only in Italian. Sorry. (You can find the pdf file in attached) 

    The message exchanged must be sent with http GET/POST method redirects, in SSL mode.

    REQUEST (START PHASE)

    The payment page URLs provided by VIRTUAL PAY, which should be directed to the user's browser, is:

    https://ecommerce.keyclient.it/ecomm/ecomm/DispatcherServletIl

    first step that the merchant must fulfill is to generate a message to the client browser to start the payment process towards the virtual POS. This can be done either with a redirect, or a link, (then using the HTTP GET method), or by submitting a form with hidden fields (which can HTTP POST method)

    RESPONSE (END PHASE)

    Once the payment is redirected directly to the merchant site, at the address indicated in the payment initiation message (named 'url' field). The user then returns to the merchant's site, bringing with him the parameters (see table below) that attest to the conclusion of the transaction.

     

    Matteo@MR


  • 18.  Re: HTTP POST/GET request and receive how to

    Posted Tue March 01, 2016 09:48 AM

    Matteo,

    I am sorry, but I just don't have the expertise to give you much guidance on this.

     

    Maybe others on the forum do and can tell you whether the provider you have chosen is able to work with a Web 2.0 type app.  Or other advice.

     

    Mark

    markevans


  • 19.  Re: HTTP POST/GET request and receive how to

    Posted Tue March 01, 2016 10:50 AM

    I think I understand the process, but I don't know how I can pass external parameters to a rui application.

     

    A practical example:

    We have an application for invoice approval. It sends a mail to a user to notify that an invoice needs to be approved.

    The mail contains the invoice id.

     

    The user then has to open a rui handler which consist of two parts:

    • Search screen
    • Invoice details screen

    The user first has to retype the invoice number to search for the invoice, before he can approve the invoice.

    This is because I can't put a link in the email with parameters to load the rui handler to the specific invoice without searching.

     

     

    This is very similar to matteo's problem (correct my if I misunderstood)

    • The RUI application has to show an external web application, loaded with some details through the post/get parameters.
    • The user has to approve the payment in the external application.
    • The external application links to a new URL (passed with the initial post/get parameters) to respond with the result of the payment process (ok / nok)

    I don't have a solution for the last step: load a rui handler with access to the post/get parameters.

     

     

    Bram_Callewaert


  • 20.  Re: HTTP POST/GET request and receive how to

    Posted Wed March 02, 2016 02:34 AM

    Yes @Bram_Callewaert c8e871a3-4d76-4753-b3c1-cdbbcf53831e​, that's the scenario.

    But I wonder if you can load the startup page payment as a new browser tab and not in the iframe inside the dialog.

    In this way, the browser should be able also to handle the loading of the response page to specific URL (RUI handler and not widget) .

    Here I read the parameters in the url with the parsing (https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014499758) and then posting an event on the bus I can pass the response to the main page. 

    it's possible? 

    Matteo@MR


  • 21.  Re: HTTP POST/GET request and receive how to

    Posted Wed March 02, 2016 03:42 AM

    Thanks for the link to the parameter passing. It will be helpfull in the future.

    I don't know if you can have infobus communication accross browser windows. It would be easy to test though.

    Bram_Callewaert


  • 22.  Re: HTTP POST/GET request and receive how to

    Posted Wed March 02, 2016 09:37 AM

    I'm interested to know if it is possible and how to open the page of payment to a new browser tabs (perhaps in the same session) , now the page is open in an iframe into a dialog.

    This is the start payment url: matteo@mr-srl.it&languageId=ITA&TCONTAB=I&url=http://google.it&url_back=http://google.it&mac=3a612baf8286e94ef73a823957567e9c8615cde2">https://coll-ecommerce.keyclient.it/ecomm/ecomm/DispatcherServlet?alias=3444153&importo=0000001&divisa=EUR&codTrans=0000000000000038&mail=matteo@mr-srl.it&languageId=ITA&TCONTAB=I&url=http://google.it&url_back=http://google.it&mac=3a612baf8286e94ef73a823957567e9c8615cde2

    Matteo@MR


  • 23.  Re: HTTP POST/GET request and receive how to

    Posted Wed March 02, 2016 10:05 AM

    In html (or javascript) there are options on a link tag, describing where the link should be opened (current tab, other tab, new window, ...)

    As it is the external payment service who opens the link, I fear you don't have any control over the name parameter of the window.open operation (http://www.w3schools.com/jsref/met_win_open.asp

     

    Bram_Callewaert


  • 24.  Re: HTTP POST/GET request and receive how to

    Posted Wed March 02, 2016 10:20 AM

    So are you telling me that there is an alternative to load my page in an iframe? (iframe.src = matteo@mr-srl.it&languageId=ITA&TCONTAB=I&url=http://google.it&url_back=http://google.it&mac=3a612baf8286e94ef73a823957567e9c8615cde2">https://coll-ecommerce.keyclient.it/ecomm/ecomm/DispatcherServlet?alias=3444153&importo=0000001&divisa=EUR&codTrans=0000000000000038&mail=matteo@mr-srl.it&languageId=ITA&TCONTAB=I&url=http://google.it&url_back=http://google.it&mac=3a612baf8286e94ef73a823957567e9c8615cde2) 

    Matteo@MR


  • 25.  Re: HTTP POST/GET request and receive how to

    Posted Fri March 04, 2016 09:31 AM

    Hi,

    to open a url in a new tab you have to use javascript (externaltype).

     

                                            "link" : function(url) {                                                window.open(url, '_blank')                                        },

     

     

    Take a look at Bram's post....

     

    Kind Regards!

    Marcel-D


  • 26.  Re: HTTP POST/GET request and receive how to

    Posted Tue March 08, 2016 05:04 AM

    Ok @Marcel-D 185ef4e2-58bb-459d-b414-d02f00ff390d but in my case how do I apply the javascript?  

    In attached the handler page source where the payment process starts (Fatture.egl) and IFrame source (IFrame.egl).

    My idea now would know not to use IFrame inside dialog but open the paid launch url (matteo@mr-srl.it&languageId=ITA&TCONTAB=I&url=http://google.it&url_back=http://google.it&mac=3a612baf8286e94ef73a823957567e9c8615cde2">https://coll-ecommerce.keyclient.it/ecomm/ecomm/DispatcherServlet?alias=3444153&importo=0000001&divisa=EUR&codTrans=0000000000000038&mail=matteo@mr-srl.it&languageId=ITA&TCONTAB=I&url=http://google.it&url_back=http://google.it&mac=3a612baf8286e94ef73a823957567e9c8615cde2) in a new browser tab.  

    So hoping that the process works, what is the javascript command to close the tab at the end?  

     

     

     

    Matteo@MR


  • 27.  Re: HTTP POST/GET request and receive how to

    Posted Tue March 08, 2016 05:54 AM

    Hi Matteo,

    i've attached a sample project for you,

    including a program which opens a new browser tab.

     

    But I think to close a tab is not possible...

     

    Kind Regards!

     

     

     

    Marcel-D

    Attachments



  • 28.  Re: HTTP POST/GET request and receive how to

    Posted Mon May 23, 2016 07:03 AM

    Ok @Marcel-D 185ef4e2-58bb-459d-b414-d02f00ff390d​, it's work!

    And now, how can I close the pop-up page at the end?

    What's the Javascript command that I can use?
    You can integrate your example?

    thank you

     

    Matteo@MR


  • 29.  Re: HTTP POST/GET request and receive how to

    Posted Mon May 23, 2016 07:32 AM

    Hi Matteo,

     

    I attached the sample project including the close function...

     

    Kind Regards!

    Marcel-D

    Attachments



  • 30.  Re: HTTP POST/GET request and receive how to

    Posted Tue May 24, 2016 03:29 PM

    Thanks @Marcel-D 185ef4e2-58bb-459d-b414-d02f00ff390d​, but the project is damaged.
    The source files inside are't valid.

    Can you re-upload the example please?

    Matteo@MR


  • 31.  Re: HTTP POST/GET request and receive how to

    Posted Wed May 25, 2016 02:06 AM

    Hi,

    sorry.

     

     

    EGL RUI:

     

    package test;// RUI Handlerimport com.ibm.egl.rui.widgets.GridLayout;import com.ibm.egl.rui.widgets.GridLayoutData;import egl.ui.rui.Event;import dojo.widgets.DojoButton;import externalTypes.CustomFunctions;////handler test type RUIhandler{initialUI =[ui            ], onConstructionFunction = start, cssFile = "css/test.css", title = "test"}    ui GridLayout{columns = 3, rows = 4, cellPadding = 4, children =[Button_open_url,Button_close            ]};    Button_open_url DojoButton{layoutData = new GridLayoutData{row = 1, column = 1}, text = "Open URL in new Tab", onClick ::= Button_open_url_onClick};    Button_close DojoButton{layoutData = new GridLayoutData{row = 1, column = 2}, text = "Close Tab", onClick ::= Button_close_onClick};    function Button_open_url_onClick(e event in)        open_url("http://google.de");    end    function open_url(url_string string in)        customFunctions CustomFunctions{};        customFunctions.open_url(url_string);    end    function Button_close_onClick(e event in)        close_tab();    end    function close_tab()        customFunctions CustomFunctions{};        customFunctions.close_tab();    end    function start()    endend

     

     

     

    EGL External Type:

     

    package externalTypes;externalType CustomFunctions type JavaScriptObject{relativePath = "customJavaScript", javaScriptName = "customFunctions"}    function open_url(url_string string in);    function close_tab();end

     

    JavaScript:

     

     

    egl.defineClass('customJavaScript', 'customFunctions', {        "constructor" : function() {                var myWindow;        },                "open_url" : function(url) {                myWindow = window.open(url, '_blank');        },                        "close_tab" : function() {                myWindow.close();        }});

     

     

     

    Kind Regards!

    Marcel-D


  • 32.  Re: HTTP POST/GET request and receive how to

    Posted Mon May 30, 2016 08:13 AM

    @Marcel-D 185ef4e2-58bb-459d-b414-d02f00ff390d​ , your sample work fine but I have another problem. :-(

    When you open a new page, the current session is lost.

    When I close the page and go back to the application in the session I have nothing !!!

    How can I save the session before and restore it later?

    J2EELib.setSessionAttr and J2EELib.getSessionAttr not work!!

    Matteo@MR


  • 33.  Re: HTTP POST/GET request and receive how to

    Posted Thu June 02, 2016 02:31 AM

    Hi,

    what do you mean with "J2EELib.setSessionAttr and J2EELib.getSessionAttr not work!!" ?

     

     

    Marcel-D


  • 34.  Re: HTTP POST/GET request and receive how to

    Posted Mon June 06, 2016 02:56 AM

    //Elabora la risposta di pagamento con carta di credito
    function elaboraVposResp(par VPOSResp in)
         tsession = Navigation.currentSession;
         J2EELib.setSessionAttr("tempSession", tsession);
         esitopagamento = par as VPOSResp;
         case
           when (esitoPagamento.esito == "OK")
             tsession = J2EELib.getSessionAttr("tempSession");
             AcquisizionePagamento();
           when (esitoPagamento.esito == "ANNULLO")    
             txtEsitoV.text = "Pagamento annullato";
             //showDialogFrame();
             showDialogPaga();
           otherwise;
             //Errore nel pagamento sul sito del servizio on-line
             txtEsitoV.text = "Pagamento on-line concluso con errore. Riprovare più tardi.";
             showDialogPaga();     
         end   

    end

     

    Matteo@MR


  • 35.  Re: HTTP POST/GET request and receive how to

    Posted Tue June 21, 2016 10:55 AM

    Hi,

    you can't use the J2EELib in the RUI...

     

    You have to put your code in the service which generates java.

     

     

    Kind Regards!

    Marcel-D


  • 36.  Re: HTTP POST/GET request and receive how to

    Posted Tue March 08, 2016 07:08 AM

    Thanks @Marcel-D​, but in my shenario how I do to open my payment url (matteo@mr-srl.it&languageId=ITA&TCONTAB=I&url=http://google.it&url_back=http://google.it&mac=3a612baf8286e94ef73a823957567e9c8615cde2">https://coll-ecommerce.keyclient.it/ecomm/ecomm/DispatcherServlet?alias=3444153&importo=0000001&divisa=EUR&codTrans=0000000000000038&mail=matteo@mr-srl.it&languageId=ITA&TCONTAB=I&url=http://google.it&url_back=http://google.it&mac=3a612baf8286e94ef73a823957567e9c8615cde2)  into new tab from principal handler (Fatture.egl)? With your Js would avoid to pass the url in the Iframe and load it in the dialog box.

    Maybe working on a new page the gateway is able to load the error or confirmation pages properly.  

    The two pages I plan to create them as handler and not widgets. So they will have in their specific url. In the start function do the parser of the utl and get the pagametri response. At the end of the parser, I manage the answer and proceed with the closing of the page in the browser. 

    I attached the source of the main page where you enable the payment process (Fatture.egl) and the source of iframe (IFrame.egl).

    So using your Js how I do to close the new tab opened at the end of the payment process ?

    Matteo@MR


  • 37.  Re: HTTP POST/GET request and receive how to

    Posted Tue March 08, 2016 07:13 AM

    I don't think it is possible to close another web page with web technology. This feature would be heavily abused by pop-ups.

    This is not a limitation of egl, but of web technology in general.

     

    This is where some example code from your service provider would help to understand how he sees the payment process, without having two windows open...

    Bram_Callewaert