In order to complement the official documentation on creating a REST based MBO (Mobile Business Object) on SMP, i’m creating this Blog to make it easier and more “hands on”.
Let’s say a have the below Rest Service, that passing the field 1, returns the below structure:
And now i’m want to use him on my Mobile Application as a MBO. So first, i need a XSD mapping for this service. In this case, it’s the one below:
<?xml version="1.0" encoding="UTF-8"?> <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="emp" type="emp"/> <xs:complexType name="emp"> <xs:sequence> <xs:element name="HNK" type="xs:string" minOccurs="1"/> <xs:element name="SCH" type="xs:string" minOccurs="1"/> <xs:element name="DAYS_TO_EXPIRE" type="xs:string" minOccurs="1"/> <xs:element name="USER_EXPIRE" type="xs:string" minOccurs="1"/> </xs:sequence> </xs:complexType> </xs:schema>
If you want to know more about XSD mapping, link.
So now, in your current project(assuming you have one already), let’s create e MBO.
Before that, you need a REST Web Service connection created on your SDK. So assuming it’s a new service(not a new URI on a current service), you should create one like this:
Place your HOST:PORT and URI below.
Now let’s create the MBO:
Naming as RestExample:
REST Web Service type, with Data source as the connection created above:
On the new screen, we need to map the service response:
Using the XSD file generated(in my example, located at C:\):
On the next screen, you need to define the key fields and that’s it! Your new MBO is all set to be used, so now you should place him on your desired Cache Group and Sync Group, generate the source code, deploy to the server and enjoy your new data 😀🤝.
Don’t forget to visit the official help: