A Simple SUP Hybrid App to access Web Service: Part I
Creating Web Service based MBO
This blog explains how we can create a simple SUP based hybrid application which is connected to web service (backend).
Tools used in developing this application are:
SUP version : 2.2 SP04
Android Emulator: 2.2 version
Note: A similar document is already available in SCN but that app was built on SUP old version 2.0 and as we all know that there have been few changes in SUP 2.2 SP04 as compared to SUP 2.0. So here i have pointed all the new changes with the same app.
1. Establish a backend connection to web service in mobile sdk workspace.
- Right click web service under Enterprise Explorer
- Give some name i.e. currConv, click on “Next“
- Select From URL option in web service Connection details screen and provide this URL
2. Right click on currConv and select Connect
3. Create a new project. File>New>Mobile Application Project. Give some name i.e. CurrencyProject.
4. Its time to create Mobile Business object (MBO). Drag and drop Mobile Business Object to the Mobile Application diagram screen under palette.
- Give some name i.e. CurrMBO
- Select desired connection profile (currConv)
- For this current sample application, we are using “GetCurrencyValue” method which has source currency, target currency and a provider agency as import parameters and the exchange rate as export parameter.
- In next step, provide some test data e.g.
- Provider : AVERAGE
- Source Currency : USD
- Target Currency: INR
- Finish it
- You can right click to the MBO and preview what value you will be getting in the output result
5. Since we are developing this application as type online so we have to set cache policy as “Online”
- Right click Default Cache group in CurrencyProject>Properties>Policies>select Online
- Select CurrMBO in Confirm changes window
6. As soon as step 5 is completed, we can see one error under problems tab says
Mobile Business Objects ‘CurrMBO’ with online cache policy must have at least one load argument with ‘Propagate To’ attribute set.
- To overcome this issue, we have to create attributes in the mbo and have to do ‘Propagate To‘ mapping
- Right click MBO>Attributes>Attributes Mapping
- Add 3 new attributes
- New Attributes:
- srcCurrency (stirng(5), Not Nuallable, Primary key)
- TrgtCurrency (stirng(5), Not Nuallable, Primary key)
- Prvdr (stirng(10), Not Nuallable, Primary key)
- Open Load Arguments tab,
- Map corresponding “Propagate To” value against each argument respectively
- As you map it, an online object query will be regenerated
7. Deploy MBO to SUP server
- Make sure to create a new connection under server Connection mapping window.