Skip to content

Commit d2bcb5e

Browse files
committed
Update Mobile Back-End Tools tutorials
1 parent 4e1ee10 commit d2bcb5e

File tree

6 files changed

+129
-79
lines changed

6 files changed

+129
-79
lines changed

tutorials/cp-mobile-backend-tools-cache-db/cp-mobile-backend-tools-cache-db.md

Lines changed: 77 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ author_profile: https://github.com/manuel-stampp
4242

4343
Open the file `mtad.yaml` that you created in the previous Tutorial [Create a Simple OData Service with Mobile Back-End Tools](cp-mobile-backend-tools-simple-odata).
4444

45-
In the application's **requires** section, after `- name: MbtEpmDemoService-xsuaa` (line 20), add another line with
45+
In the application's **requires** section, after `- name: MbtEpmDemoService-xsuaa` (line 27), add another line with
4646

4747
```YAML
4848
- name: MbtEpmDemoService-destination
@@ -65,83 +65,106 @@ author_profile: https://github.com/manuel-stampp
6565
```YAML
6666
---
6767
ID: MbtEpmDemoService
68-
_schema-version: "3.3"
68+
_schema-version: '3.3'
6969
version: 1.0.0
7070
modules:
71-
-
71+
-
7272
# application
7373
name: MbtEpmDemoService
7474
# module
75-
path: srv/target/odata-service-1.0.0.war
75+
path: srv/deploy/odata-service-1.0.0.war
7676
type: java
77-
parameters:
78-
memory: 1G
79-
disk: 2G
80-
instances: 1
81-
properties:
82-
SET_LOGGING_LEVEL: '{odata: TRACE, sap.xs.console: TRACE, sap.xs.odata: TRACE}'
83-
TARGET_RUNTIME: tomee7
77+
parameters:
78+
instances: 1
79+
memory: 2G
80+
disk: 2G
81+
properties:
82+
TARGET_RUNTIME: tomcat
83+
JBP_CONFIG_COMPONENTS: "jres: ['com.sap.xs.java.buildpack.jdk.SAPMachineJDK']"
84+
JBP_CONFIG_SAP_MACHINE_JDK: "{ version: 11.+ }"
85+
# jco-config
86+
USE_JCO: false
87+
# log-config
88+
# [console]
89+
# debug-opts
90+
# [none]
8491
requires:
85-
- name: MbtEpmDemoService-xsuaa
86-
- name: MbtEpmDemoService-destination
87-
# Providing default-url can be re-used for the app router
92+
- name: MbtEpmDemoService-xsuaa
93+
- name: MbtEpmDemoService-destination
94+
# provide default-url to be re-used for the app router's destination
8895
provides:
89-
-
90-
name: mbtepmdemo-odata
96+
- name: mbtepmdemo-odata
9197
properties:
92-
url: ${default-url}
93-
-
94-
# approuter
98+
url: ${default-url}
99+
- # approuter
95100
name: MbtEpmDemoService-approuter
96101
type: nodejs
97102
path: srv/approuter
98103
requires:
99-
- name: MbtEpmDemoService-xsuaa
100-
# require
101-
- name: mbtepmdemo-odata
104+
- name: MbtEpmDemoService-xsuaa
105+
# require
106+
- name: mbtepmdemo-odata
102107
parameters:
103-
buildpack: nodejs_buildpack
104-
instances: 1
105-
memory: 128M
108+
buildpack: nodejs_buildpack
109+
instances: 1
110+
memory: 128M
106111
properties:
107-
destinations: >
112+
# reference the provided URL for automatic linking
113+
destinations: >
108114
[
109-
{"name":"odata","url":"~{mbtepmdemo-odata/url}","forwardAuthToken": true}
115+
{"name":"odata","url":"~{mbtepmdemo-odata/url}","forwardAuthToken": true}
110116
]
111117
resources:
112-
- name: MbtEpmDemoService-xsuaa
118+
- name: MbtEpmDemoService-xsuaa
113119
type: org.cloudfoundry.managed-service
114120
parameters:
115-
service: xsuaa
116-
service-plan: application
117-
path: srv/xs-security.json
118-
- name: MbtEpmDemoService-destination
121+
service: xsuaa
122+
service-plan: application
123+
path: srv/xs-security.json
124+
- name: MbtEpmDemoService-destination
119125
type: org.cloudfoundry.managed-service
120126
parameters:
121-
service: destination
122-
service-plan: lite
127+
service: destination
128+
service-plan: lite
123129
```
124130

125-
4. To further allow deployments with `cf push` or `csdl-to-war`, also reference the destination service instance in `manifest.yml` by adding the instance name to the **services** of your application (last line only) as in the reference below:
131+
4. To further allow deployments with `cf push` or `csdl-to-war`, also reference the destination service instance in `manifest.yml` by adding the instance name to the **services** of your application and deleting the placeholder as in the reference below:
126132

127133
```YAML
134+
---
128135
applications:
129-
- buildpack: sap_java_buildpack
136+
-
137+
# application
130138
name: MbtEpmDemoService
131-
path: target/odata-service-1.0.0.war
139+
# module
140+
path: deploy/odata-service-1.0.0.war
132141
random-route: true
142+
buildpacks:
143+
# buildpack
144+
- sap_java_buildpack
145+
instances: 1
146+
memory: 2G
147+
disk: 2G
133148
env:
134-
TARGET_RUNTIME: tomee7
135-
services:
136-
- MbtEpmDemoService-xsuaa
137-
- MbtEpmDemoService-destination
149+
TARGET_RUNTIME: tomcat
150+
JBP_CONFIG_COMPONENTS: "jres: ['com.sap.xs.java.buildpack.jdk.SAPMachineJDK']"
151+
JBP_CONFIG_SAP_MACHINE_JDK: "{ version: 11.+ }"
152+
# jco-config
153+
USE_JCO: false
154+
# log-config
155+
# [console]
156+
# debug-opts
157+
# [none]
158+
services:
159+
# db-service
160+
# [h2db]
161+
- MbtEpmDemoService-destination
162+
# xsuaa-service
163+
- MbtEpmDemoService-xsuaa
138164
```
139165

140-
141-
142166
### Annotate your entities for data load from source system
143167

144-
145168
1. Open your `metadata.csdl.xml` with text editor.
146169

147170
2. Add `edmx` references to the declarations in the first lines - you will need three additional namespaces to be available for the cache database: *SQL*, *Cache* and *HTTP*.
@@ -282,8 +305,8 @@ author_profile: https://github.com/manuel-stampp
282305
8. You can now access the data from source system via your cached OData service by executing the URL from approuter, as in the last step of the previous tutorial of this mission. The data can be accessed by appending either `BusinessPartnerSet` or `SalesOrderSet` to the URL.
283306

284307
>The URL should look like the following: `https://[your-org]-[your-space]-mbtepmdemoservice-approuter.cfapps.[landscape-host].hana.ondemand.com/BusinessPartnerSet`
285-
- If you experience any issues on querying the data, please try to sort them out first before continuing with the next step. After the next step it will become much more difficult.
286-
- The service should return corresponding data from the source system and render it in a simple table. You can use standard OData query parameters to restrict the returned data.
308+
- If you experience any issues on querying the data, please try to sort them out first before continuing with the next step. After the next step it will become much more difficult.
309+
- The service should return corresponding data from the source system and render it in a simple table. You may use standard OData query parameters to restrict the returned data.
287310

288311
### Add Client-Filter and Client-Registration entities to customise a download query
289312

@@ -539,18 +562,19 @@ author_profile: https://github.com/manuel-stampp
539562

540563
### Examine and test your OData service
541564

542-
1. If not noted down previously, find the application route (URL) assigned to the app router in the space of SAP Business Technology Platform Cockpit and click it
565+
1. If not noted down previously, find the application route (URL) assigned to the app router in the space of SAP Business Technology Platform Cockpit and click it
566+
567+
- ![Application Routes in SAP BTP Cockpit](img_application_route.png)
543568

544-
![Application Routes in SCP Cockpit](img_application_route.png)
569+
- A new browser tab will open, showing the service document
545570

546-
- A new browser tab will open, showing the service document
571+
![Service Document](img_service_document.png)
547572

548-
![Service Document](img_service_document.png)
573+
2. Call `/BusinessPartnerSet` or `SalesOrderSet` and notice an error that the `Client-Instance-ID` header is missing.
549574

550-
2. Call `/BusinessPartnerSet` or `SalesOrderSet` and notice an error that the `Client-Instance-ID` header is missing.
575+
>Due to the custom download query incorporating the `BusinessPartnerFilter`, you can only query this data set if you registered to the service and sent your `Client-Instance-ID` header representing your registration. Without a filter uploaded, you will still see an empty response.
551576

552-
>Due to the custom download query incorporating the `BusinessPartnerFilter`, you can only query this data set if you registered to the service and sent your `Client-Instance-ID` header representing your registration. Without a filter uploaded, you will still see an empty response.
553-
>You can perform such a [Client Registration](https://help.sap.com/doc/f53c64b93e5140918d676b927a3cd65b/Cloud/en-US/docs-en/guides/getting-started/mbt/client-registrations.html#registration-header) also in a REST client, while the recommended approach would be to use a mobile application that automates this procedure.
577+
>You may perform such a [Client Registration](https://help.sap.com/doc/f53c64b93e5140918d676b927a3cd65b/Cloud/en-US/docs-en/guides/getting-started/mbt/client-registrations.html#registration-header) also in a REST client, while the typical approach would be to use a mobile application that automates this procedure.
554578

555579
---
556580

tutorials/cp-mobile-backend-tools-simple-odata/cp-mobile-backend-tools-simple-odata.md

Lines changed: 52 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ The command creates a blank metadata file for you that you can now open and edit
199199
```YAML manifest.yml
200200
---
201201
applications:
202-
- # application
202+
-
203+
# application
203204
name: MbtEpmDemoService
204205
# module
205206
path: deploy/odata-service-1.0.0.war
@@ -211,7 +212,9 @@ The command creates a blank metadata file for you that you can now open and edit
211212
memory: 2G
212213
disk: 2G
213214
env:
214-
TARGET_RUNTIME: tomee7
215+
TARGET_RUNTIME: tomcat
216+
JBP_CONFIG_COMPONENTS: "jres: ['com.sap.xs.java.buildpack.jdk.SAPMachineJDK']"
217+
JBP_CONFIG_SAP_MACHINE_JDK: "{ version: 11.+ }"
215218
# jco-config
216219
USE_JCO: false
217220
# log-config
@@ -223,32 +226,41 @@ The command creates a blank metadata file for you that you can now open and edit
223226
# [h2db]
224227
# destination-service
225228
# [no-destinations]
229+
# xsuaa-service
230+
# [no-xsuaa-service]
226231
```
232+
227233
>When inserting snippets to YAML files, pay attention to the indentation of the lines, as YAML is indentation-sensitive. Before pasting, make sure that your cursor is set to beginning of an empty line.
228234

229235
>**Hint:** You can indent multiple line back or forward by selecting them and pressing **(Shift + TAB)** or **(TAB)** on your keyboard.
230236

231237
8. Select **Terminal** → **Run Task** and select the task `csdl-to-war` to generate, deploy and run the service to your space. You can observe in the Terminal if the run was successful.
232238

233-
![Deployment log](img_run_log.png)
239+
![Deployment log and cf apps output](img_run_log.png)
240+
241+
**Congratulations!** You just deployed an OData service. You can find out the application route using `cf apps` in Terminal or through BTP Cockpit and open the URL in e.g. in your browser.
242+
![OData service document in browser, accessed via URL](img_browser_service.png)
234243

235-
9. (Optional) If you want your service to load test data, you can switch `TEST_MODE` to `true`. Therefore you execute task `csdl-to-war-test` or edit the variable in file `TestSettings.java` from your workspace at the path `srv` → `src` → `main` → `java` → `com` → `sap` → `mbtepmdemo` → `TestSettings.java`.
244+
>At this point you created an OData service that you can already use for prototyping, development etc. Keep in mind that data is not persistent when using MBT with H2 database. In the next step you will learn how to implement authentication, which might not be necessary for pure testing purposes.
236245

237-
You can also edit the generated test data inside the folder `srv` → `src` → `main` → `resources` → `test-data`. The test data is stored in the `.json` files. You will have to re-run the build task `csdl-to-war` again to reflect this change.
246+
9. (Optional) If you want your service to load test data, you may switch `TEST_MODE` to `true`. Therefore you execute task `csdl-to-war-test` or edit the variable in file `TestSettings.java` from your workspace at the path `srv` → `src` → `main` → `java` → `com` → `sap` → `mbtepmdemo` → `TestSettings.java`.
247+
248+
You might want to edit the generated test data inside the folder `srv` → `src` → `main` → `resources` → `test-data`. The test data is stored in the `.json` files. You will have to re-run the build task `csdl-to-war` again to reflect this change.
249+
250+
There is also the possibility to include initial data which will be loaded on every fresh database initialization, for non-testing scenarios.
238251

239252
![Test Mode and Test Data](img_test_data.png)
240253

241254
>In case you struggle on generating the service, you might find the [documentation](https://help.sap.com/doc/f53c64b93e5140918d676b927a3cd65b/Cloud/en-US/docs-en/guides/getting-started/mbt/generating.html) helpful.
242255

243-
**At this point you created an OData service that you can already use for prototyping, development etc. In the next step you will learn how to implement authentication, which might not be necessary for pure testing purposes.**
244256

245257
### Configure authentication and app router
246258

247259
If the service shall be accessible independently and authentication is required, an Authorization and Trust Management Service (XSUAA) service binding as well as an app router will be required for your OData service. If you are looking for more details of this service, you might want to go through [Secure a Basic Node.js App with the Authorization and Trust Management Service (XSUAA)](cp-cf-security-xsuaa-create) tutorial and its references, already covering the same for another application type.
248260

249-
1. Open the file ``tasks.json`` from folder ``.vscode`` and uncomment the line `"-login", "XSUAA",` in the configurations `csdl-to-war` and `csdl-to-war-nodeploy` as shown below.
261+
1. Open the file ``tasks.json`` from folder ``.vscode`` and uncomment the lines `"-login", "XSUAA",` and `"-xsuaa", "<xsuaa-instance-name>",` in the configurations `csdl-to-war` and `csdl-to-war-nodeploy` as shown below. Thereby replace `<xsuaa-instance-name>` with `MbtEpmDemoService-xsuaa`.
250262

251-
>Sometimes it may happen that, due to automatic formatting in SAP Business Application Studio, comments may have been removed from `tasks.json` file. You can try to restore them with **Undo** [CMD] / [CNTRL] + [Z]. Alternatively, recreate the file or add the parameters `"-login", "XSUAA",` manually. Take care of the parameter order, as some parameters are interpreted as a pair, key (prefixed with "-") and value.
263+
>Sometimes it may happen that, due to automatic formatting in SAP Business Application Studio, comments may have been removed from `tasks.json` file. You can try to restore them with **Undo** [CMD] / [CTRL] + [Z]. Alternatively, recreate the file or add the parameters `"-login", "XSUAA",` manually. Take care of the parameter order, as some parameters are interpreted as a pair, key (prefixed with "-") and value.
252264

253265
![Uncomment for XSUAA security](img_uncomment_login.png)
254266

@@ -288,16 +300,19 @@ If the service shall be accessible independently and authentication is required,
288300

289301
![Create new files](animation_create_approuter_files4.gif)
290302

291-
5. Finally, the XSUAA service binding need to be reflected for deployment. You can achieve this by adding them to the ``manifest.yml`` that was generated in your workspace.
303+
5. Finally, verify the XSUAA service binding in `manifest.yml` that should have been updated in your workspace. The tools leverages specific comments for parsing and recreating the file.
292304

293-
- To bind the XSUAA service instance, add the following lines:
305+
- The end section of the file should have been updated to contain:
294306

295307
```YAML
296-
services:
297308
- MbtEpmDemoService-xsuaa
298309
```
299310

300-
>**Important:** Do not execute the ``csdl-to-war`` tasks anymore. First we need to create the service instances via the Multi-Target-Archive. When they are created, you can work with ``csdl-to-war`` again in order to push just the OData service. This will be quicker than deploying the full MTA.
311+
- Under certain circumstances, it might happen that the `# services:` section is not automatically uncommented. Therefore, please uncomment it in case.
312+
313+
- The placeholder comment `# xsuaa-service` marks the following line to be overwritten with the name given in the task. By removing the placeholder, you may disable this feature.
314+
315+
>**Important:** Do not execute the `csdl-to-war` task anymore but stick to `-nodeploy`. First it's necessary to create the service instances via the Multi-Target-Application archive. When they are created, you may work with `csdl-to-war` again in order to push the OData service only. This will be quicker than deploying the full MTA.
301316

302317
For reference check the full `manifest.yml` file content.
303318

@@ -317,19 +332,22 @@ If the service shall be accessible independently and authentication is required,
317332
memory: 2G
318333
disk: 2G
319334
env:
320-
TARGET_RUNTIME: tomee7
335+
TARGET_RUNTIME: tomcat
336+
JBP_CONFIG_COMPONENTS: "jres: ['com.sap.xs.java.buildpack.jdk.SAPMachineJDK']"
337+
JBP_CONFIG_SAP_MACHINE_JDK: "{ version: 11.+ }"
321338
# jco-config
322339
USE_JCO: false
323340
# log-config
324341
# [console]
325342
# debug-opts
326343
# [none]
327-
services:
328-
- MbtEpmDemoService-xsuaa
344+
services:
329345
# db-service
330346
# [h2db]
331347
# destination-service
332348
# [no-destinations]
349+
# xsuaa-service
350+
- MbtEpmDemoService-xsuaa
333351
```
334352

335353
6. Create a MTA deployment descriptor.
@@ -346,18 +364,26 @@ If the service shall be accessible independently and authentication is required,
346364
_schema-version: '3.3'
347365
version: 1.0.0
348366
modules:
349-
- # application
367+
-
368+
# application
350369
name: MbtEpmDemoService
351370
# module
352371
path: srv/deploy/odata-service-1.0.0.war
353372
type: java
354-
parameters:
355-
memory: 1G
356-
disk: 2G
373+
parameters:
357374
instances: 1
358-
properties:
359-
SET_LOGGING_LEVEL: '{odata: TRACE, sap.xs.console: TRACE, sap.xs.odata: TRACE}'
360-
TARGET_RUNTIME: tomee7
375+
memory: 2G
376+
disk: 2G
377+
properties:
378+
TARGET_RUNTIME: tomcat
379+
JBP_CONFIG_COMPONENTS: "jres: ['com.sap.xs.java.buildpack.jdk.SAPMachineJDK']"
380+
JBP_CONFIG_SAP_MACHINE_JDK: "{ version: 11.+ }"
381+
# jco-config
382+
USE_JCO: false
383+
# log-config
384+
# [console]
385+
# debug-opts
386+
# [none]
361387
requires:
362388
- name: MbtEpmDemoService-xsuaa
363389
# provide default-url to be re-used for the app router's destination
@@ -404,16 +430,16 @@ If the service shall be accessible independently and authentication is required,
404430

405431
![BTP Cockpit Application with marked application route](img_btp_application_route.png)
406432

407-
>Take note: If you created your Cloud Foundry environment in a `-00x`-environment (like e.g. `us10-001`, currently used in SAP BTP Trial by default), you might receive the error `"The redirect_uri has an invalid domain"`. If this is the case, you will have to allow-list your application uri in the `xs-security.json` file and re-run `cf deploy`.
433+
>Take note: If you created your Cloud Foundry environment in a `-00x`-environment (like e.g. `us10-001` or `eu10-004`), you might receive the error `"The redirect_uri has an invalid domain"`. If this is the case, you will have to allow-list your application uri in the `xs-security.json` file and re-run `cf deploy`.
408434

409435
```json
410-
[...]
411-
"tenant-mode": "dedicated",
412-
"xsappname": "MbtEpmDemoService",
436+
{
413437
"oauth2-configuration":
414438
{
415439
"redirect-uris": ["https://*.us10-001.hana.ondemand.com/**", "https://*.eu10-004.hana.ondemand.com/**", "https://*.eu10.hana.ondemand.com/**"]
416440
},
441+
[...]
442+
}
417443
```
418444

419445
---
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)