Plex 2E

Expand all | Collapse all

Calling a Web Service outside of As400 (system I)

  • 1.  Calling a Web Service outside of As400 (system I)

    Posted May 04, 2011 01:03 PM
    Hi all,
    I need to call a web service outside of the AS400, so I'm the Client for this web service...

    Outside of my Synon model I have done this steps (as on the IBM i Web Service Client for ILE Programming guide) based on Axis (Apache) and C stubs :

    1) In the Qshell environment (STRQSH) and with the command wsdl2ws.sh I have generated my C stubs.

    2) I have created the C modules (with CRTCMOD comand)

    3) I have created the ILE RPG Module (CRTRPGMOD) to call this C Stubs

    4) and I have created one programme to binding all this (the C modules and the ILE RPG Module) with CRTPGM.

    So, outside of synon I call the program (created on step 4) and all this working.

    But, I want to put the programs created on Step 3 and 4 inside of my Synon Model and I need to call the program created on step 4 from one Synon function (EXCEXTFUN).

    So, for step 3 I have created one EXCUSRPGM with target HLL = RP4 and with T-ILE Compilation Type (*PGM/*MODULE) I have change the object type from PGM to MOD. I have compile this successfully;
    for step 4 (the CRTPGM command) I don't know how to do this, because I don't have a synon function type to do the CRTPGM command.

    To workaround, I create one EXCUSRPGM with the same name and parameters as the program created on step 4 and with a lock on.

    Is there any others ideas?

    PS. I'm on synon version 8.5 but I have no synon Web option.

    Tanks,

    Rui


  • 2.  RE: Calling a Web Service outside of As400 (system I)

    Posted May 04, 2011 04:31 PM
    Rui,

    It's much easier than that.

    1. Create an EXCEXTFUN that calls the EXCUSRPGM defined as a *MODULE. Define this EXCEXTFUN as a PGM, type RP4.
    2. Compile the EXCEXTFUN. This will bind the EXCUSRPGM *MODULE to the EXCEXTFUN.

    Now you can call the EXCEXTFUN, and it will call the EXCUSRPGM MODULE. You only need to deploy the EXCEXTFUN, as the MODULE is bound into the *PGM object (you probably know this, just adding for reference).

    HTH.

    Crispin.


  • 3.  RE: Calling a Web Service outside of As400 (system I)

    Posted May 05, 2011 07:18 AM
    Hi Crispin,
    Tanks for your replay.
    So, if I understand your ideia, the steps are:
    1) Create one EXCEXTFUN with type = PGM and target HLL = RP4, so the comand to compile will be CRTBNDRPG.
    2) Inside this EXCEXTFUN call the EXCUSRPGM with type = MOD and target HLL = RP4, so the command to compile will be CRTRPGMOD.

    But something are missing on this...

    Outside of synon the final step is:
    CRTPGM PGM(&Mylib/WS_SINAL) MODULE(STUBSSINAL/*ALL PPPJUPR) BNDSRVPGM(QSYSDIR/QAXIS10CC)

    where:
    STUBSSINAL is one libary on all the C modules are created with the qshell command wsdl2ws.sh;
    PPPJUPR is the EXCUSRPGM (ILE RPG Module) that I refers on step 3 (on my first post) and on 2nd step (on this post)

    So, on the EXCEXTFUN I just call the PPPJUPR (the RP4 Module) but there are missing all the Modules on STUBSSINAL and the reference to the QAXIS10CC SRVPGM on library QSYSDIR.

    How to do this references?

    Tanks,
    Rui


  • 4.  RE: Calling a Web Service outside of As400 (system I)

    Posted May 05, 2011 09:26 AM
    2E has a BNDDIR (YBNDDIR by default). You could add the MODULE's to that, then they should be picked up. Would it make more sense to create a SRVPGM (which you can model in 2E)? I've found an old 2E SRVPGM that holds the CLLE MODULE's created by wsdl2ws. It was back in early 2009 I did this though, and I can't find all the code associated with it.

    I do know that I had a 2E DSPFIL on one machine that was calling a Web Service (that was a 2E WEBSRV on another machine) to get Customer Data. I am pretty sure that it was an EXCEXTFUN that was called from the DSPFIL.

    If I can find the DSPFIL, I may be able to shed some more light.

    Sorry I could not be more help...

    Crispin.


  • 5.  RE: Calling a Web Service outside of As400 (system I)

    Posted May 06, 2011 06:02 AM
    Hi Crispin,
    That was my choice, create a SRVPGM in Synon (on 8.5 this is a new function type...) but I don't know how to call this SRVPGM on my EXCEXTFUN. Now I have the *SRVPGM created on YBNDDIR directory:

    Ver Directório de Enlace

    Directório de Enlace: YBNDDIR Biblioteca: ZGGENDEV

    ---------Criação---------
    Objecto Tipo Biblioteca Data Hora
    PPPKSPS SRVPGM        LIBL 05/05/11 12:08:11

    and on synon model:

    Function name . . : CALL WS Sinal Type : Service program
    Received by file. : PS Sin Mensagens IDS SMG Acpth: *NONE                    
    Workstation . . . : NPT Signature . . : *SRVPGM         
    Source library. . : ZGGENDEV

    Object Source Target
    ? Type Name HLL Text
    SPG PPPKSPS BND CALL WS Sinal Service program

    and the Modules:
    Function name . . : CALL WS Sinal Type : Service program
    Received by file. : PS Sin Mensagens IDS SMG

    ? Module Library Text
    PPPJUPR ZGGENDEV
    ANYTYPE STUBSSINAL
    INT STUBSSINAL
    SINALSOAP STUBSSINAL
    STRING STUBSSINAL

    then my EXCEXTFUN (type PGM and HLL=RP4) was nothing inside (is just to call the SRVPGM).
    I have now one problem: When Synon create my EXCEXTFUN the command is:
    CRTBNDRPG PGM(ZGGENDEV/PPPVXTR) SRCFILE(ZGGENDEV/QRPGLESRC) SRCMBR(PPPVXTR
    ) AUT(*CHANGE) REPLACE(*NO)

    and on synon with option O=Compiler Overrides I see:
    Create Bound RPG Program (CRTBNDRPG)

    Indique opções, prima Enter.

    Program . . . . . . . . . . . . > PPPVXTR Name, *CTLSPEC               
    Library . . . . . . . . . . . > ZGGENDEV Name, *CURLIB                
    Source file . . . . . . . . . . > QRPGLESRC Name, QRPGLESRC
    Library . . . . . . . . . . . > ZGGENDEV Name, LIBL, CURLIB
    Source member . . . . . . . . . PGM          Name, PGM
    Source stream file . . . . . . .

    Generation severity level . . . 10 0-20
    Text 'description' . . . . . . . *SRCMBRTXT                                 

    Default activation group . . . . > NO           YES, *NO                    
    Activation group . . . . . . . . > CALLER       Name, QILE, NEW, *CALLER    
    Binding directory . . . . . . . > YBNDDIR Name, *NONE                  
    Library . . . . . . . . . . . LIBL       Name, LIBL, *CURLIB...      
    + mais valores
    *LIBL                                    

    I check also the *MSG Y2U1022 on my model and I see:

    Message . . : *CRTBNDRPG                 Type. : EXC                          
    Execution environment. : QCMD (QCMD, QCL, OS2, UNX, WIN)
    Command . . : CRTBNDRPG PGM(&2/&1) SRCFILE(&3/QRPGLESRC) DFTACTGRP(*NO)
    BNDDIR(&YBNDDIR) DBGVIEW(*SOURCE) CVTOPT(*DATETIME) ACTGRP(*CALLER)
    OPTIMIZE(*BASIC)

    What could be wrong, or is there anything else to check ???

    Rui


  • 6.  RE: Calling a Web Service outside of As400 (system I)

    Posted May 11, 2011 09:31 AM

    Rui wrote:

    Hi Crispin,
    That was my choice, create a SRVPGM in Synon (on 8.5 this is a new function type...) but I don't know how to call this SRVPGM on my EXCEXTFUN.
    You do realize that you are not calling the service program, you are calling the module contained in the service program. So when you define the module to Synon, and insert a call to the function that points to the module, then you are calling the module (in the service program). You can put multiple modules into that service program, and as long as they are defined to Synon, as you described earlier, you can call them out of the service program as well. If you are having binding problems, you might want to make sure the YBNDDIR binding directory is included in the CRTBNDRPG command. There is nothing magic about CRTPGM vs. CRTBNDRPG other than CRTPGM does no compilation. CRTBNDRPG will work fine because you always have a main program source that needs to be compiled prior to the bind step.

    IMHO, all module should be rolled into a service program. It minimizes multiple copies of code in production. But that's just me.


  • 7.  RE: Calling a Web Service outside of As400 (system I)

    Posted May 11, 2011 09:49 AM

    MarkMurphy wrote:

    IMHO, all module should be rolled into a service program. It minimizes multiple copies of code in production. But that's just me.
    Hi Mark,

    It's not just you :)

    I never liked the MOD type in 2E (or in RPG in general), but I've said that lots of times. It's tantamount to using an Internal Function, because a change to it has to be populated to everywhere it is used. Much rather use a PGM and only have to change it once. Now that we have SRVPGM's though, it finally makes sense...

    Crispin.


  • 8.  RE: Calling a Web Service outside of As400 (system I)

    Posted May 06, 2011 06:15 AM

    Rui wrote:

    Hi all,
    I need to call a web service outside of the AS400, so I'm the Client for this web service...

    Outside of my Synon model .......
    Too late to be of direct help, but I'd use the Russian Advance technique..

    an alternative approach would be to go to Scott Klement's website and download the HTTPAPI set of shareware.

    Given its robustness, breadth, support, and healthy backup forum (and you have the source code) then I cannot imagine a way that making your own stuff can be remotely cost effective or robust enough to match.

    (sounds like a sales job - I have no affiliation etc - just a user )

    and to interface, you write some EXCUSRPGMs and provide interfaces to the bits you need, or inject some EXCUSRSRC if that's appropriate. Either way, your problem becomes integration rather than origination. Given that you know that HTTPAPI works, and can be tested against the web service independantly, your task is suddenly much more predictable.


    But, there may be other constraints, and you have your stuff working


    Bonne chance

    Richard Wilson


  • 9.  RE: Calling a Web Service outside of As400 (system I)

    Posted Jul 04, 2011 10:38 AM
    Hi Richard,

    also late on this one but have you successfully used HTTPAPI to consume a web service generated through 2E.

    Using HTTPAPI I can consume the IBM supplied service to convert Fahrenheit to Centigrade. But when I try with a 2E generated web service, the name tags for the "parameters" <P0RTN></P0RTN> <WP0001></WP0001> aren't being found (stepped through in debug) although they exist in the returned XML.

    I know it's not a 2E problem but wondered if anyone else had been down this route.

    Thanks,
    Mark - Not Yorkshire man, but in Yorkshire.


  • 10.  RE: Calling a Web Service outside of As400 (system I)

    Posted May 06, 2011 11:01 AM
    Hi all,

    Depending upon the skills you have in the team it is also possible to use Java as the wrapper to the web service and then call it from an RPGILE program.
    Here is what we have done on several occasions, use AXIS to create the web service stubs in Java, add some more Java code to keep parameters tidy and handle exceptions, and finally unit test the wrapper using Eclipse Java debugger.
    We were happy with approach as we could leave the web service integration in the realm of of languages and tools which do this very naturally, while the 2E developers got on with building the application. Performance is great, there is a lag on the first call as the JVM is loaded into the iSeries job, after that it's all sweet.
    As we do more and more integration work with web services we are making more use of this technique.


  • 11.  RE: Calling a Web Service outside of As400 (system I)
    Best Answer

    Posted May 06, 2011 12:21 PM
    Hi Matt,

    This is exactly what OP is doing, exceept he's generating C stubs instead of Java stubs (wsdl2ws instead of wsdl2java). The C stubs are callinhg into the AXIS code.

    Interestingly there is now an option in wsdl2ws to generate RPG Wrappers to the C code directly from wsdl2ws, which means that you can bypass the hand coding of the RPG wrappers.

    IWS News

    You can pass a switch to wsdl2ws or just call wsdl2rpg...

    Crispin.


  • 12.  RE: Calling a Web Service outside of As400 (system I)

    Posted Sep 07, 2011 12:44 PM
    Hi Rui:

    It looks like you got a lot of help with your question. Please go back and check the "Mark as Accepted Solution" boxes on the posts that helped solve your problem.

    Thanks,
    Mary