REST Application sample project

Posted by Simon de Kraa on 02-Sep-2014 07:00

Hi,

I have read the "web services" documentation.
http://documentation.progress.com/output/OpenEdge113/pdfs/dvwsv/dvwsv.pdf

Are there any sample projects available for REST applications?
I am just looking for a simple backend implementation like for example:
http://code.msdn.microsoft.com/Contact-Manager-Web-API-0e8e373d

So I can configure the AppServer etc. and run the code for demo purposes.
Just downloaded the latest samples (PROGRESS_OE_11.4_WIN_DOC.zip) but there is no sample available.

I am looking to create something like this:
http://localhost:8081/api/contacts/1 --> {"ContactId":1,"Name":"Glenn Block","Address":"1 Microsoft Way","City":"Redmond","State":"WA","Zip":"98052","Email":"gblock@microsoft.com","Twitter":"gblock","Self":"/api/contacts/1"}

Any suggestions on how to get started please? Thanks. Regards, Simon.

All Replies

Posted by Simon de Kraa on 02-Sep-2014 07:03

Sorry for the bad formatting. I tried to change it but I give up...

Posted by Jean Richert on 02-Sep-2014 07:07

Hi Simon, I just tried to fix your formatting issue.

Posted by ymaisonn on 02-Sep-2014 07:43

Hi Simon,

There is a step-by-step tutorial available online  on the Progress Education site.

In lesson 2, you will learn how to create a REST Web application from an existing Progress OpenEdge ABL application. First, you will learn, how to annotate ABL resources and create a REST service. Next, you will learn how to map REST operations with ABL operations. Then, you will learn how to publish and test a REST service. Finally, you will learn how to export a REST Web application for deployment.

I have attached the exercise files related to this tutorial. This is a self-extracting archive. Your files should be extracted to C:\progress_education\openedge\REST.

Please let me know if you have any question.

Posted by Simon de Kraa on 02-Sep-2014 11:48

Thanks, but I don't have a PEC account and I was hoping there would be an example somewhere in the docs/prokb?

Posted by Thomas Mercer-Hursh on 02-Sep-2014 12:05

Are you a partner, Simon?

Posted by Simon de Kraa on 03-Sep-2014 03:29

Yes.

Posted by Thomas Mercer-Hursh on 03-Sep-2014 09:40

My understanding is that all partners are entitled to a PEC account.  I have never used it, but there was some webinar thing that was posted there and I asked and got a sign in.

Posted by Margaret Collins on 03-Sep-2014 13:17

Hi Simon,

Please contact me at mcollins@progress.com, and I can look up if your company is registered/entitled to PEC seats.

Thanks,

-Margaret

Posted by egarcia on 05-Sep-2014 12:16

Hello,

You may probably be all set on this.

Just in case, I wanted to give you some suggestions.

You can create a REST Service from Progress Developer Studio by creating a new OpenEdge project and using REST as the project type.

You can use an existing ABL program, or create a new ABL procedure or class file to use as a service interface.

You can use the Progress OpenEdge --> Define Service Interface wizard (right mouse click from the editor or Project Explorer) to add the annotations and export the the procedures or methods that you want.

Then you would use the Edit option of the Defined Services node in the Project Explorer to access the REST Resource URI Editor and define the URI and the mapping.

I am attaching a sample program that users the Customer table.

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/customer_5F00_rest.p:550:0]

Here is a link to a video showing how to create the service:

[View:~/cfs-file.ashx/__key/communityserver-discussions-components-files/19/RESTServicePDSOE.mov:550:0]

Link: http://oemobiledemo.progress.com/rest/rest_service.mov

Note: This video corresponds to the same demo presented at the PUG Challenge Americas.

However, the recording at the PUG Challenge was only audio.

You can find the presentation at pugchallenge.org/downloads.html

Look for session 1468: Developing REST support for B2B access to your AppServer application

I hope this helps.

Posted by Simon de Kraa on 12-Sep-2014 03:34

Thank you for your time to answer my question and the examples.

Posted by Simon de Kraa on 12-Sep-2014 03:50

BTW

In customer_rest.p...

Why use the JsonArray instead of just using an output table for ttcustomer?

{"response":{"jsonText":"{\"CustNum\":1,\"Country\":\"USA\",\"Name\":\"Lift Tours\",\"Address\":\"276 North Drive\",\"Address2\":\"\",\"City\":\"Burlington\",\"State\":\"MA\",\"PostalCode\":\"01730\",\"Contact\":\"Gloria Shepley\",\"Phone\":\"(617) 450-0086\",\"SalesRep\":\"HXM\",\"CreditLimit\":66700.00,\"Balance\":903.64,\"Terms\":\"Net30\",\"Discount\":35,\"Comments\":\"This customer is on credit hold.\",\"Fax\":\"\",\"EmailAddress\":\"\"}"}}

(any idea why there are backslahes in the response?)

compared to:

{"response":{"ttcustomer":{"ttcustomer":[{"CustNum":1,"Country":"USA","Name":"Lift Tours","Address":"276 North Drive","Address2":"","City":"Burlington","State":"MA","PostalCode":"01730","Contact":"Gloria Shepley","Phone":"(617) 450-0086","SalesRep":"HXM","CreditLimit":66700.0,"Balance":903.64,"Terms":"Net30","Discount":35,"Comments":"This customer is on credit hold.","Fax":"","EmailAddress":""}]}}}

And why isn't there an option just to return:

{"CustNum":1,"Country":"USA","Name":"Lift Tours","Address":"276 North Drive","Address2":"","City":"Burlington","State":"MA","PostalCode":"01730","Contact":"Gloria Shepley","Phone":"(617) 450-0086","SalesRep":"HXM","CreditLimit":66700.0,"Balance":903.64,"Terms":"Net30","Discount":35,"Comments":"This customer is on credit hold.","Fax":"","EmailAddress":""}

Posted by Simon de Kraa on 12-Sep-2014 04:30

Ok sorry, my question is explained in oemobiledemo.progress.com/.../rest_service.mov.

Sometimes you want to be able to return other structures than the temp-table itself and you can use the JsonArray for that.

Posted by Simon de Kraa on 12-Sep-2014 04:45

And also my last question about returning the following output is answered.

You have to bind the JsonText directory to the Body.

Great!

{"CustNum":1,"Country":"USA","Name":"Lift Tours","Address":"276 North Drive","Address2":"","City":"Burlington","State":"MA","PostalCode":"01730","Contact":"Gloria Shepley","Phone":"(617) 450-0086","SalesRep":"HXM","CreditLimit":66700.00,"Balance":903.64,"Terms":"Net30","Discount":35,"Comments":"This customer is on credit hold.","Fax":"","EmailAddress":""}

Posted by BartMille on 25-Sep-2014 07:45

Would you care to explain your last statement?

"You have to bind the JsonText directory to the Body."

Edit:

Sorry, missed it in the video (no soundcard on my computer).

In the rest-schema tool I had to connect the output to "Body" instead of directly beneath "body".

So:

Wrong:

Right:

Thx for pointing me in the right direction.

Posted by agent_008_nl on 04-Dec-2014 07:53

For me www.progress.com/.../Workshop%20-%20Progress%20Developer%20Studio%20For%20OpenEdge%20-%20Labs%20FINAL.pdf proved a usable intro.

--

Kind regards,

Stefan Houtzager

Houtzager ICT consultancy & development

www.linkedin.com/in/stefanhoutzager

Posted by OctavioOlguin on 17-Jan-2015 22:50

I wonder, why people keeps using quicktime?

I can't see the video in any of explorer, chrome, firefox. .

Even I tought that quicktime was retired some time ago, as I being able to use the computer and see everything, with out never using quicktime in some 8 - 10 years or so..  

I'll keep trying to install that piece of .... of quicktime, as I'm relly intereted on this tutorial.

Greetings you all!!

Posted by egarcia on 18-Jan-2015 09:13

Hello,

I am sorry for the inconvenience.

The video was recorded using the built-in screen recording tool on Mac and the file was exported using the default option (H.264, AAC with an MOV extension).

This format can be played by Windows Media Player (without installing QuickTime).

Are you able to see the video?

Could you try downloading the video and playing it with Windows Media Player?

Here is a link to the file:

oemobiledemo.progress.com/.../rest_service.mov

Please let me know if you still have issues and I can try to covert the file to another format.

Thank you and regards.

Posted by OctavioOlguin on 18-Jan-2015 16:48

Thanks for the tip....

Yes, indeed, I ended watching the tutorial in windows media, as you mention, after installing some full version of quicktime.  It is a very clear and good  intro to rest on OEPDS.  I recommend it.

Thanks for good work.

Posted by egarcia on 19-Jan-2015 05:38

Great.

You are welcome.

I am glad that you were able to watch the video and found it useful.

Thanks.

Posted by Andrzej_Sz on 04-May-2016 03:30

I found this thread very interesting.

I was looking for REST application sample project based on DataSet input-output parameter and Pacific Server but I couldn't find.

Is Business Entity class suitable for that purpose ?

What are REST applications adventages vs. Progress Data Objects.

Regards

Posted by Sanjeva Manchala on 04-May-2016 04:30
Hi,
 
You can use Business Entities for your REST Applications.
 
Progress Data Object Service is also a REST Service with some additional information. Data Object Service generates a catalog file which will be used to communicate with the JSDO while building the Mobile/Web Applications. The catalog file have schema information along with operations defined in the resource.
 
Both REST and Data Object services are accessed using the same URI name space. i.e., http(s)://<host>:<port>/<WebAppName>/rest/<ServiceURI>/<ResourceURI>
 
 
Hope this helps,
Sanjeev.
Posted by Andrzej_Sz on 04-May-2016 05:07

Do you know any sample projects ?

Is Data Object Service more flexible and could be the future of REST service solutions ?

Posted by Ramadevi Dhavala on 04-May-2016 06:18
Hi,
 
We can’t say that Data Object Service is the future of REST service solutions. Each are having their own importance. The following documentation (in the middle) explains the difference between REST and DataObject services.
 
Please find the attached sample (ABLrest.zip) project with some rest service which uses dataset inside a business entity.
 
Thanks,
Rama
 
Posted by Andrzej_Sz on 04-May-2016 07:27

Thank you Ramadevi Dhavala. It's usefull.

What are the possiblities of advanced filtering of data in BE ? Is 'filter' parameter as a JSON descipted in documentation ?

For example, how can I define filter for few 'Customers' and their 'Orders' between 2 dates from Sports database ?

I know, I need 2 tables Dataset.

Posted by Sanjeva Manchala on 04-May-2016 07:40
Hi,
 
Here is the link to documentation which describes filtering pattern of Business Entities which access JSON object as a filter. It describes only one table DataSet (dsCustomer), you have to construct your Business Entity something similar to this one:
 
Thanks,
Sanjeev.
 
Posted by Anil Kumar on 04-May-2016 09:40
Hi Andrzej,
 

We can customize/extend our Business Entity (Read() method) to support to support filtering, sorting and paging operations via JSON Filter Pattern.

 

Following community post has some code samples pertain to JSON Filter Pattern

 

Additional Details:

 

We continue to use the same Read() operation (available in the Business Entity) which accepts filter string as the parameter. Only difference is that the client application sends an HTTP/S request to OpenEdge backend with an encoded JSON object having parameters for ablFilter, top, skip, etc.

 

The OpenEdge backend then runs the Read() method in the Business Entity (ABL business logic with code to support the parsing of the JSON object in the filter parameter) and returns a temp-table or a DataSet with the results set that corresponds to specified parameters.

 
Thanks and Regards,
Anil Kumar.
 
Posted by Andrzej_Sz on 04-May-2016 12:58

Thank you Anil. Very instructive examples.

And could you help with my example, how to define filter for few 'Customers' and their 'Orders' between 2 dates from Sports database (2 tables dataset) ? - {"ablFilter":"Customer.CustNum>1 and Customer.CustNum<10 and Order.OrderDate>01/01/2016 and Order.OrderDate<02/01/2016"}

This thread is closed