Faster way to map parameters in rest service? - Forum - OpenEdge Development - Progress Community

Faster way to map parameters in rest service?

 Forum

Faster way to map parameters in rest service?

This question is not answered

Hello,

in the rest resource uri editor (using a Rest service project in dev studio) is there a way to automatically do the mapping in mapping definitions instead of drag/drop every parameter? For example to automatically map output parameters to response body parameters (to get a json response).

With webservices one can manually edit the xpxg files and compile them, how do one do the same with rest services (what files and where are they located)?

We are using OE 11.3.2, but if there is a better solution in a later version please let us know.

All Replies
  • I might be completely misunderstanding, but….
     
    Don’t create individual output parameters if you didn’t want to map them.  If you want JSON mapped to the body, return JSON and map it to the body (so, only 1 output parameter in your business entity - “OUTPUT TABLE ttTableName”).
     
    The only problem I have with it right now is that you can’t omit the outer object (unless that has been recently fixed).
     
     
    From: stefan.tersin@exicom.se [mailto:bounce-stefantersinexicomse@community.progress.com]
    Sent: Monday, May 11, 2015 5:42 AM
    To: TU.OE.Development@community.progress.com
    Subject: [Technical Users - OE Development] Faster way to map parameters in rest service?
     
    Thread created by stefan.tersin@exicom.se

    Hello,

    in the rest resource uri editor (using a Rest service project in dev studio) is there a way to automatically do the mapping in mapping definitions instead of drag/drop every parameter? For example to automatically map output parameters to response body parameters (to get a json response).

    With webservices one can manually edit the xpxg files and compile them, how do one do the same with rest services (what files and where are they located)?

    We are using OE 11.3.2, but if there is a better solution in a later version please let us know.

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

  • Hi,
     
    As of now we don't have the support to map the parameters automatically for a rest service, from rest resource URI editor of progress developer studio. You have to manually create the mappings for each parameter in both the tabs.
     
    Thanks,
    Rama.
     
    From: WinningJr [mailto:bounce-WinningJr@community.progress.com]
    Sent: Monday, May 11, 2015 5:48 PM
    To: TU.OE.Development@community.progress.com
    Subject: RE: [Technical Users - OE Development] Faster way to map parameters in rest service?
     
    Reply by WinningJr
    I might be completely misunderstanding, but….
     
    Don’t create individual output parameters if you didn’t want to map them.  If you want JSON mapped to the body, return JSON and map it to the body (so, only 1 output parameter in your business entity - “OUTPUT TABLE ttTableName”).
     
    The only problem I have with it right now is that you can’t omit the outer object (unless that has been recently fixed).
     
     
    From: stefan.tersin@exicom.se [mailto:bounce-stefantersinexicomse@community.progress.com]
    Sent: Monday, May 11, 2015 5:42 AM
    To: TU.OE.Development@community.progress.com
    Subject: [Technical Users - OE Development] Faster way to map parameters in rest service?
     
    Thread created by stefan.tersin@exicom.se

    Hello,

    in the rest resource uri editor (using a Rest service project in dev studio) is there a way to automatically do the mapping in mapping definitions instead of drag/drop every parameter? For example to automatically map output parameters to response body parameters (to get a json response).

    With webservices one can manually edit the xpxg files and compile them, how do one do the same with rest services (what files and where are they located)?

    We are using OE 11.3.2, but if there is a better solution in a later version please let us know.

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

    Stop receiving emails on this subject.

    Flag this post as spam/abuse.

  • WinningJr: Thanks for your reply,

    unfortunate we have preexisting webservices we would like to also add as rest services. These procedures dont use temp-tables but have alot of input/output parameters.

    Ramadevi Dhavala: Ok, can we edit the generated files directly (like the xpxg files for webservices)? If so, which ones? Also will you add the ability to remove the temp-table name (like when using write-json omit-outer-object)?

  • Hi Stefan,

    Take a look at the annotations we use for REST services for the JSDO. The annotations provide some customizations but the majority of the mapping is done using defaults based on the signature of the method/procedure. There are less options for mapping (only body or query parameter) but you can avoid the mapper and just automate the generation of the annotations to the source files of your REST service.

    Thanks

    -Shelley

  • Shelly Chase: I am not familiar with JSDO and couldn't find any examples on how to annotate an existing .p-file in a way that removed the need to use REST Resource uri editor. Can you please add an URL to an example?

  • If I understand the question correct: you don't need to be familiar wirh the jsdo for this. Just define a service interface with pds for your .p and take the generated annotations as example for your own codegenerator. It shouldn't be that difficult.

  • agent_008_nl: Using "define service interface" on the .p-file only created the @openapi.openedge.export line and no mappings. Also I don't understand how to take the annotated .p-file and generate the .pidl-file (with supplied tools).

    Basically we don't want to make our own code generator, we have a number of preexisting .p-files (which we already have deployed as web services) and want to generate appropriate .pidl-files (with default mapping), preferably without having to use drag/drop. Much like having a .xpxg-file and generating the .wsm-file when creating a web service.

  • Forgot to mention my name, Stefan Houtzager it is. Strange. I'm on 11.5 and see f.e. the code below after defining the serviceinteface (rightmouse click in pds, above the code-editor choose "progress openedge" and then "define service interface". For the rest I cannot help you, sorry. Your wish looks fair to me, I had a comparable one: community.progress.com/.../18051.aspx

    Regards, Stefan.

    @openapi.openedge.export FILE(type="REST", executionMode="singleton", useReturnValue="false", writeDataSetBeforeImage="false").

    @progress.service.resource FILE(name="custom", URI="/custom", schemaName="dsPurchaseOrder", schemaFile="").

    /*------------------------------------------------------------------------

       File        : custom.p

       Purpose     :

       Syntax      :

       Description :

       Author(s)   :

       Created     : Wed May 20 12:12:59 CEST 2015

       Notes       :

     ----------------------------------------------------------------------*/

     BLOCK-LEVEL ON ERROR UNDO, THROW.

       {"dsPurchaseOrder.i"}

       {"dsFetchRequest.i"}    

    /* ***************************  Definitions  ************************** */

      @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").

      @progress.service.resourceMapping(type="REST", operation="read", URI="?filter=~{filter~}", alias="", mediaType="application/json").

      procedure ReaddsPurchaseOrder:

        define INPUT parameter filter AS CHARACTER no-undo.

        define OUTPUT parameter  DATASET for  dsPurchaseOrder.

       END procedure.

  • Stefan Houtzager: Thanks for your reply, unfortunately we are using OE 11.3.2, however we are looking into upgrading to 11.5. Indeed more automation would be preferable when having large amount of preexisting files.