About the Mobile Backend Generator
If you haven’t heard already, there’s a brand-new way to create and deploy an OData service, using the Mobile Backend Generator. The Mobile Backend Generator is a set of tools included with SAP Web IDE that interacts with SAP Cloud Platform Mobile Services. These tools are now available to customers with the latest release of the Mobile Development Kit (MDK) on SAP Web IDE for trial or preview landscapes. You’ll need to create a trial account to use this new feature, if you don’t have one already.
This blog walks you through generating and deploying an OData service to the Neo or Cloud Foundry landscape. Even if you plan to deploy to Neo, you require a Cloud Foundry account as well. Cloud Foundry provides the builder service for the Mobile Backend Generator.
About the MDK
MDK is a feature of SAP Cloud Platform Mobile Services. If you’re new to MDK and want to learn more about developing apps without having to do much coding, you might want to begin by going through this Learning Journey and these helpful videos.
Setting Up Your Environment
Ensure that the SAP Web IDE Full-Stack is enabled.
Select the box and under Take Action, select “Go to Service”.
Select the gear in the left menu (1) and select “Features” (2). Make sure that “Mobile Development Kit Editor V master” is On (3).
Select “Cloud Foundry” (1), verify that you have a builder installed (2) and that it is up to date. When the installation or update is complete, select “Save” (3). I missed this and wondered why I couldn’t continue!
Generating an OData Service
Select the “</>” symbol (1) to enter your workspace. Right-click your workspace folder, select “New” (2) then “Project from Template.”(3)
Change the Category to “All categories” (1) and select “Mobile OData Service Project.” (2) Select “Next.” (3)
Provide a project name (1), then select “Next.” (2).
Provide a service app name (1) and the version (2). Here, for simplicity, I’m using an in-memory database (3), a deployment target of Neo (4) and “None” (5) as the authentication mode. Select “Finish” (6) when done. See Generating an OData Service for choices other than in-memory database.
Add a model to your project by importing a CSDL (Common Schema Definition Language) file that you’ve previously created. Right-click your project folder (1), select “Import” (2), then “File or Project.” (3)
When you see the import screen, browse to the location of your csdl.xml file (1), then select “OK”. (2)
Next, you’ll see a visual representation of your CSDL file. You can use our CSDL graphical modeling tool to create or modify an existing csdl.xml file. This tool is currently available in preview mode.
You can create your own csdl.xml file if you don’t already have one. Right-click your project folder, (1) and select “New” (2), then select “OData CSDL Document.” (3)
You can use either OData Version 2.0 or Version 4.0 (1). Please see Overview for OData versions to help determine what version is correct for you. Provide a schema namespace (2) and a namespace alias (3), then select “Create” (4). The file name is generated automatically from the schema namespace.
Double-click the csdl.xml file to use the graphic editor to graphically create your model. Remember to save your changes!
Right-click your csdl.xml file (1), select “Generate Mobile OData Service” (2) to generate the OData service.
The srv (service) folder now contains new files and folders. Right-click your srv folder (1),
select “Build”(2)(3) .
The target folder now contains an odata-service-version#.war file.
Deploying the Generated Service to Neo
Right-click your generated war file in the target folder (1) , select “Export.” (2) This saves the file locally.
Since you cannot deploy to Neo from Web IDE, move to the SAP Cloud Platform cockpit of your Neo landscape. Select “Tools” (1) from the top menu and select “SAP Cloud Platform Cockpit”. (2)
Once you’re in the cockpit, go to “Applications” (1) then “Java Applications,” (2) then select “Deploy Application”. (3)
Browse to the war file you exported (1) and enter an application name (2) (this is the name that will display in Neo). Select the runtime “Java EE 7 Web Profile TomEE 7.” (3) When done, select “Deploy.” (4)
When the deployment completes, select “Done”. Don’t start the service yet.
Select the service name.
Since this blog used the in-memory database and None as authentication method options, select “Start”. Otherwise, you’ll need to bind your database to your application.
Once the service starts, you see its URL in the Application URLs.
Select this link to access your OData service and make sure it works from a browser.
Deploying the Generated Service to Cloud Foundry
Even though I chose Neo as the deployment landscape, I’ve added the instructions to Cloud Foundry because they are simple!
You can deploy your application to Cloud Foundry from Web IDE. Right-click on your project folder (1) and select “Build” (2), then “Build.” (3)
Right-click on the srv folder (1), select “Run” (2), then “Run as Java Application” (3).
Once the app is deployed, you’ll see a URL just above the console. You can test and debug your service within Web IDE.
Select the link to access your OData service and make sure it works from a browser.
Now you are ready to use your newly generated OData service by building a mobile app with SAP Cloud Platform SDK for iOS, SAP Cloud Platform SDK for Android, MDK or SAP Mobile Cards!
I hope you enjoyed my first blog!