REST Application sample project - Forum - OpenEdge Development - Progress Community
 Forum

REST Application sample project

  • 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.

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

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

  • REST.exe

    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.

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

  • Are you a partner, Simon?

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • Yes.

  • 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.

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • 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

    MARGARET COLLINS

    Sr. Manager, Education Design and Development

  • 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.

    customer_rest.p

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

    Click here to play this video

    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.

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

  • 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":""}

  • 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.

  • 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":""}

  • 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.