Motivation to write this blog came from the desire to develop a SAPUI5 based application and deploy on the cloud. It is fairly easy to consume OData based services in UI5. For example you can see how Abhilash developed an UME based SAPUI5 application which is based on OData service. In this case it was great that SAP NetWeaver Gateway was providing the OData service. What if you want to develop an application from scratch? How do you make your application REST and JSON enabled to consume them in UI5. Scratching that itch resulted in this blog 🙂

The most important part of such an application is to figure out how various things play with each other. In our case we have to figure out how are CXF, Spring and Servlets are wired together. Fortunately this has been made easy with the availability of a Maven archetype ( something like a project template). In this blog we will use the org.apahce.cxf.archetype to generate our sample project. Then we would refactor few things to understand the generated code. I would also talk about how various things are tied together in the generated code.

Prerequisites


  1. Completed the setup of SAP NetWeaver Cloud SDK and Eclipse IDE.
  2. Deployed Hello World kind of application on the cloud.
  3. Installed and configured Maven on the Eclipse IDE.
  4. Installed and configure Apache CXF 2.6.1 with Eclipse
  5. Ability to do HTTP POST. I use Google Chrome and Advanced REST client extension with it.    

Since CXF is such an important part of this project, let us make sure it is configured properly by going to Window à Preferences

/wp-content/uploads/2012/08/1_130875.jpg

As you can see I have my CXF installed at the “Location” and it is version 2.6.1.

How to Steps

Fireup your eclipse and create a new Maven project by File -> New -> Other -> Maven -> Maven Project

/wp-content/uploads/2012/08/2_130876.jpg

Skip the default option on the next screen (“Select project name and location”) and hit Next. You would land on the “Select an Archetype” dialog. Make sure All Catalogs is selected and look for the archetype org.apache.cxf in Filter field

/wp-content/uploads/2012/08/3_130886.jpg

Select the archetype with the Artifact Id cxf-jaxrs-service and hit Next. Specify various parameters

/wp-content/uploads/2012/08/4_130887.jpg

Click on finish. If you have prayed to your Maven and CXF gods correctly you should see a new restez project in the navigator with the following structure

/wp-content/uploads/2012/08/5_130888.jpg

By default the cxf archetype sets up the Dynamic Web Module version to 2.4 to the project. But NW Cloud as of now is based on 2.5 so we have to change the Change the Dynamic Web Module version from 2.4 to 2.5 in the project. Right click on project name and go to project properties dialog. In this selct the Facets options and make the necessary change as shown below.

/wp-content/uploads/2012/08/6_130889.jpg

Now we are ready to deploy this generated application. If you are feeling lucky or are the adventurous kind go ahead and deploy the application on the local NW Cloud instance. Or you can wait for the second part of the blog where we would cover the inner workings of this generated app, how it is wired and how to use Advanced Rest Client to talk with it. Till then happy cloud building.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply