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

How to call a Service in a JSP or a JavaScript File (RBD v9.5)

  • 1.  How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Thu December 17, 2015 11:44 AM

    Hey guys,

     

    I'm trying to figure out a way to call a Service (or Web Service) in RBD v.9.5 without using a JSFHandler (since it is now completely removed).

    Is there a specific way to do this?

    Should I use my JavaScript file to call the service directly?

    Should I use my JSP file to call the service directly?

    How would I do these things if I could?

    These questions are what I'm trying to figure out, but I can't find much new documentation for it.

     

    Overall, I'm just not sure what direction to go in to link my service to the front-end without a JSFHandler.

     

    Thanks a lot,

    Murphy

    B2BMRP


  • 2.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Thu December 17, 2015 03:23 PM

    Murphy,

    The summary is that the RUI handler always has to invoke a service to do the database logic, etc.  

    So, the RUI Handler which is generated as JavaScript can invoke an EGL service or a 3rd party service  via SOAP or REST or what is called a "dedicated Service".

    Also, an EGL Service can invoke other services as well.  

    So, the architecture possibilities are the following:

     

    RUI (javascript) <-> EGL Service (Java)  <-> Library/call to remote, etc

    RUI (javascript) <-> 3rd Party Service  <-> Library/call to remote, etc

    RUI (javascript) <-> EGL Service (Java) <-> EGL Service <-> Library/call to remote, etc

    RUI (javascript) <-> EGL Service (Java)  <-> 3rd party service

     

    This is all done via "bindings" in the egldd file (Deployment Descriptor)  just as they were in the JSFHandler.

     

    So in replacing the JSFHandler (generated as Java), you can invoke the service from either the RUI Handler directly or you can choose to create and use an EGL service part to invoke the services you already have in place.

     

    One of the differences between the RUI and JSF is that you can invoke more than one service asynchronously when using RUI and handle the return events as they are returned.   Another difference is navigation between pages is done in the RUI handler (in the browser), not driven by the code in the application server.

     

    A two Rich UI tutorials in the RBD Knowledge Center under Tutorials->Do and Learn.  These give you a good introduction to both RUI and Services and how they tie together.

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

     

    There is also a section called "Service Access in Rich UI" that you may want to look at.

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

     

    Finally, there is some introduction materials under the EGL Distance Learning category of the EGL Learning Center.   They are a little old (written with V8), but they still have good concepts even if all you want to do is look at the slides.   Here is the link:  

    https://www.ibm.com/developerworks/community/wikis/home?lang=en#/wiki/EGL%20Learning%20Center/page/EGL%20Learning%20Center%20Archives/attachments

     

    markevans


  • 3.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Thu December 17, 2015 03:24 PM

    One further note.

    With Rich UI, JSPs are no longer used as the RUI Handlers are generated as JavaScript.
     

    markevans


  • 4.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Thu December 17, 2015 06:15 PM

    Mark,

    Pretend I don't have access to RUI Handlers (for sake of a longer story).

     

    If JavaScript and the JSP were the only options for calling the EGL Service, how would I do this?


    Can I create a Service Binding between the JSP and the EGL Service? Or is there some way to create a Web Service and perform an AJAX call from my JavaScript?

     

    I currently work on a computer with RBD v.9.5 and another with RBD v.9.1.

     

    Thanks in advance,

    Murphy

    B2BMRP


  • 5.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Thu December 17, 2015 06:20 PM

    Well, for any EGL service, you can invoke it via SOAP as long as the EGL service is defined as a SOAP capable service.   This would mean the JSP and the Javascript (and whatever tools you are using) can consume this and know how to invoke it.

     

    I know some folks have invoked EGL REST Services, but I don't have the details on exactly how they have done this. Maybe someone on the forum can tell us how they have done it.    Again, you would have to use whatever method that it is possible to invoke any REST service from the JSP or JavaScript.

     

    Note that the tooling for non-EGL JSPs and Javascript are provided by RAD (Rational Application Developer), not RBD.

     

    take care.

    Mark

     

     

    markevans


  • 6.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Fri December 18, 2015 10:26 AM

    "Well, for any EGL service, you can invoke it via SOAP as long as the EGL service is defined as a SOAP capable service.   This would mean the JSP and the Javascript (and whatever tools you are using) can consume this and know how to invoke it."

     

    Can you expand on this? How do I invoke it?

     

    I have created a SOAP Web Service and have a single method I want to call to test it.

     

    Also, if you find a person that mentions they know how to call a REST service in JavaScript or a JSP, that would be extremely helpful because it would be beneficial to have the service return the data in JSON.

     

    Thanks. 

    B2BMRP


  • 7.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Fri December 18, 2015 10:42 AM

    Murphy,

     

    For SOAP, most tools work by importing/processing the WSDL for the service.   So, generate WSDL for the EGL SOAP service and then use the tools available to you for JavaScript/JSPs to import and create an interface/class/etc. to invoke it.   I can't tell you the steps as I am not familiar with the tools to do native JavaScript and JSPs.

     

    take care.

     

    Mark

    markevans


  • 8.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Fri December 18, 2015 11:38 AM

    Thanks for all the help so far Mark, it's helping me learn the huge amount of information that is available.

     

    Back to a more basic question about RBD v9.5, though, as WSDL services seem to be outdated somewhat.

     

    Let's pretend this is the situation I'm in:

     

    I am using RBD v9.5 and I want to call an EGL Service to retrieve data from an SQL database. My project is NOT a RUI and does NOT contain a RUI Handler. There is no way to call the EGL service directly into my JSP?


    Does this mean that RBD v9.5 is moving towards a strictly RUI Project-based development system? It seems that if I don't want to use a RUI, and I simply create a Web Application consisting of a JSP and JavaScript along with an EGL Service, that this is no longer feasible to do solely in RBD v9.5. 

     

    I don't need OR want a RUI for my Web Application, unless I can somehow make calls to the RUI Handler from my JSP or JavaScript page.

     

    Sorry if I'm asking the question in a confusing way, I might just not be understanding the process of creating a Web Application in RBD v9.5 correctly. It seems as though RBD v9.5 is forcing me into creating a Web Application using a RUI, when all I need and want to use for this particular project is just an EGL service call, an HTML page (or JSP), and a JavaScript file.

     

    Thanks again,

    Murphy

     

     

     

     

     

    B2BMRP


  • 9.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Fri December 18, 2015 12:52 PM

    Murphy,

    An EGL service does not have to be created in a RUI project.

    An EGL service can be defined in EGL project of these types:

    - RUI project

    - Web project

    - General Project

    Each of these are a type of EGL project and you choose which type when you are creating the new project.

    For example, if you have JSFHandler's today, they are in a Web Project which (usually) does not contain any support for RUIs.   In this, you can invoke an EGL service and the service can be defined within this project or a general Project.

     

    So, again the use of RUI or RUI projects is not a pre-requisite for using EGL services.

     

    One consideration though:  In order to have an environment that supports the invocation of web services, you will need to deploy the application/service to Tomcat or WAS.  The easiest way to do this is to develop/generate/deploy/publish the service as part of a Web Project.

     

    As a further example of this (and I know you are not using RUI)...in the RUI tutorials, both have you create a general EGL project which is used to hold the EGL service source.  Then the generated code is deployed to a web project so it can be invoked via the URL.   So, even our RUI examples do not force the creation of a RUI project for the services.

     

    On your comment "It seems that if I don't want to use a RUI, and I simply create a Web Application consisting of a JSP and JavaScript along with an EGL Service, that this is no longer feasible to do solely in RBD v9.5.".

    I don't totally agree with you as this is not the intention of RBD/EGL.    RBD is the product to do development of EGL based applications and is not intended to provide you the license to do any type of development you choose whether it includes EGL or not.   Honestly, I suspect some of the JSP/JavaScript tooling for native development is available since we inherit many plugins from RAD, but you are not technically licensed to do that type of native development with RBD.    RAD is the tool that IBM sells to do native JSP/JavaScript development and it may include additional tools that RBD does not include.    So from that perspective, you are correct that you cannot "solely" use RBD for everything.    However, you can install both RAD and RBD in the same software Development Package and to the developer it will be seamless and look like one tool.

     

    markevans


  • 10.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Fri December 18, 2015 01:58 PM

    Interesting. I haven't heard that both RAD and RBD can both be installed in the same Software Package.

     

    Another way to ask my question though:

    What's the best and easiest way to take a Web Project from RBD v9.1 containing an EGL Service, JSFHandler, and JSP... and then move this to a Web Project in RBD v9.5 (where there is no longer JSFHandlers)?

     

    The project I am working on is currently in RBD v9.1 and I will eventually want to move it to RBD v9.5 very soon. I have no idea how I can recreate and connect to a database in my Web Project without a JSFHandler.

     

    If you were going to move a Web Project from RBD v9.1 to RBD v9.5 and your JSFHandler now does not work, what is your next step?

     

    Thanks.

     

     

    B2BMRP


  • 11.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Fri December 18, 2015 02:04 PM

    Are you doing your database access through the service or the JSF Handler?   In other words, is the JSF Handler invoking a service and then the service is doing the DB i/O.

    If the service is doing the i/o, then you can just use the same Web project you are using and remove all the JSF related EGL Stuff as you replace it.

    If the services are in different packages vs the JSF Handlers, then basically you just keep the services packages.  

    markevans


  • 12.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Fri December 18, 2015 02:07 PM

    And a couple of other points:

     

    a.)  There is nothing that says you have to move to 9.5 right away.   RBD 9.1 will be in support through at least Sept. 2019..so you can continue to use this if you want. 

    b.)  I would still encourage you to go through the first part of the RUI tutorials.  The first steps in the "access a database with Rich UI" create a services project and then access a database.   So, this would get your started.

    markevans


  • 13.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Fri December 18, 2015 02:50 PM

    Mark,

     

    Currently we are accessing the database through the JSF Handler using libraries.

     

    We would like to understand how to turn our libraries into services and call the services from a JSP page. We have about 2,000 JSP pages we would like to use with 9.5 but none of them will currently work.

    B2BMRP


  • 14.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Fri December 18, 2015 02:51 PM

    And to respond to b.):

     

    I have already completed the RUI tutorials twice. I understand how the RUI works with a Service, and how to call the Service from the RUI. I will go through again though and make sure I have not missed anything important.

    B2BMRP


  • 15.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Fri December 18, 2015 04:22 PM

    Ok..good to know that you have been through the tutorials.     You are asking how to create a service, so I was referring to only that part of the tutorials.   How you access a "java" service from a native JavaScript or JSP is the client side and that is based on the tools you are using to "consume" the service.   The EGL tutorials focus on EGL RUI's consuming them, but any client that can consume web services can use EGL SOAP services and I believe as REST services (still waiting on feedback).

     

    You also asked how to turn a library into a service.

     

    Structurally they are identical.   Meaning.

    library mylibrary

       myglobalvar char(3);

        function func1 (var1 type)

                 // statements

        end

        function func2 (var1 type) returns(type)

                  // statements

        end

    end

    service myservice

       myglobalvar char(3);

        function func1 (var1 type)

              // statements

        end

        function func2 (var1 type) returns(type)

            // statements

        end

    end

    The difference in behavior that I can think of are:

    a.)  The service can be invoked from a remote (web service) client.   Libraries cannot

    b.)  In a library, the global variables (defined outside the functions) are directly accessible from the "caller"  (e.x. mylibrary.myglobalvar = "AAA" in the JSF Handler.  Service global variables are not accessible except inside the service.

    c.)  Services can return an exception in the client if the service invocation fails.

    d.) Services need service deployment information which is contained in the .egldd file

     

    So, you "should" be able to do the following to convert them:

    - Change the "type" from "library" to "service"

    - Create an .egldd file in the web project (if not already there).

    - Add service deployment entries to the .egldd for the services you want to expose.

    - Create WSDL for the SOAP services (from the context menu).

    - Change the build descriptors used to generate the java to specify the service runtime

    - If you were expecting global variables to be accessed, you will probably have to imbed them with an invokable function rather than direct access

    - You need to generate the service parts AND the .egldd file.

     

    You may also have to create a new web project and copy the source you want to convert into it.  Sometimes it helps to start with a new web project already targeting the application server you want to deploy to.

     

    hope this helps.

    Mark

    p.s. I will be on holiday for a couple of weeks, so my responses may be slow.

    markevans


  • 16.  Re: How to call a Service in a JSP or a JavaScript File (RBD v9.5)

    Posted Mon December 21, 2015 09:47 AM

    Mark,

     

    Thank you, that did help a lot. Hopefully some other RBD users will come across this and it will help them out some, too.

     

    Hope you enjoy your holidays! Glad I caught you in time.

     

    Thanks,

    Murphy

    B2BMRP