Faster way to map parameters in rest service?

Posted by stefan.tersin@exicom.se on 11-May-2015 04:41

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

Posted by WinningJr on 11-May-2015 07:17

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).
 
 
[collapse]
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.

[/collapse]

Posted by Ramadevi Dhavala on 11-May-2015 08:16

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.
 
[collapse]
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).
 
 
[collapse]
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.

[/collapse][/collapse]

Posted by stefan.tersin@exicom.se on 11-May-2015 08:22

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)?

Posted by Shelley Chase on 19-May-2015 15:32

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

Posted by stefan.tersin@exicom.se on 20-May-2015 03:51

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?

Posted by agent_008_nl on 20-May-2015 05:22

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.

Posted by stefan.tersin@exicom.se on 20-May-2015 06:29

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.

Posted by agent_008_nl on 20-May-2015 07:15

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.

Posted by stefan.tersin@exicom.se on 20-May-2015 07:42

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.

Posted by Sivarami Reddy Marella on 11-Jul-2019 03:17

Hi Everyone,

Do we have any option to map the customized header parameter from the Rest URL in rest adapter?

I have given the Key as "Sourcesystem" and the value is "XYZ", Now i want to get into internal procedure and how to map this in rest adapter.

Your help much appreciated.

Thanks,

Sivarami Reddy

Posted by Peter Judge on 15-Jul-2019 20:26

If you're using PASOE, I'd suggest looking at the web transport - there's no dependency on PDSOE there.
 
Webhandlers let you deal with all of the HTTP parts and do your mapping as you want to.
Look at the Data Object handler if you don't want to write that code. docs.progress.com/.../Use-a-Data-Object-Handler.html has more on this approach.
 
 
 

This thread is closed