Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Building RESTful webservices for ABAP still seems to be an issue for SAP Netweaver. In fact, it isn’t. The great article “

Building Mash-Ups and simplifying Application Integration withRESTful Web Services in SAP ABAP

” shows how to implement basic RESTful functionality in ABAP. Let’s take this concept further. 

Hint

All development objects mentioned in this tutorial are available as SAPLink nugget. To avoid inconsistencies while activating, please first activate ZIF_RESOURCE_CONTROLLER and ZRESOURCE_ROUTNG in order to activate any other development objects shipped with this nugget.If you haven’t heard about REST before, you should read this

article

in order to get familiar with the REST paradigm. Please note, the sources for this example are available as a

SAPLink nugget

.

What do we miss?

A good introduction to the REST paradigms is explained in the article. There are some restrictions with this approach. I would like to explain to you, what restrictions are existent and how to bypass them. First of all: For RESTful webservices, a hierarchy of resources would be needed. This means, in terms of the SAP flight model shipped with all WebAS ABAP releases, there should be flight connections (sub-resources) available for certain carriers (super-resources). For example, when performing “GET” requests using a standard browser...

http://<yourServer>/resources/scarr/LH/ returns details of the carrier Lufthansa...0.1.

http://<yourServer>/resources/scarr/LH/SPFLI/* returns all flight connections related to Lufthansa...0.1.

http://<yourServer>/resources/scarr/LH/SPFLI/402 returns the specific flight connection “402” related to Lufthansa.  Second, there should be some kind of delegation logic for our endpoint handler class which is dealing with all requests sent to a specific endpoint. This means, we only want to use one single ICF handler which should be responsible for delegating the requests to another resource handler class according to some routing logic. Parameters passed in the URL, like “LH” and “402” serve as “input parameters” for the methods invoked from this class. The parameters should be handed over in a structured way.

Let’s start

  First, we need to create an endpoint handler for an URL on the Application server.

Call transaction SICF and press F8.

!https://weblogs.sdn.sap.com/weblogs/images/251763241/RA_001.png|height=300|alt=Transaction SICF|width=500|src=https://weblogs.sdn.sap.com/weblogs/images/251763241/RA_001.png|border=0!!https://weblogs.sdn.sap.co...!     

In the tree bar, right click on the “sap” node and choose “New Sub-Element”

!https://weblogs.sdn.sap.com/weblogs/images/251763241/RA_002.png|height=400|alt=Create new independent Service|width=500|src=https://weblogs.sdn.sap.com/weblogs/images/251763241/RA_002.png|border=0

Choose a name for the new independent service. In the example, this endpoint is called “resources”. 

In the maintenance screen, go to tab “Handler List”. Type in the class name of the class which is handling requests sent to this node. In our case, there is already a class which is named ZCL_RESTFUL_CONTROLLER shipped with the nugget file. This class is implementing the Interface IF_HTTP_EXTENSION, since this is needed to register a handler class for a node represented by an URI.

(Please note, the sources for this example are available as a

SAPLink nugget

!https://weblogs.sdn.sap.com/weblogs/images/251763241/RA_010.png|height=450|alt=Define handler|width=600|src=https://weblogs.sdn.sap.com/weblogs/images/251763241/RA_010.png|border=0!</body>

7 Comments