Skip to Content

This  blog is about Integration Gateway in SAP Mobile Platform 3.0 (SMP).

It is a follow-up of the previous blog, where I explained how to implement the CREATE operation for your OData service, based on a REST data source.

Since SMP SP07, DELETE operation is supported by Integration Gateway.

If you’re new to the topic, check the Links section below where you can find the tutorials which get you up to speed.

Update:

The sample REST service is now made available for public usage, so I’ve updated the tutorial to use it.

Also, the code is attached to this blog.

Prerequisites

I expect that you’ve gone through my previous tutorials, explaining REST data source – QUERY and READ and CREATE operation – based on XML payload.

Please check the Links section for the relevant blogs.

Furthermore, you need:

  • Eclipse with SAP Mobile Platform Tools installed
  • SMP SP07
  • Basic knowledge about OData provisioning using the Integration Gateway component of SMP

Preparation


REST Service

For this tutorial, we need a REST service that supports writing scenario.

I’m using a service that is public available, you only need to sign up, afterwards you can access it with your SCN  user and password.

Please see the following document for details:

Getting started with the SAP Netweaver Gateway Service Consumption System

Finally, you should be able to access it via the following URL:

https://sapes1.sapdevcenter.com/sap/opu/rest/address/companies

Destination

In your SMP, you need to create an HTTP destination to the following URL:

https://sapes1.sapdevcenter.com

Furthermore, you need to download the certificate and import it into your SMP keyStore.

Note:

For this Destination, it isn’t possible to do a “Test Connection”, as the server doesn’t send a valid response.

As a workaround, you can proceed as follows:

Create a second destination, which is only used to test if the target host can be reached.

This second destination points to a URL that actually can send a valid response.

For example, enter the following URL as destination URL:

https://sapes1.sapdevcenter.com/sap/opu/rest/address/companies

So, you use this second destination to do the “Test Connection”.

If this succeeds, then the first destination should be fine as well.

This first destination will be used to configure our OData service, that we create in this tutorial.

If you get an error message on connection test, you might consider the following:

Note that you might need to enter proxy settings in your SMP:

https://localhost:8083/Admin/ -> Settings-> System

Note that you might need to restart the SMP server after changing the proxy settings.

OData Model

The OData model for this tutorial is the same like in the previous tutorial:

You can simply continue with the project that was created for the previous tutorial.

Bind data source

The Relative URI is the same like for the READ operation

/sap/opu/rest/address/companies/{ID}

Please check my previous tutorials for explanation about how to compose the Relative URI

Custom Code

Generate the Custom Code for Groovy.

For the DELETE operation, we don’t have to implement anything.

Why?

In the processRequestData() method, there’s no special requirement regarding request header or request body

In the processResponseData() method, no response body will be returned, according to OData specification.

Note:

If your backend requires additional handling, then of course you have to provide the implementation here

For example, my backend REST service requires the x-requested-with header to be set, while sending the request.

Therefore, I’m adding the following line to the processRequestData() method

def Message processRequestData(message) {

    message.setHeader(“x-requested-with”, “XMLHTTPRequest”);

       return message;

}

Result

In order to test the DELETE  operation, proceed as described in the previous tutorial.

The response status code should be 204 No Content and the response body should be empty, as can be seen in the screenshot below.

Summary

In this tutorial, we’ve learned how to implement the DELETE operation in a Groovy script.

We’ve seen that it’s easy, as no implementation is required to fulfill the task

Links

Installing SMP Toolkit:

http://scn.sap.com/community/developer-center/mobility-platform/blog/2014/08/22/how-to-install-sap-mobile-platform-tools-for-integration-gateway-in-eclipse-kepler

Tutorial for OData provisioning in SMP:

http://scn.sap.com/community/developer-center/mobility-platform/blog/2014/06/10/creating-an-odata-service-based-on-sap-gateway-soap-jdbc-and-jpa-data-sources-ba

Preparing Eclipse for Groovy scripting: http://scn.sap.com/docs/DOC-61719

Introduction in REST datasource part 1: Understanding the return structure in xml

http://scn.sap.com/community/developer-center/mobility-platform/blog/2015/02/10/understanding-rest-data-source-in-integration-gateway-1-query-very-simplified

Introduction in REST data source part 2: Understanding the return structure in json

http://scn.sap.com/community/developer-center/mobility-platform/blog/2015/02/11/integration-gateway-understanding-rest-data-source-2-query–json-very-simplified

Introduction in REST data source part 3: Implementing the QUERY operation

http://scn.sap.com/community/developer-center/mobility-platform/blog/2015/02/12/integration-gateway-understanding-rest-data-source-3-query–xml-standard

Introduction in REST data source part 7: Implementing the READ operation

http://scn.sap.com/community/developer-center/mobility-platform/blog/2015/03/06/integration-gateway-understanding-rest-data-source-7-read–xml

Introduction in REST data source part 9: Implementing the CREATE operation

http://scn.sap.com/community/developer-center/mobility-platform/blog/2015/04/21/integration-gateway-understanding-rest-data-source-9-create-operation

Overview of all REST blogs

http://scn.sap.com/community/developer-center/mobility-platform/blog/2015/04/08/integration-gateway-rest-data-source-overview-of-blogs

The official documentation: http://help.sap.com/mobile-platform/

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