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
  • 1.  Accessing IBM i programs as Web services

    Posted Sat October 16, 2010 09:49 AM
    How do I access my IBM i RPG program using a stateful REST service?

    I'm trying to use the section titled 'Accessing IBM i programs as Web services' (within the help documentation) to help me do this, but I'm struggling.

    There are three steps outlined in the documentation:

    1) Create an external type (type HostProgram)

    I'm fairly happy with this bit as there is an example in the documentation to work from, so I created the following EGL code in a new EGL source file.

    package programs;   externaltype IPROG1 type HostProgram {platformData=[@i5OSProgram{ programName="IPROG1", programType=NATIVE, isServiceProgram=false, libraryName="RXMEGL"}]} function IPROG1(text char(40)){ hostName="IPROG1"}; end


    As I understand it this makes my IBM i RPG program known to EGL. It tells EGL that my RPG program is called IPROG1 and sits in library RXMEGL, and that it accepts a single 40 long character parameter.

    2) In the Services deployment section of the EGL deployment descriptor editor, select that external type and enter other appropriate information.

    This is where it all starts getting a bit tricky. I go to my deployment descriptor editor, select the Service deployment tab and then press the Add button. In the 'Add Web Services' wizard I can see the external type that I just created so I select that, I leave the generate as SOAP Service and TEST service ticked and press the Add --> button. I then press the Finish button.

    Is that all I need to do? I'm not sure whether the '... enter other appropriate information.' means I need to enter anything else or not. I am leaving the SOAP Web Service Properties and REST Web Service Properties on the Generate Web Service panel as they are, mainly because I don't know what to enter in them! I then press CTRL-S and exit the deployment descriptor editor.

    3) Deploy the resulting Web service to a JEE-compliant application server.

    I think I'm OK with this bit. I select Deploy EGL Project and then restart my tomcat server, once the deployment has completed.

    Now that's complete I'm not sure what to do next. I somehow want to access the service from my EGL code and I also need to point the service to my IBM i server but I'm not sure how to do that. I've been reviewing the forum and the help documentation but haven't been able to find any documentation that takes me to the next step.

    This is what I tried.

    I created a new RUI handler that had a single TextField, I then added the following code.

    function start() myService pgmIPROG1{}; text string; call myService.IPROG1(text) returning to myCallback; end function myCallback(text string in) TextField.text = text; end


    The EGL editor came up with an error on the 'myService.IPROG1' function stated it must be defined as a service or interface part.

    When I was trawling through the help documentation I remembered seeing something about an interface part so I found a section titled 'Creating an Interface part to access a REST service', which I then followed to create the following interface part.

    package interfaces;   interface pgmIPROG1 {@xml{name="pgmIPROG1" }} function IPROG1( text string inout ) {@xml{name="IPROG1"}}; end


    I then updated my RUI handler to call my new interface part rather than the external part. When I saved my RUI handler I get the following EGL generation result.

    IWN.VAL.8008.e 18/0 The service variable 'myService' uses an interface part 'pgmIPROG1' which requires a binding annotation or no initialization block.

    Back in the help documentation I found a section called 'Adding a REST binding to the deployment descriptor'. So I went in to the Service client bindings in the deployment descriptor editor and clicked the Add button. I then selected a binding type of REST Web Binding and pressed the Next button. The 'Add a Service Client Binding' wizard then asked for the REST binding name, I hit the Browse button and selected my interface part. It then asked for a BASE URI, I'm not sure what this should be, based on the on screen example text I entered http://localhost:8080/testWEB/restservices/pgmIPROG1. I left the Session Cookie ID blank and pressed Finish. I pressed CTRL-S and closed the deployment descriptor editor.

    I went back to my RUI handler but it still comes up with the same message.

    So, I think the questions for me to move forward are ...

    a) Is everything I've tried above correct?
    b) How does the service know about my IBM i server?

    Any and all help, pointers, links would be very much appreciated.

    Richard
    SystemAdmin


  • 2.  Re: Accessing IBM i programs as Web services

    Posted Sun October 17, 2010 04:29 PM
    Hello Richard,

    To answer your questions:
    a) Your approach seems pretty much OK. However the call to the service interface is not correct. It should look like:
    myService pgmIPROG1{@WebBinding{wsdlLocation="wsdl/IPROG1.wsdl", wsdlPort = "IPROG1", wsdlService = "IPROG1"}}; text string = ""; call myService.IPROG1(text) returning to myCallback onException serviceExceptionHandler;

    Notice:
    • You mentioned you generated the service as SOAP. For SOAP services a WebBinding as shown above should be used.
    • When you generated a REST service the Binding should look like: @RESTBinding{baseURI = "http://localhost:8080/testWeb/services/IPROG1"} Notice the end of the Binding where you should provide the name of the service (IPROG1), rather than the name of the service interface (pgmIPROG1).
    • You can also use '@BindService{}' and provide the necessary information in the EGL Deployment Descriptor under the 'Service Client Bindings' tab.

    b) In the EGL Deployment Descriptor you should create a Protocol using the 'Protocols' tab in the EGL Deployment Descriptor Editor.
    Then this Protocol must be linked to the service. This is also done in the EGL Deployment Descriptor, under the 'Service Deployment' tab.
    The settings of the Protocol should look like:
    conversionTable: CSOE037
    library: *LIBL
    location: myIBMi.myDomain.com
    password: *****
    userID: myUser

    Hope this helps you further.
    Ortwin


  • 3.  Re: Accessing IBM i programs as Web services

    Posted Mon October 18, 2010 07:39 AM
    Ortwin, many thanks for the advice. I'll try this later and will post my results.

    Richard
    SystemAdmin


  • 4.  Re: Accessing IBM i programs as Web services

    Posted Tue October 19, 2010 08:22 AM
    I've got a bit further but there still seems to be a problem.

    I've modified my RUI handler to include the SOAP details you outlined, I did make one small change (see below) to wsdlLocation as looking on my web server the wsdl file was called pgmIPROG1.wsdl. I also created the protocol entry and linked this to my service.

    myService pgmIPROG1{@WebBinding{wsdlLocation="wsdl/pgmIPROG1.wsdl", wsdlPort = "IPROG1", wsdlService = "IPROG1"}};


    When I run my RUI handler from the deployed web server (or from debug) I get the following error.

    An exception has occurred: EGL1541E An exception occurred during a SOAP service call. Binding:pgmIPROG1, Service:IPROG1, Port:IPROG1, WSDL location:wsdl/pgmIPROG1.wsdl EGL0001I The error occurred in EGL Rich UI Proxy.
    Detail1: 500
    Detail2: FAILED
    Detail3: java.lang.NoClassDefFoundError: com/ibm/etools/egl/wsdl/model/WSDLModel

    Richard
    SystemAdmin


  • 5.  Re: Accessing IBM i programs as Web services

    Posted Fri October 22, 2010 02:30 PM
    Hello Richard,

    Did you generated the WSDL?
    Right click on the Interface Part and generated the WSDL in package 'wsdl' in the EGLSource folder.
    Ortwin


  • 6.  Re: Accessing IBM i programs as Web services

    Posted Thu September 14, 2017 04:49 PM

    Ortwin

     

    Subject has been discontinued ..

    Tell me one thing .. have you solved the subject of error "EGL1541E" ??

     

    Osvaldo Menezes

    ojomenezes