Plex 2E

  • 1.  Web Service with multi-levels

    Posted Jan 22, 2016 11:16 AM

    Hi all,

    I'm trying to create a web service with the following structure:

    1. Header Record (only one record)

    2. Order Header (1 to many)

    2.1 Order Details (1 to many for each order header)

    2.2 Attachments with pictures (pdf, png, jpg, etc.) (1 to 2 for each order header)

     

    3. Return Status (only one)

    3.1 Errors (Code and description) (0 to many for each Header Record)

     

    The Web sevice is to be deployed on Iseries but it is consumed outside (anyone outside, call the web service passing the parameters and have a return status OK or ERROR with the section 3.1 populated).

     

    So, for this, I creating a EXCEXTFUN type MOD RP4 with MIAP. For the parameters, the first is one *array for Header Record passed as RCD; The second is another *array for Order Header passed as RCD Array; the problem is the third parameter, how to fit between the records of the second parameter?

    Another problem is how to deal with attachments?

     

    Thanks in advance,

    Rui

     

       



  • 2.  Re: Web Service with multi-levels

    Posted Jan 31, 2016 05:48 PM

    Hi Rui

     

    If you read Scott Klement's excellent presentation on Web Services https://www.scottklement.com/presentations/Providing%20RPG%20Web%20Services%20on%20IBM%20i.pdf  It shows that the default IBM IWS web server does not support multi level Web Services (Beyond 2 levels) and this is what 2e web services use. I think if you follow the instructions you could quite easily provide what you are asking for, but you would have to retrieve the relevant data and load into data structures within the rpg or possibly supply via arrays, but load data structures within the rpg. I can't see a way this could be achieved using structures available in 2e without writing rpg code as Scott's examples.

     

    The presentation also explains why CA 2e should allow rest-ful JSON services, which it does not.

     

    Nick R



  • 3.  Re: Web Service with multi-levels

    Posted Feb 01, 2016 09:47 AM

    Hi Nick,

    Thanks for your answer and the link to SK excelente presentation. So this is a IBM IWS restriction... To work around I will add a Key field on Order Header and put this same field on Order Details just to link between this 2 structures:

    ......

    2. Order Header (1 to many)

    3. Order Details (1 to many with Order_Header_KEY)

    ......

    Attachments is another IWS limitation...

     

    I hope 2E in the future can also allow REST with JSON.

     

    Rui     



  • 4.  Re: Web Service with multi-levels

    Posted Feb 01, 2016 09:22 PM

    So are these orders being sent in or sent out, either way you should not need a common key-field in structure, as the presence within structure would assume the association. e.g.

     

    Header 1

         Order No 15, Customer A001

              Order Line 1 Product A4223 Qty 6

              Order Line 2 Product A2525 Qty 5

         End Order

         Order No 16 Customer A022

               Order Line 1 Product A2525 Qty 3

         End Order

    End Header



  • 5.  Re: Web Service with multi-levels

    Posted Feb 02, 2016 06:33 AM

    The Orders are being Sent In (the external partie call the WS to sent the Orders).

    The structure you say, are the same as on my first post and is what I would like. So, because I can't create my EEF parameters with a variable array within another variable array (IWS limitation, 2E limitation ???), that's why I put the Order_Header_Key on Order Detail Structure.

     

    Rui



  • 6.  Re: Web Service with multi-levels

    Posted Feb 01, 2016 02:20 AM

    As you say this service is provided for consumption by external parties. In this case I would expect as a 3rd party to be submitting a file upload not a line by line, complicated, slow, service...what happens if a field changes !. I urge you to reconsider your design and put yourself into your 3rd parties shoes and see what problems and headaches they will have consuming such as fiddly service.

     

    Now can 2E do an upload of a file I don't know but that is not the point, I feel you are tackling this issue from a mainframe programmers point of view and not from a service based, easy to do business with, point of view