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.
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:
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.
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
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;
}
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.
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
Installing SMP Toolkit:
Tutorial for OData provisioning in SMP:
Preparing Eclipse for Groovy scripting: http://scn.sap.com/docs/DOC-61719
Introduction in REST datasource part 1: Understanding the return structure in xml
Introduction in REST data source part 2: Understanding the return structure in json
Introduction in REST data source part 3: Implementing the QUERY operation
Introduction in REST data source part 7: Implementing the READ operation
Introduction in REST data source part 9: Implementing the CREATE operation
Overview of all REST blogs
The official documentation: http://help.sap.com/mobile-platform/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
22 | |
11 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 |