Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
richard_hirsch
Active Contributor

I remember reading a blog from dagfinn.parnas entitled “Exposing a REST API from #SAPNWCloud” in which he describes how to create an application on NetWeaver Cloud that supports REST.

Although Dagfinn used Apache Jersey, there was still a great of development work that was necessary.

A Challenge

I thought to myself – I like a challenge - what about trying to create the same app without any Java coding.

I used Spring Roo and used these commands:

project --topLevelPackage net.rhirsch.test --projectName restpoc

persistence setup --provider ECLIPSELINK --database HYPERSONIC_IN_MEMORY

entity jpa --class ~.domain.FeedEntry --testAutomatically

field string --fieldName senderName --sizeMax 50

field string --fieldName senderEmail

field boolean --fieldName isComment

field string --fieldName parent

field date --fieldName timeCreated --type java.util.Date

field string --fieldName feedText

json add --class ~.domain.FeedEntry

web mvc setup

web mvc all --package ~.controller

web mvc json add --jsonObject ~.domain.FeedEntry --class ~.controller.FeedEntryController

nwcloud enable-deploy

nwcloud enable-jpa

quit

I changed the nwcloud.properties file to contain my properties

I then used maven to deploy the application to the NetWeaver Cloud:

mvn -Dmaven.test.skip=true package nwcloud:deploy nwcloud:start


The Results

A nice web User Interface.

I also got a working REST interface:

The generated REST interface is a bit flaky but it works.


Conclusion

Motto: Never underestimate the power of Spring Roo + NetWeaver Cloud.

JSON, REST, Persistence, WebUI in 16 lines of Roo code and a few maven commands.

Dagfinn’s application is probably a better foundation for a real app but for a quick prototype – nothing beats Roo.

3 Comments
Labels in this area