This guide will give a clear understanding on how to create an OData service for a given SAP Gateway data source. Here, i am using publicly available demo gateway service : Flight example
Service URL :
https://sapes4.sapdevcenter.com/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/
Note:
To access this URL, you must have an account on SAP Gateway Demo system.
How to get access
Now,to make this service available through SMP 3.0 server, i am going to import it in eclipse and then will deploy to SMP server.
Tools Used: Eclipse
Luna,
SAP Mobile Platform 3.0 SP10 PL01 Advanced REST Client
Steps:
Prerequisite:
Installing "SAP Mobile Platform Tools" latest version 1.6.2 in Eclipse Luna Reference Document
- Create a new project in Eclipse Luna, make sure to select proper "Target Runtime"
2. Select
Model Content as "
OData Service URL" , Click "
Next"
3. Provide the service URL
https://sapes4.sapdevcenter.com/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/ and click "
Go". Enter correct credentials to connect to sapes4.sapdevcenter.com server
Note:
Not able to retrieve the service details? Look at Troubleshooting #1.
4. Once done, you can see the automatic creation of OData entities.
5. Next task is to assigning data sources to each and every Entitysets.
- Right click> FlightModel.odatasrv >Select Data source
- Name : RMTSAMPLEFLIGHT
- Make sure you specify Namespace as "IWBEP" (not SAP as always)
-
The ODC data source is only used for services registered under the iwbep node. For the SAP Gateway service coming from the Hub, you need to bind it with REST data source NOT as ODC data source. Reference
Note:
How to identify what is the correct Namespace for a particular SAP gateway service? I generally prefer to a cross-check from step #9.
6. Right click project >
Generate and Deploy Integrate Content
7. Now, i have to register
RMTSAMPLEFLIGHT service in
SMP Management cockpit
<<From SMP 3.0 SP08 Runtime onward, SMP Gateway cockpit has been integrated into SMP Management cockpit>>
Note: Make sure if you have imported ES4 certificate into SMP Keystore. How to do? Check troubleshooting #5
8. Select the "
ES4" destination, click on "
Test Connection". You should see a
SUCCESS message.
Note: Not able to ping successfully? Look at Troubleshooting #2
9. Register Back-End service from ES4 sever
- Click on "Register a New Service" under SERVICES
- Select Destination as "ES4"
- Type RMTSAMPLEFLIGHT in search
- Click on "Register"
This is how it should look like:
Note: As you can see the "
IWBEP" is the namespace of the service coming directly from server "ES4" and "SAP" is the namespace of the service deployed through Eclipse.
10. Add destination "ES4" to the service "SAMPLEFLIGHT" by clicking on it.
Note:
I didn't find assigning a destination (ES1) to the deployed OData model (SAMPLEFLIGHT) since backend service (RMTSAMPLEFLIGHT) has already been registered in gateway cockpit. But for best practices it is good.
You should see that "ES4" destination has been mapped to service "SAMPLEFLIGHT".
11. Open "Service Document" as highlighted above. (Assuming you have created a security profile named "SAP" in admin cockpit)
https://jk:8083/gateway/odata/SAP/SAMPLEFLIGHT;v=1
This URL will return all entity sets contained in the service
12. To test each Entityset details, just add the Entityset name at the end of above URL.
e.g.
a.
https://smpserverip:8083/gateway/odata/SAP/SAMPLEFLIGHT;v=1/CarrierCollection('AA')
This URL will return carrier CARRIER NAME, CURRENCY CODE, URL for Carrier ID "AA"
b.
https://smpserverip:8083/gateway/odata/SAP/SAMPLEFLIGHT;v=1/TravelagencyCollection
This will return all Travel Agencies details available in ES1 system.
c.
https://smpserverip:8083/gateway/odata/SAP/SAMPLEFLIGHT;v=1/SubscriptionCollection
d.
https://smpserverip:8083/gateway/odata/SAP/SAMPLEFLIGHT;v=1/FlightCollection
CUD operation:
CREATE: I am getting '500 Internal Server Error'
UPDATE:
First i need to get X-CSRF-TOKEN value using GET method
Pass mentioned value in header section for updating a record: image link
Dropbox - PUT1.png
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<content type="application/xml">
<m:properties>
<d:CARRNAME>British Airways</d:CARRNAME>
<d:CURRCODE>USD1</d:CURRCODE>
<d:URL>http://www.aa.com</d:URL>
<d:mimeType>text/html</d:mimeType>
</m:properties>
</content>
</entry>
You can verify the same in the browser by just running the OData URL
Dropbox - PUT2.png
DELETE:
Dropbox - DELETE.png
<<I was not able to upload images in the blog so i have placed it at dropbox for time being. I am checking why i am not able to insert images here , will update it soon>>
Troubleshooting:
If you are using any proxy setting to access any external network, you may encounter below issues:
(A). Connection timed out: connect
Resolution: Go to Windows>Preferences>Network Connections. Select Active provider as 'Manual' and provide proxy details for HTTPS. Check
Reference Document for more details.
(B).
Connection has Failed: Connection to https://sapes1.sapdevcenter.com:443 refused
Resolution:
Set HTTP/HTTPS proxy settings in Admin cockpit. > SETTINGS>SYSTEM
(C). Could not retrieve services from the destination ES1
Resolution:
Set the proxy server details for the destination ES1. Go to path:C:\SAP\MobilePlatform3\Server\config_master\service.destinations\destinations
Open ES1. And proxy details.
e.g. Proxy=proxyserver:80
save the file and NO need of restarting SMP server.
(D). When you try to access any entityset information, you are encountered with message saying "Error in Getting the service",
Check if you have missed registering the service as mentioned in step #9.
(E). Importing ES1 HTTPS certificate into SMP server keystore
Open https://sapes1.sapdevcenter.com/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/ in a browser ( i did in chrome) and follow below screenshots:

Select Base-64 encoded option

You can export it anywhere as per your wish (for me its on Desktop) and you should see a successful message at last.
From SMP 3.0 SP08 Runtime onward, you can directly import certificate into SMP keystore through SMP Management Cockpit.
Note: This has to be done only and only by Administrator.
Open SMP Management cockpit: https://localhost:8083/Admin/ > SETTINGS>CERTIFICATES
You have to restart SMP server
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This below method is valid if you are working with SMP3.0 SP07 server or lower version
Once certificate export is done, open a command prompt and run below keytool command:
C:\SAP\MobilePlatform3\Server\configuration>keytool -import -v -alias sapgatewaycert -keystore smp_keystore.jks -storepass s3pAdmin -file c:\Users\Jitendra\Desktop\ES1.cer
Note, the password shown above, s3pAdmin, was a value that was requested during the SMP 3.0 server install. Replace changeit with the value you specified during the install. Note that the SMP 3.0 server needs to be restarted after making this change.
One tool which provides a graphical view of the contents of keystores is
KeyStore Explorer.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
(F). Peer not Authenticated
Pinging the destination through an error: Connection test failed-Peer not authenticated
When i looked into its 'Certificate' details, then came to know that its certificate had already expired. Delete this and import a new valid certificate.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
(G). Log Settings
Logon to Admin Cockpit > Logs > Settings
Log Level > debug
Trace > Enabled
Follow these forums for latest update on SAP Mobile Platform 3.0 : ,
Note: Big thanks to
bjoernw for helping me in writing this blog.