Plex 2E

  • 1.  Consuming a web service in 2E

    Posted May 16, 2012 11:23 AM
    Hey everyone,

    I'd love to hear peoples' experiences of trying to consume a web service into 2E.

    2E does not provide such 'consume' functionality automatically. (Of course r8.5 and r8.6 do allow us to deploy/publish/expose 2E business logic as a web service).

    Has anyone had a need to 'consume' a web service into their 2E app? What was the business justification?

    What success did you have?

    What changes would you like to see in 2E to help this situation?

    CHeers,

    Simon

    Simon Cockayne
    CA Technologies
    Principal Software Engineer
    CA Subject Matter Expert
    Tel: +1-703-708-3042
    Simon.cockayne@ca.com


  • 2.  RE: Consuming a web service in 2E

    Posted May 16, 2012 12:45 PM
    Hi Simon,

    Ggreat question!

    So far, I have only consumed a Web Service that was created from 2E. A snake eating it's tail kind of situation. At the time I wanted to a) make sure that the Web Service created from 2E was callable outside of the IWS test harness and b) go through the process of consuming a web service.

    At the time I used the wsdl2c process that creates the stubs. It was extremely complicated and took a lot to get it working (i.e. a technical challenge), but was fun to do. I think there is now a wsdl2rpg script that will provide RPG stubs. I have yet to investigate.

    For the main part I see us providing web services for outside consumption, but I can see situations where being able to consume a Web Service that one of our Customers has published may well become something that we want to do. Not today, but maybe in the future.

    If 2E was able to automate the wsdl2rpg (I suggest this only because I would think it was easier than creating the c or java stubs - but perhaps you could draw on your experience with the EJB java processing) stub creation, and somehow create a function that provided calls to the stubs, I can see that removing a lot of the black art involved in consuming a web service (we, all of it really). I have to wonder if a lot of the EJB processing would somehow fit this. Maybe/maybe not. I expect you have already considered this though :smile

    Crispin.


  • 3.  RE: Consuming a web service in 2E

    Posted May 17, 2012 12:59 AM
    Hi Simon

    At this point we have 'consumed' web services from two other providers and are likely to add a third set in the near future.

    The first use was adding a call to a remote system into our Point of Sale 2E application. This allows data validation and removes the need for users to double enter data into two systems. (We really shold be doing a lot more of this!)

    The second (and likely third) use is where we are effectively replicating parts of our database to a different system. These systems are being supported by third party suppliers to our customer and need bits of database to work. We enhanced our journal monitoring system to allow it to call specific 2E programs when changes are made to specific files. These then pick up the data needed from the wider database and make the appropriate web service call.

    We built RPGLE programs based on Scott Klement's LIBHTTP suite sample program(s). These handle all the messy stuff and we link them into the 2E application by defining them as user programs. The user programs end up having a nice and simple parameter interface - some input and some output parameters and a return code and error message parameters so you have some idea about what happenned inside the web service call.

    I haven't had a need to use arrays when consuming a web service yet:wink: (I don't think I would - the reason for wanting to use an array is because you are going to or from a grid and one wouldn't use a 2E program for as the client side of a SOA would you?) (Though as I write I am thinking that I might have a need to populate a selection screen/pick list via a web service - if you don't know the reference number that needs to be validated it might be useful to allow the user to choose the one.) You could always get the user program to write the database records to drive the selection program but it would be nicer to do that within 2e (or to use one of Lee's selections based on a driver file)

    These programs seem to work well and perform OK. (I haven't needed to stress test them yet (It might be more of a problem at the server end anyway)) Each program is customised in relation to which parameters it accepts, which web service it consumes, and how it parses the return data to find the parameters I'm interested in. It's not that obvious how 2E could help here - particularly as we need the program to be able to call the web service at different locations as we move from test to production.

    cheers Harry


  • 4.  RE: Consuming a web service in 2E



  • 5.  RE: Consuming a web service in 2E

    Posted Jun 06, 2012 09:07 AM
    I would say right now 75% of my time programming is Consuming a web service in 2E. Some soap and some XML.

    Right now I use HTTPAPI from scott for XML used with www.IContact.com and WSDL2RPG for soap.
    I put ever thing in Execute user source with parms then all of then in a Execute external function.

    I have no really programs except when 2E does not support Free Rpg to with parms that well


    EUS01 Header Execute user source

    D/copy /BRC/stub/ICAPI/ICAPISoap.rpgleinc
    D WsStub DS likeds(This_t)
    D OrderHeader DS likeds(OrderHeader_t)
    D ServerHeader DS likeds(ServerHeader_t)
    D StartOrder DS likeds(StartOrder_t)
    D OrderReturn DS likeds(OrderReturn_t)
    D xsd_stringI DS likeds(xsd_string)
    D xsd_stringO DS likeds(xsd_string)
    D HelloReturn DS likeds(HelloReturn_t)
    D ServiceOrder DS likeds(ServiceOrder_t)
    D CampaignInput DS likeds(CampaignInput_t)
    D packageInput DS likeds(packageInput_t)
    D hitInput DS likeds(hitInput_t)
    D hitReturn DS likeds(hitReturn_t)

    EUS02 Stub Config Create Execute user source

    /free
    clear WsStub;
    WsStub.endpoint = %trim(#IR9A3);
    #OS3CD = stub_create_ICAPISoap(WsStub);
    /end-free

    EUS03 Stub Config Destroy
    /free
    #OS3CD = stub_destroy_ICAPISoap(WsStub);
    /end-free


    EUS15 Add Campaign

    D proCode S 10A
    D grpCode S 7p 0
    C MOVEL #ILVJ5 grpCode
    C MOVEL #ILWJ5 proCode
    /free

    clear CampaignInput;
    clear OrderReturn;

    CampaignInput.groupCode.value = %char(grpCode);
    CampaignInput.promotionCode.value = proCode;

    if (stub_op_AddcampaignOrder(WsStub:
    OrderHeader:
    CampaignInput:
    OrderReturn) = *ON);                

    OrderHeader = OrderReturn.OrderHeader_Ref;
    #ORUA3 = OrderReturn.Status.value;
    #OMNH1 = OrderReturn.Message.value;
    else;
    #ORUA3 = 'EX';
    #OMNH1 = 'stub_op_AddcampaignOrder failed';
    endif;

    /end-free