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

EGL Wrapper Call

Discussion Topic

Discussion TopicTue December 03, 2013 05:37 PM

  • 1.  EGL Wrapper Call

    Posted Tue December 03, 2013 03:37 PM

    I am hoping someone can send me a sample of a SIMPLE native JAVA call to a basic EGL generated wrapper.  I know in it's simpliest terms it creates the call program with parm1 as int and parm2 as string.  If someone could reply with the least of a program that you would use to call such and EGL program and include some simple explanation I would be SOOOO grateful.  I am very new to both EGL and JAVA and really appreciate the help.  Thanks.

    kennetheld


  • 2.  Re: EGL Wrapper Call

    Posted Tue December 03, 2013 04:36 PM

    Hi,

     

    here is a sample project that you can import (using import->General->existing project into workspace->archive file

    In it is

    - an EGL program named hellopgm which takes two parms (strings).

    - a native Java class (main class) named startMe that invokes the HellopgmWrapper class that was generated and sets/gets the parm values

    - the .eglbld file with a linkage table and correct build descriptors to generate the wrapper.

    Hope this helps.

     

    markevans


  • 3.  Re: EGL Wrapper Call

    Posted Tue December 03, 2013 04:56 PM
    Mark, I am not seeing the attachment. Can you resend the attachment? Thanks so much. this sounds exactly what I am looking for.
    kennetheld


  • 4.  Re: EGL Wrapper Call

    Posted Tue December 03, 2013 05:04 PM

    I see in the other post you were able to see the attachment.

    Also, FYI...it was exported using RBD V8.5.1.1.  If you import into RBD V9, it might do a migration which is fine to let it do it.

    markevans


  • 5.  Re: EGL Wrapper Call

    Posted Tue December 03, 2013 05:37 PM

    Mark,

     

    One other email and hopefully I will not bug you any more.  Once I get the project imported should I just do a generate and compile your native JAVA code?  Will there be any tricks you can think of to get things compiled and runable?  Thanks again for all your help.

    kennetheld


  • 6.  Re: EGL Wrapper Call

    Posted Tue December 03, 2013 06:16 PM

    First, can we keep the posts in the same forum entry.  Seems like they are bouncing back and forth between this one and the other one you started.   Let's use this one just to make it simpler.

    What I sent you was a Java project.   It contains the native Java class and the egl source which was generated into Java.  

    Within the workbench, all you should have to do after importing the project is select the StartMe class and then from the context menu, choose "Run as-> Java Application".  The compiled/generated classes are already in it. 

    Outside the workbench, deployment has many meanings.   But the example I sent you is just a normal Java application. 

    So, one way is to export the project as a jar file and then put that jar file in the CLASSPATH and also put the fda7.jar in the CLASSPATH as well.  The fda7.jar can be copied out of the install directories (see the location if you hover over this file in the workbench).   

    There are some instructions in the EGL InfoCenter in the section entitled "Deploying to a non-JEE environment"

    http://pic.dhe.ibm.com/infocenter/rbdhelp/v8r5m0/topic/com.ibm.egl.gg.doc/topics/gegl_core_container_gennonj2ee.html

    markevans


  • 7.  Re: EGL Wrapper Call

    Posted Thu December 05, 2013 09:59 AM

    Mark,

    Just to understand things a little better I am went through the steps using your project as a guide and have created my own wrapper project.  I have also played with adding another parm as a integer,  Finally, I have added a small record to my EGL program and take one of the incoming parms and execute an additional function which   reads a Warehouse record and returns the description of the Warehouse.  While I am currently passing only a description back how easy would it be to pass back the entire record/resultset and how would I define that on the paramters statement within EGL?  

    Thanks for your help.  

    kennetheld


  • 8.  Re: EGL Wrapper Call

    Posted Thu December 05, 2013 12:48 PM

    I have attached an updated project where I added a record to the "hellopgm" and I pass data from the native Java and then receive data back and display it.   You may need to delete the project you have in the workspace and replace it with this or create another workspace.

    Also, there is a pretty decent set of info in the helps related to how to deal with the various datatypes/record types used with the java wrappers.   It can be found at the following link in the EGL Info Center:

    http://pic.dhe.ibm.com/infocenter/rbdhelp/v8r5m0/topic/com.ibm.egl.gg.doc/topics/gegl_java_javawrapperclasses.html

    markevans


  • 9.  Re: EGL Wrapper Call

    Posted Thu December 05, 2013 02:55 PM

    Mark,

    Thanks SO much for your help.  You have really saved the day.  

    kennetheld


  • 10.  Re: EGL Wrapper Call

    Posted Thu December 05, 2013 07:20 PM

    Mark,

    I know you are bound to be tired of hearing from me.  I think I only have one more step to finalize the full circle of what I have been trying to accomplish.  Basically we use a 3rd party product called MRC for much of our Web Facing.  This product allows you to call out to stored procedures, RPG/Cobol programs and native JAVA code.  It forces you to specify the Class and Method when calling Java code.  If I pull out the source and compile the individual Startme.java app would I most likely only have to have the created JAR from EGL in the classpath for everything else to be found?  

     

    Startme will domino through the whole project as you well know.  I was just unsure as to whether I would need to make any other references other than having the EGL JAR in the class path.  Thanks, and I hope I am being clear.  

    MRC program is calling Startme.java which calls the wrapper which calls the EGL code and returns.  

    kennetheld


  • 11.  Re: EGL Wrapper Call

    Posted Fri December 06, 2013 08:30 AM

    Hi,

    You will need all the generated classes as well as the fda7.jar (the EGL Java Runtime).  The generated classes can be exported into a Jar file as part of the whole project including Startme.  (select the project and choose Export->Java->Jar file (or something like that).   This Jar file would need to be on the CLASSPATH.   The fda7.jar needs to be listed on the CLASSPATH as well.   The easiest way to "find" it is to hover over its name in the RBD Project Explorer and it will popup the location.

    That is all I can think of not knowing anything about MRC.

    take care.

    markevans


  • 12.  Re: EGL Wrapper Call

    Posted Mon December 09, 2013 10:42 AM

    Mark,

    I wanted to see if you could possibly shed any light on this error.  When I create a runable JAR file eglwrapper.jar and process manually it works.  When I call it from within my MRC application it calls and links fine but gets the following EGL errors when trying to connect to the iSeries database.  

    egl.core.InvocationException: EGL0150E An error occurred calling the hellopgm program. Error: EGL0509E Cannot connect to the default database. The name of the default database was not specified.
    EGL0002I The error occurred in hellopgm processing the WHRead function.
    EGL0001I The error occurred in hellopgmWrapper.

    While I know you are not familiar with MRC I thought you might be able to shed some light on the following.  I am wondering if the JT400.JAR within MRC might be different from the JT400.JAR EGL was created with???  Maybe some other class file or something missing that EGL needs??  

    Thanks for any help you can provide.  

    kennetheld


  • 13.  Re: EGL Wrapper Call

    Posted Mon December 09, 2013 10:52 AM

    Hi,

    One of the outputs of generation of the hellopgm is some EGL Java Runtime properties.    One of these properties is the connect info for the database (vgj.jdbc.default.database.<name>)

    I don't know if MRC is a web application or a non-Web application.

    For J2EE (web) based applications along with the EGL build Descriptor J2EE = yes, the properties are generated into the web.xml.  It also assumes the use of a datasource.

    For non-J2EE based applications along with the use of the EGL Build Descriptor J2EE=NO, the properties are generated into a file named rununit.properties.  This properties file needs to be in the CLASSPATH and is generated into the root of EGLGen/JavaSource.

     

    NOTE:  Both scenarios above assuming the EGL build Descriptor named genProperties is set to Global (the default if I remember right).

     

    markevans


  • 14.  Re: EGL Wrapper Call

    Posted Mon December 09, 2013 12:35 PM

    Mark,

    Thanks for your reply.  MRC is a web application, but I have a question.  The original hellopgm was set as J2EE = NO.  Since MRC is simply transferring control to Class Startme will it look in the WEB-INF folder or will it use the J2EE = NO setting and expect to find the RUNUNIT.PROPERTIES files with the info?

    Lastly, since this is EGL code failing but running from the MRC server would I need to create the same directory structure from the base package directory all the way to the RUNUNIT file?  In other words, the base package directory in testing under MRC is MRCCLEAN2.  However it is calling a JAR file created from the EGL project and the path there to the RUNUNIT is WRAPPER\WRAPPERCREATION\EGLGEN\JAVASOURCE.  I am asking if I would need to create \EGLGEN\JAVASOURCE under MRCCLEAN2 to place the RUNUNIT.  Since the EGL was created as a J2EE = NO I assume I should follow this path because no WEB-INF would exist for that EGL app.  MRC would have a WEB-INF but I see no way for the EGL app to make it their.  

    I hope all this makes sense.  Let me know your thoughts.  Thanks.

    kennetheld


  • 15.  Re: EGL Wrapper Call

    Posted Mon December 09, 2013 06:10 PM

    Actually, I am not entirely sure if it handles it as a J2EE app or a non-J2EE app in this circumstance. 

    I would first try it with the rununit.properties.   The main thing is the rununit.properties needs to be found on the CLASSPATH..not necessarily a fixed location.   So, either the directory that holds it needs to be added... (try it) or thinking about it, if the rununit.properties was already part of the Jar, I would think it would have "seen" it, but it has been a long time since I tried this.

    Morten posted a similar item today regarding some linkage properties with java wrappers... where he used an extended definition since he was running WAS.

    One thing to try is also to set two other properties that produce trace output as this would let you see which usage triggers a trace.

    The properties are

    vgj.trace.type=-1 (negative 1)

    vgj.trace.device.option=0  (0=stdout, 1=stderr, 2=file)

     

    You could try adding these to the web.xml and seeing if it starts a trace.  If it does, then you know the EGL runtime is looking in the web.xml for properties.    This would be the web.xml for the base WAR project, not one for EGL as the EGL Jar is just a extra jar.

    Sorry, I cannot be more exact on this.   I just have not tried this in a long time.

     

    markevans


  • 16.  Re: EGL Wrapper Call

    Posted Mon December 09, 2013 06:29 PM

    Mark,

    I actually did a SQLLIB.CONNECT within the EGL code and it worked.  I am going to work on getting the connection string passed from MRC to EGL and I should have it licked.  Will there be any gotha's or other problems I am not thinking about in doing it this way?

    kennetheld


  • 17.  Re: EGL Wrapper Call

    Posted Tue December 10, 2013 08:07 AM

    Glad you got it working.

    Assuming all access is a database, then no...can't think of any more problems.  File access also uses info from the rununit.properties, but you have not mentioned that so far.

    And assuming you are using a connection string (URL), then you are using J2EE=NO, so the only trick would be getting the rununit.properties "visible" if you want to go back to the implicit way of connecting.   That said, some people like to use SQLLIB.Connect since it also allows a userid/password to be specified.

    markevans


  • 18.  Re: EGL Wrapper Call

    Posted Tue December 10, 2013 09:35 AM

    Mark,

    What are you talking about when you differentiate between database access and file access?  In the repsonse previous to your last you mentioned me changing the web.xml file in the WAR.  This is a BASIC EGL project and is not running under web properties.  Would that still apply?  This wrapper project does not have a Web Content folder.  

    And as far as the rununit.properties file I have tried a number of things and nothing seems to work.  I am wondering if some of the EGL workings are lost when I call out to this JAR via MRC???

    The sqllib.connect seems to work for what I am currently doing.  If I wanted to make a call to an iSeries RPG program would that work or would I have another set of problems without getting the rununit problem resolved?  

    Let me know.  Thanks again for all your help.

    kennetheld


  • 19.  Re: EGL Wrapper Call

    Posted Tue December 10, 2013 03:22 PM

    Hi,

    A database call is something like DB2 through the JT400 JDBC drivers/DB2 drivers.   This is what you are doing since you are using sqllib.connect.   File access would be access to a serial file (txt, etc) in the servers file system.

    To answer your question on the web.xml.  In some circumstances, the EGL runtime detects that it is running in the context of a web application and based on this will only look in the web.xml. So even though the EGL code itself is not in a web project and the EGL code is just an additional Jar,, it still knows it is running in a J2EE server or context of a web application and looks at the current web.xml.  I don't know that this is the case here..but sometimes it is true.

    So.. maybe all this is a moot point..if the sqllib.connect is working and you can determine how to pass the connection info, we don't need to worry about the properties being found.

    On a call to the iSeries, you can set this up at generation time (server, library or library list, etc) so it is generated into the EGL classes.  In this case, no properties are needed.   If you want these attributes to be set and determined dynamically at runtime, that is also possible, but it does require a properties file to get the values (different than rununit.properties).  Again, this is the technique that Morten was using in his post yesterday.

    markevans


  • 20.  Re: EGL Wrapper Call

    Posted Thu December 12, 2013 10:30 AM

    Mark,

    Do you have a sample project that consumes a public web service?  I have found a few links but have encountered problems with each.  If you have sample code or any direction I would really appreciate it.  I am just trying to understand the process to create an EGL process that will consume a web service and develop around it.  Thanks.

    kennetheld


  • 21.  Re: EGL Wrapper Call

    Posted Tue December 10, 2013 12:49 PM

    Mark,

    One other topic where I would appreciate your input.  Do you know of a link or possibly have a project sample where EGL is being used to query a web service and parse the returned data?  Thanks.

    kennetheld


  • 22.  Re: EGL Wrapper Call

    Posted Thu December 12, 2013 04:24 PM

    do you want to access the service from something generated as Java or from a RUI (i.e. from JavaScript)??

     

     

    markevans


  • 23.  Re: EGL Wrapper Call

    Posted Thu December 12, 2013 06:12 PM

    java

     

    Thanks

    kennetheld


  • 24.  Re: EGL Wrapper Call

    Posted Fri December 13, 2013 01:15 AM

    Hi,

    I attached a sample "ServiceSample.zip" which contains:

    • ServiceProvider: an EGL web project on Tomcat v6, it provides the EGL-generated SOAP service and REST service.
    • ServiceConsumer: an EGL general project targeting on Java, it provides the client that consumes the service, including:
      • Consume_EGLGenerated_SOAPService.egl: client that consumes the EGL-generated SOAP service.
      • Consume_EGLGenerated_RESTService.egl: client that consumes the EGL-generated REST service.
      • Consume_3rdParty_SOAPService.egl: client that consumes the 3rd party SOAP service.
      • Consume_3rdParty_RESTService.egl: client that consumes the 3rd party REST service.

    Also attached two tutorials of how to create/consume service step by step in EGL, please check it. For high level overview of EGL service, please refer to the info center:

    http://pic.dhe.ibm.com/infocenter/rbdhelp/v8r0m0/topic/com.ibm.egl.pg.doc/topics/pegl_core_service_part_cpt.html
    http://pic.dhe.ibm.com/infocenter/rbdhelp/v8r0m0/topic/com.ibm.egl.lr.doc/topics/regl_core_service_part.html

    Thanks & Regards

    PengFeiYu


  • 25.  Re: EGL Wrapper Call

    Posted Fri December 13, 2013 11:01 AM

    I plan to work through the Hello World example you attached.  However, what am I missing in being able to run any of the "myprograms" under the ServiceConsumer project?  I see that they write information back to the console but I am not being able to run.  Can you provide directions as to how these can be ran.  

    Hopefully after that along with working through the Hello World  example I can figure things out.  thanks.

    kennetheld


  • 26.  Re: EGL Wrapper Call

    Posted Sun December 15, 2013 09:43 PM

    Hi,

    In the workbench, please try one of the following ways:

    1. Right click ServiceConsumer/EGLGen/JavaSource/myprograms/Consume_xxx.java, from the context menu, Run As -> Java Application.

    2. Right click ServiceConsumer/EGLSource/myprograms/Cosume_xxx.egl, from the context menu, Debug As -> EGL Program.

    Thanks & Regards

    PengFeiYu


  • 27.  Re: EGL Wrapper Call

    Posted Tue December 17, 2013 04:23 PM

    Mark,

    Can you reply with proper syntax to set a program defined array with a RETURNS value array from a function within EGL?  

    The returns is like  returns(org.datacontract.schemas._004._7.PushWcfService.Models.Asset?[]) and the program has it defined as Assets string[0] 

    I was trying to do an Assets.appendAll(iservice.GetAssetList(CustomerID));

    Thanks.

    kennetheld


  • 28.  Re: EGL Wrapper Call

    Posted Tue December 17, 2013 04:46 PM

    Hi,

    You cannot use a returns clause in a program.   You only receive/pass back parameters. 

    All arguments/parameters are passed both directions

    Example:

    program arrayprog type BasicProgram(myrecin recin, myarrayout string[]) {}
        
        
        assets string[0];
        function main()
            myarrayout.appendall(assets);
        end
        
    end

    record recin type BasicRecord
       mystring string;
       myint int;
       mydecimal decimal(5,2);
      end

    or

     

    program arrayprog type BasicProgram(myrecin recin, assets string[]) {}
        
        
        
        function main()
            assets.appendelement("ABCD");
        end
        
    end

     

    Returns can only be used in functions (service, library, or function to function).

    markevans


  • 29.  Re: EGL Wrapper Call

    Posted Wed December 18, 2013 12:14 PM

    I am having trouble with a WSDL file.  I am getting an error on trying to parse the lines below when I try to run the jsp on the server (TOMCAT).  I can use the "Test with Web Services Explorer" and the web service call works correctly.  No one will be able to verify what I am saying since this web service requires specific IP mapping to reach.  I have attached the whole WSDL.  I can certainly reach out to the provider.  I am wondering if I am missing something in the structure of my project.  I basically imported the WSDL, created the EGL Service Skeleton, setup both the Deployment, Bindings and client.  Any help would be GREATLY appreciated.  Since the canned client works I have got to be doing something wrong with my setup.  

    <xsd:importschemaLocation="http://qawebservicesv2.cooltrax.com/Service.svc?xsd=xsd0" namespace="http://tempuri.org/"/>

    <xsd:importschemaLocation="http://qawebservicesv2.cooltrax.com/Service.svc?xsd=xsd1"namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>

    <xsd:importschemaLocation="http://qawebservicesv2.cooltrax.com/Service.svc?xsd=xsd2"namespace="http://schemas.datacontract.org/2004/07/PushWcfService.Models"/>

    <xsd:importschemaLocation="http://qawebservicesv2.cooltrax.com/Service.svc?xsd=xsd3"namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>

     

    The last three receive an error that states

     

    "Multiple annotations found at this line:

                    - XSD: There is no xmlns declaration for namespace 'http://schemas.microsoft.com/2003/10/Serialization/'

                    - XSD: The location 'http://qawebservicesv2.cooltrax.com/Service.svc?xsd=xsd1' has not been resolved because the

                     import is unused"

     

    This is the complete XML tag.

     

    <xsd:schematargetNamespace="http://tempuri.org/Imports">

    <xsd:importschemaLocation="http://qawebservicesv2.cooltrax.com/Service.svc?xsd=xsd0" namespace="http://tempuri.org/"/>

    <xsd:importschemaLocation="http://qawebservicesv2.cooltrax.com/Service.svc?xsd=xsd1"namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>

    <xsd:importschemaLocation="http://qawebservicesv2.cooltrax.com/Service.svc?xsd=xsd2"namespace="http://schemas.datacontract.org/2004/07/PushWcfService.Models"/>

    <xsd:importschemaLocation="http://qawebservicesv2.cooltrax.com/Service.svc?xsd=xsd3"namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>

    </xsd:schema>

     

    Let me know if you have any thoughts.  I can certainly follow-up with Susan or even the contact at Cool Trax if that is OK.  I think it may have something to do with the way I have files stored in the project but unsure.  Let me know your thoughts.  Thanks.

    kennetheld


  • 30.  Re: EGL Wrapper Call

    Posted Wed December 18, 2013 03:10 PM

    I do not think you understood.  I have sent a little better documentation.  Let me know your thoughts.  

    import org.datacontract.schemas._004._7.PushWcfService.Models.*;

    assets Asset?[0];

    function getAssets()
    SysLib.writeStdout("getAssets before service " + CustomerID);
    assets = iservice.GetAssetList(CustomerID);
    SysLib.writeStdout("getAssets after service " + assetID);
    end

    Record Asset being imported above.

    record Asset {@XMLRootElement{namespace="http://schemas.datacontract.org/2004/07/PushWcfService.Models"}}
      ApplicationType string? {@XMLElement{namespace="http://schemas.datacontract.org/2004/07/PushWcfService.Models", nillable=true}};
      AssetId bigint? {@XMLElement{namespace="http://schemas.datacontract.org/2004/07/PushWcfService.Models"}};
      AssetName string? {@XMLElement{namespace="http://schemas.datacontract.org/2004/07/PushWcfService.Models", nillable=true}};
      ContactMonitoringPoints MonitoringPoint?[] {@XMLElement{namespace="http://schemas.datacontract.org/2004/07/PushWcfService.Models", nillable=true}, @XMLArray{wrapped=true, names=["MonitoringPoint"]}};
      TemperatureMonitoringPoints MonitoringPoint?[] {@XMLElement{namespace="http://schemas.datacontract.org/2004/07/PushWcfService.Models", nillable=true}, @XMLArray{wrapped=true, names=["MonitoringPoint"]}};
      UMDId bigint? {@XMLElement{namespace="http://schemas.datacontract.org/2004/07/PushWcfService.Models", nillable=true}};
      UMDName string? {@XMLElement{namespace="http://schemas.datacontract.org/2004/07/PushWcfService.Models", nillable=true}};
    end

    I have getAssets binded to a screen.  I thought this code would call the function within the web service and bind to variable assets.  When I run it comes back with error 

    EGL0100E An unhandled error occurred. Error: java.lang.NullPointerException.
    EGL0002I The error occurred in ClientPage processing the getAssets function.

    I looked and I have assets defined as 0 array length versus empty.  What else should I look for?  Thanks for your help.

    kennetheld


  • 31.  Re: EGL Wrapper Call

    Posted Wed December 18, 2013 04:06 PM

    hi,

    First, again, I would ask that you open a new thread in the forum when you switch subjects so we don't get answer/ideas intermingled.

     

    On the null pointer, it is hard to say.

    I would look at

    a.) does CustomerID have a value? I did not see that passed in.

    b.) Turn on the EGL Java Runtime trace and see how far it is getting (if at all). The EGL Java Runtime Trace can be turned on by setting the following:

            vgj.trace.type=-1  (negative 1)

            vgj.trace.device.option=0           (0=stdout or console, 1=stderr, 2 = file)

     

    You can find this in the web.xml or the rununit.properties.   It should already be in this but commented out.

    markevans


  • 32.  Re: EGL Wrapper Call

    Posted Thu June 23, 2016 09:15 AM

    Hi Kenneth,

    Even i am looking for examples to call a EGL from a wrapper class, It looks like you succeeded. Can i get some more info on this?

    Thanks in advance.

    Ravi Bhardwaj

    RaviBhardwaj


  • 33.  Re: EGL Wrapper Call

    Posted Tue December 03, 2013 06:37 PM

    Thanks Mark.  Sorry for bouncing between topics.  And thank you so much for all your help.  

    kennetheld