1 2 3 13 Previous Next

SAP Mobile Platform Developer Center

195 Posts

What is Cordova ?

Cordova ,formerly called as Phone Gap is a platform to build Native Mobile Applicatons using HTML5, CSS and Java Script.

In other words it acts  a container for running a web application written in HTML, CSS,JS Typically Web applications cannot use the native device functionality like Camera, GPS, Accelerometer , Contacts etc. . With Cordova we can very much achieve this and package the web application in the devices installer format.


Device installer formats :

 

Android - .apk (Android Application Package)

IOS - .ipa (iPhone Application Archive)

Windows Phone .xap (Silverlight Application Package)


Are PhoneGap and Apache Cordova different ?

Both are the same . But we can say that Apache Cordova as an engine that powers PhoneGap , like how Webkit is an engine that powers Chrome.

More details on the name transitions from PhoneGap to Cordova are here

 

How Does it actually work ?

Technically the User Interface of a Cordova Application is effectively a WebView that occupies the complete screen and runs in the native Container. So , it is the same web view that is used by the Native  Operating systems. This purely means that only the Native Containers changes according to the OS and internally the web pages remain the same. (Since the browser rendering of webpages are different for each operating systems)


For       IOS it is UIWebView class

             Android it is in  android.webkit.webview

             Windows it is WebViewClass and the similar goes to other OS .

 

Cordova_framework.png

and the Cordova libraries communicate with the Native Framework of the respective OS .

 

Cool then what device API's are available ?

This list has that answer

 

OK , Then - What OS are supported ?

Almost all major platforms are supported . Here's the list

 

WOW ! i 'm loving this . How much does this cost ?

Its absolutely free . Cordova was announced as an Open Source project and will always remain free licensed under Apache License ,Version 2.0

 

Interesting !!! But my Application Requirement is not completely satisfied with the list of plugins API 's available. How should i proceed ?

No problem . It is completely extensible . If cordova does not provide an API to complete your Application requirement , then a custom Native Plugin can be created and used.

 

What is Kapsel ?

Kapsel is a set of custom plugins developed  by SAP underlying the Cordova technology to meet the enterprise requirements like encryption storage,Cache Management, Logon, AuthProxy,fiori client  etc and delivered from SMP3.0 (SAP Mobile Platform 3.X ) and integrated with it.

 

Get more information on Kapsel and its usage

 

My Good Friends for Developing applications :

1) Chrome Remote Debugging is really a cool feature of chrome to test and debug Mobile Web applications for Android. It helps by a great extent to inspect,analyse and debug browser tabs, web views of Android. (works well from Cordova v 3.3.0 )


2) Mobile Emulation is a unique feature of chrome which reduces the complexity to test the web application on multiple devices and different OS.

How to enable Mobile Emulation in Chrome


3) A New feature The PhoneGap Developer App has been added recently by Cordova , which saves a lot of time in compiling and packaging the Application for testing the changes during development .

Just Download the Native containers as applications for the required OS from PhoneGap Developer App . Open the developed project and start in a local server and specify the IP address of the desktop server in the downloaded application.


Boom !!! when both get paired all the web pages are loaded in the application and can gain the power of the Native Device API s that are nt supported by browsers .

This gives a great power and eases the development with cordova showing the changes instantaneously.


This is a long awaited feature and is now available .


Happy Working with Cordova and Kapsel !!!


CC:

UI Development Toolkit for HTML5 Developer Center


Part - 1Part - 2Part - 3
Click HereClick HereClick Here

 


This is Part 3 of the entire Overview.

First Part on how to create mobile App in SMP, please click here

Second Part on Configure SMP for back end SAP Connectivity, please click here


Before we proceed, you need to download few things to setup your development environment.

1. Download Sencha Touch

2. Download PhoneGAP or Cordova

3. Download a webserver (XAMPP is the one i use)

 

In our previous sessions, we've covered How we can configure SMP to connect with SAP Backend systems, and how to consume the web services using NW Gateway.

 

Now let's have deeper look into SalesOrder Service and it's metadata.

 

<Property Name="SalesOrderID" Type="Edm.String" />

<Property Name="NetSum" Type="Edm.Decimal" />

<Property Name="Tax" Type="Edm.Decimal" />

<Property Name="Currency" Type="Edm.String" />

<Property Name="ChangedAt" Type="Edm.DateTime" />

<Property Name="Note" Type="Edm.String" />

<Property Name="CreatedAt" Type="Edm.DateTime" />

<Property Name="TotalSum" Type="Edm.Decimal" />

<Property Name="Status" Type="Edm.String" />

<Property Name="CustomerName" Type="Edm.String" />

<Property Name="BusinessPartnerID" Type="Edm.String" />

 

** `These are the fileds returned to the web service` **


This service returns the above details, and in our front end app we need to store these values into local memory, in HTML5 these will be called as Store and defined as Models.

 

Sencha Touch:

Sencha is based on MVC Architecture, and its highly recommended to use Model, View and Controllers.

 

In our example we will define our view(Screen) to show the data returned for the SalesOrders. In the same way each request/response may have its own view(Screen) or some business validations may happen based on the need.

 

Here are some views we need to create for this example

 

Views:

Login view – User will enter Username and password

Selection View – Use Choice of selection

Order View – We will show the Sales Orders in the device

Sales Order Details View – Details of Sales Order (Line items, Material and Business Partner)

Sales Partner View – Display Sales Partner details

Material View – Display Material Details in the Sales Order

Graphical View – Display Charts using Sencha Touch GPL Version

 

Models and Stores:

Models and stores are important and need to be defined inline with our Metadata to store the return values from the Sales Order service. We can do all internal operations in the store once we've data including converting, sorting or writing some special business logic.

 

Profile:

     We can create profiles which suites for our needs, as an example user will open this app in Small resolution device such as phone, or user can open the same app in big screen such as tablet, we need to provide different look and feel as Tablet will have more space to show the details. This can be easily done with Sencha Touch (Please note that, our example will not show the profile concept)

 

I've uploaded all the source code to this location in GutHub, feel free to download, in the source code please change the URLs referring to your SMP3 and update your password to make it work.

 

Native Build:

Once you have the working example of this, then you are ready to compile this app into Native apps, you can setup each environment locally or simply you can use PhoneGap Remote build, which will generate all the native apps for you. for more information https://build.phonegap.com/

 

If you need any help / assistance on setting up this demo working please contact me via comment section below.

Problem :- When we want fetch on demand on that time how we check device is working in offline mode or online mode.

Solution:- we are working in SAP WM 6.0.0 and want to fetch on demand, On that time first off all we check that our device is in offline or online mode.

in that situation we following some steps :-

 

First create a button in Screen set on which we want to execute online fetch. On that button we can make a action Inside that action we create two sub action:-

a)On first sub action we define a rule that check device is offline or online if device is in online mode than execute mapped action and show all record. else execute second sub action.


b)In Second sub action we also used a rule that verify device is in offline or online mode than execute mapped action and that action show messgae box that your device is in Offline mode else execute first sub action

 

So using it we can do online fetch after verify that our device is in offline mode.

 

You can verify your rule with given rule.

 

For more detail :-

http://scn.sap.com/content?filterID=all~objecttype~objecttype%5Bblogpost%5D

PART 1PART 2PART 3PART 4

 

Here we will see how to create a destination in Gateway cockpit and map it manually to deployed OData service and then how to perform CRUD operation on service document.

 

Test the OData service

 

  1. Log on to SMP 3.0 Admin: https://smpserver:port/Admin
  2. Create a new security profile with name as 'sap' (exact name as namespace) under Settings>Security profiles>New

 

     27.png

 

3. Log on to SMP3 gateway cockpit https://smpserver:port/gateway/cockpit

4. Go to destinations tab, Create a new destination


         

PropertiesValues
Destination TypeDATABASE
Destination URLjdbc:mysql://MySQLSeverip/schema_name
Destination Drivercom.mysql.jdbc.Driver
Authentication TypeBasic Authentication
User NameDB User
PasswordDB password


28.PNG

 

5. Move to Services tab, click on deployed service employee_MYSQLDB.

    • Click on 'Add Destination', select MYSQLDB from the drop-down.
    • Save and close.


     1.png


6. Once done, open the service document,


 

1.png


http://smpserver:8080/gateway/odata/sap/employee_MySQLDB;v=1


1.png

 

   

7. Open service metadata document

    • OData defines a metadata format based on the Entity Data Model in XML (edmx).
    • To access a service's metadata document use the $metadata command.
    • The returned document is the service's edmx metadata + backend metadata

 

http://smpserver:8080/gateway/odata/sap/employee_MySQLDB;v=1/$metadata

          1.png

 

8. To get the details for the Entity 'employee'

 

http://smpserver:8080/gateway/odata/sap/employee_MySQLDB;v=1/employee

     1.png

 

To fetch only first row of the table, http://smpserver:8080/gateway/odata/sap/employee_MySQLDB;v=1/employee(1001)

 

OData operations : RetrieveEntity (READ)

 

To retrieve details of a specific entity,use HTTP GET verb to execute the same.

    • Open Advanced REST client

 

REQUEST:


HeaderValues
X-CSRF-TOKENFETCH
Content-Typeapplication/xml


 

     1.png


RESPONSE:


    • 200 OK status message
    • X-CSRF-TOKEN value e.g. 1B4687085D8F59B1CA21382DF17D535A

          1.png

 

 

      

OData Operations – InsertEntity (CREATE)

 

    • The InsertEntity operation creates an entity.

 

REQUEST:

HeaderValues
X-CSRF-TOKEN1B4687085D8F59B1CA21382DF17D535A
Content-Typeapplication/xml
    • Pass this xml text into the BODY

 

<?xml version="1.0" encoding="UTF-8"?>
<atom:entry xmlns:atom="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">
   <atom:content type="application/xml">
      <m:properties>
         <d:EMPID>1006</d:EMPID>
  <d:FIRST_NAME>SACHIN</d:FIRST_NAME>
  <d:LAST_NAME>SHARMA</d:LAST_NAME>
  <d:CITY>CHANDIGARH</d:CITY>
         <d:COUNTRY>INDIA</d:COUNTRY>
      </m:properties>
   </atom:content>
</atom:entry>






1.png

 

RESPONSE:

    • This operation creates an entity.
    • Successful execution of the operation returns HTTP 201 status code along with the Location of the newly created entity will be returned.

     1.png

To verify, you can check with http://smpserver:8080/gateway/odata/sap/employee_MySQLDB;v=1/employee(1006) OR directly in the MySQL database.

         

          1.png

 

OData Operations – UpdatetEntity (UPDATE)

 

    • The UpdateEntity operation updates an entity.

 

REQUEST


HeaderValues
X-CSRF-TOKEN1B4687085D8F59B1CA21382DF17D535A
Content-Typeapplication/xml
    • Pass this xml text into the BODY

xml version="1.0" encoding="UTF-8"?>

<atom:entry xmlns:atom="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">
   <atom:content type="application/xml">
      <m:properties>
         <d:EMPID>1003</d:EMPID>
  <d:FIRST_NAME>CHIP</d:FIRST_NAME>
  <d:LAST_NAME>ROG</d:LAST_NAME>
  <d:CITY>SAN FRANS</d:CITY>
         <d:COUNTRY>USA</d:COUNTRY>
      </m:properties>
   </atom:content>
</atom:entry>






          1.png

RESPONSE:

 

    • If the update is successful, the server responds with 204 status code.
    • As the response code text "No Content" signifies, no data is returned in the Response Body.

          1.png

     1.png

 

 

 

OData Operations – DeleteEntity (DELETE)

 

  • The DeleteEntity operation deletes an entity.


REQUEST

HeaderValues
X-CSRF-TOKEN1B4687085D8F59B1CA21382DF17D535A
Content-Typeapplication/xml

 

     1.png

RESPONSE:

 

    • If the delete is successful, the server responds with 204 status code.
    • As the response code text "No Content" signifies, no data is returned in the Response Body.

 

1.png

 

     1.png

Next Part 4

PART 1PART 2PART 3PART 4

 

Troubleshooting:

 

1. Error while installation of MySQL Installer.

 

Unable to update security settings:Acess denied for user 'root@localhost'

  1.png    

 

Solution:

 

  • Run cmd. Go to bin folder of the MySQL installer
  • run this command: mysqladmin -u root -h localhost password <dbpassword>

 

     1.png

  • After that manually start the MySQL56 service. (services.msc) and make sure its running.

1.png

 

 

2. If you are trying to access MySQL server (machine) from other system, then make sure you change "Limit to Hosts Matching" to %. Click on 'Apply'

 

             1.png

 

3. If there is any issue for making MySQL jar file as OSGi enabled, you can download it from here.

     And then can directly deploy to SMP 3.0 server(Part 2- step 8)

 

4. While installing the GWPA component, if you encounter with below error. (Assuming you are external resource through a proxy)

 

Cannot complete the install because one or more required items could not be found.

  Software being installed: Toolkit for Integration Gateway (GWPA, Developer Edition) 1.1.1 (com.sap.odata.dt.framework.sap.smp.feature.feature.group 1.1.1)

  Missing requirement: SAP Command Framework - HTTP communication (apache) 1.6.0 (com.sap.it.commons.command.http.apacheclient 1.6.0) requires 'package org.apache.http [4.1.0,5.0.0)' but it could not be found

 

Solution: Make you set the proxy details

 

    • Go to Window>Preferences in Mobile Workspace
    • Preferences box prompt out, choose "Network Connections"
    • Select "Manual" from Action Provider in the drop-down
    • Select "HTTP" >Click on "Edit"
    • Provide required proxy details with port number.
    • Restart eclipse.

 

5. While testing the SMP server connection for Integration Gateway (Windows>Preferences>OData Development>Integration Gateway)

 

     1.png

Solution: Make sure you install the latest JDK (1.7) or JRE7 to avoid this kind of issue.

 

6. Error during OData model deployment to SMP server,

"Deployment cannot be completed for xxxsevice".

 

Make sure you configure SMP server to use the same proxy settings that you must have entered in the eclipse. Refer this link. How to configure SMP 3.0 to use proxy to access external resource

 

7. While opening service document, if you encounter with HTTP 403 - Requested URL is not valid message.

          1.png

 

Solution: Replacing localhost by system host/ipaddress worked for me.

 

For more information and updates follow SAP Mobile Platform Developer Center, SAP for Mobile

PART 1PART 2PART 3PART 4

 

Next step is to enable MySQL's JDBC driver for OSGi, then deploy it to SMP 3.0 server, create OData Modeling & deploy to SMP server.

 

Enabling MySQL's JDBC driver for OSGi

 

  1. Since MySQL JDBC driver is not archived as OSGi bundle, so it can not be read and understood by SMP3 (as SMP3 is based on OSGi), hence to make it work we need to create an OSGi enabled bundle which includes MySQL JDBC driver.
  2. Download MySQL's JDBC driver from here.
  3. Open Eclipse>New>Other>Plug-in Development>Plug-in from Existing JAR Archives
  4. Click on 'Add External' and browse to jar file

 

          18.png

 

5. Provide some project name

    • Make sure you select Target Platform as Equinox
    • Uncheck unzip the JAR archives into the project

 

               19.png

 

6. Once done, Right click project> Export>Plug-in Development>Deployable plug-ins and fragments

    • Define some location to store OSGi enabled jar file
    • Click on 'Finish'

 

     20.png

 

 

 

Configure SMP 3.0 server for Integration Gateway JDBC connection


  • As already mentioned above, SMP3 is based on OSGi  so it is very much possible to deploy any JDBC driver as OSGi enabled jar package on SMP runtime.

 

7. Copy the OSGi enabled jar file (in my case, it is at Desktop), paste it into C:\SAP\MobilePlatform3\server\pickup

    • To verify if jar file has been deployed successfully, open .state folder and see the 'OK' message

 

          21.png

OData modeling

 

 

8. Make sure you have added GWPA plugin in the eclipse. For more information, check this document.

9. Create an OData project. File>New>Service Implementation Project

10. Check 'Create OData file manually' option

          1.png

 

11. Create a model file. Right Click Model>New>Other>OData model

    • Give some name for Model i.e. empModel
    • Make sure you have selected 'Blank OData Model' from Initial Model content option
    • Click on 'Finish'.

 

               1.png

 

12. Create an Entity model same like your table structure in backend system.

    • Make sure Entityset has the same name as Table name in database
    • All properties should have same name and data type as per table in the database
    • Change the EMPID data type to INT

 

      1.png

13. Right click model>empModel.odata>Implement service

14. Right click empModel.odatasrv>Select Data source as JDBC

 

          25.png

 

15. Right click project>Generate and Deploy Integration content

    • You may prefer any other name for Service Namespace. By default it is 'sap'.

 

          1.png

 

Make sure you get a success message.

 

1.png

 

Next Part 3

Objective: This blog series with give you a detailed understanding on how to setup MySQL database, create one sample table, creating and deploying OData model to SMP 3.0 server, CRUD operation with OData service document and troubleshooting.

 


Software
Used


  • MySQL Community Server 5.6.19
  • Eclipse Junos 64 bit with "Toolkit for Integration Gateway (GWPA)" plugin added
  • SAP Mobile Platform 3.0 SP03
  • Chrome Browser, Advanced REST Client

 

Let us start it.

 

PART 1PART 2PART 3PART 4

 

Installation of MySQL server

 

  1. If you don't have a running MySQL Installer then you can download it from below link. It is for free.

 

          http://dev.mysql.com/downloads/windows/installer/5.6.html

 

          1.png

 

2. Once download completes, run the installer, select option as required.

 

          2.png

 

 

Since there was no MySQL binaries installed previously so i selected "Add/Modify Products and Features"

 

 

3.  Accept the license terms, and click on "Next"

 

          3.png

 

4. Make sure you have checked MySQL Server 5.6, Applications, MySQL Connectors, Click 'Next'

 

          4.png

 

5. Make sure all the requirements have made.

 

          5.png

 

6. Click 'Execute' to install/update the listed products/packages

 

          6.png

 

7. On the Configuration step, you can change the port value. By default it is 3306

 

          7.png

8. MySQL Admin is 'root'. Set a strong password for MySQL Root.

 

          8.png

 

10. You may change the Windows service name as per your convenience. By default it is MySQL56

 

          9.png

 

Make sure "Start the MySQL server at System Startup" is checked

 

10. You must see a message "Configuration and Installation complete".

 

     10.png

You can verify if MySQL56 service is up and running. Go to services.msc (Windows+R)

     11.PNG

 

Creating a sample database table

 

11. Launch MySQL workbench>Click on '+' icon

  • Give some Connection Name
  • Type the password (Should be the same as per step 8)
  • Click on 'Test Connection'

         12.png

 

12. Right Click > Open Connections

 

               13.png

13. You must see MySQL Workbench as per below screenshot:

    • There are some pre-existing Schemas as well. If wish, you can create a new one and Click on 'Apply'.
    • This Workbench will give a guide for Server management, server logs, performance also.
    • You may verify if Server is up and running.

 

          14.png

 

14. Since i have created a new Schema, then i have to add a table to it.

    • Right click jk_schema>Tables
    • Give some table name, add parameters
    • Make sure there is one primary key among all columns
    • Click on 'Apply'

 

          1.png

 

15. Below confirmation, you have to review the SQL script to be applied on the Database.

 

               1.png

 

16. Now, it's time for adding some values to this table.

  • Right click Schemas>employee (On left hand side below)> Select Rows-Limits 1000
  • Automatically it will run SELECT query of this table. i.e. SELECT * FROM schema_name.table_name (SELECT * FROM jk_schema.employee;)
  • Add columns value and click on 'Apply'.

 

17. You can verify the inserted columns details again by running SELECT query.

 

          1.png

Next Part 2

Hi Everyone,

 

Recently i gone through OData Read, Create, Update and Delete operations in SMP 3.0 Native ODataSDK.

 

here is a sample code for a OData service


http://sapes1.sapdevcenter.com:8080/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/TravelagencyCollection

 

GET Request Format

 

[RequestBuilder setRequestType:HTTPRequestType];

  

// Enable XCSRF handling for OData requests

[RequestBuilder enableXCSRF:YES];

  

// Initialize the Requesting class with the endpoint URL

id<Requesting> getRequest = [RequestBuilder requestWithURL:[[NSURL alloc] initWithString: appEndPoint]];

  

// Add username and password for the end point

[getRequest setUsername:username];

[getRequest setPassword:password];

   

/// Set our request headers.

[getRequest setRequestMethod:@"GET"];

[getRequest addRequestHeader:@"X-Requested-With" value:@"XmlHttpRequest"];

[getRequest addRequestHeader:@"Content-Type" value:@"application/xml; charset=UTF-8"];

[getRequest addRequestHeader:@"Accept" value:@"application/xml,application/atom+xml"];

  

// This class is the delegate callback for any notifications (success and failure)

[getRequest setDelegate:self];

[getRequest setDidFinishSelector:@selector(handleReqSuccess:)];

[getRequest setDidFailSelector:@selector(handleReqFailed:)];

  

// Each request can be tagged with a number.

getRequest.requestTag = tag; // Useful for a change request.

  

// Start our request.

[getRequest startAsynchronous];


POST Request Format

 

[RequestBuilder setRequestType:HTTPRequestType];

 

[RequestBuilder enableXCSRF:YES];

 

id<Requesting> postRequest = [RequestBuilder requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",appEndPoint,collectionName]]];

 

[postRequest setRequestMethod:@"POST"];

  

[postRequest addRequestHeader:@"Content-Type" value:@"application/json; charset=UTF-8"];

 

[postRequest addRequestHeader:@"Accept" value:@"*/*"];

 

// Here cSRFToken is retrieved from the GET Response.

[postRequest addRequestHeader:@"x-csrf-token" value: cSRFToken];

 

NSMutableData* postData;

// GetEntry is an ODataObject which has the response for GET done on single entry from a collection

 

ODataEntry const *postBody = [[ODataEntry alloc]initWithEntitySchema:[[[self.serviceDocument getSchema] getCollectionByName:self.entityName] getEntitySchema]];

  

ODataPropertyValueObject* filterValue = [postBody getPropertyValueByPath:@"agencynum"];  ///agencynum is the primary key or the unique value

   

          filterValue.rawValue=@"00000127";

    

ODataPropertyValueObject* filterValue1 = [postBody getPropertyValueByPath:@"agencyname"];

    

filterValue1.rawValue=@"BestAgency";

  

//The following code can be used to build a JSON post body:

 

ODataEntryBody *entryBody = buildODataEntryRequestBody(postBody, ENTRY_OPERATION_CREATE, self.serviceDocument, NO, BUILD_STYLE_JSON);  

      

postData = [[entryBody.body dataUsingEncoding:NSUTF8StringEncoding]mutableCopy];

 

[postRequest addRequestHeader:@"Content-Length" value:[NSString stringWithFormat:@"%i",[postData length]]];

 

[postRequest setPostBody:postData];

 

[postRequest setDelegate:self];

  

// Each request can be tagged with a number.

          getRequest.requestTag = tag; // Useful for a change request.

 

// Start our request.

[postRequest startAsynchronous];

 

PUT Request Format


[RequestBuilder setRequestType:HTTPRequestType];

  

[RequestBuilder enableXCSRF:YES];

  

id<Requesting> putRequest = [RequestBuilder requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@(%@)",appEndPoint,collectionName,agencynum]]];

  

[putRequest setRequestMethod:@"PUT"];

 

[putRequest addRequestHeader:@"Content-Type" value:@"application/json; charset=UTF-8"];

  

[putRequest addRequestHeader:@"Accept" value:@"*/*"];

  

[putRequest addRequestHeader:@"x-csrf-token" value:cSRFToken];

  

NSMutableData *postData;

 

ODataEntry const *postBody = [[ODataEntry alloc]initWithEntitySchema:[[[self.serviceDocument getSchema] getCollectionByName:self.entityName] getEntitySchema]];

 

ODataPropertyValueObject* filterValue = [postBody getPropertyValueByPath:@"agencyname"];

  

filterValue.rawValue=@"NewAgencyName";

  

//The following code can be used to build a JSON post body:

ODataEntryBody *entryBody = buildODataEntryRequestBody(postBody, ENTRY_OPERATION_CREATE, self.serviceDocument, NO, BUILD_STYLE_JSON);

      

postData = [[entryBody.body dataUsingEncoding:NSUTF8StringEncoding]mutableCopy];

  

[putRequest addRequestHeader:@"Content-Length" value:[NSString stringWithFormat:@"%i",[postData length]]];

  

[putRequest setPostBody:postData];

  

[putRequest setDelegate:self];

  

putRequest.requestTag = tag;

  

// Start our request.

  [putRequest startAsynchronous];


DELETE Request Format


[RequestBuilder setRequestType:HTTPRequestType];

  

[RequestBuilder enableXCSRF:YES];

  

id<Requesting> deleteRequest = [RequestBuilder requestWithURL:[NSURL URLWithString:[NSString stringWithFormat@"%@/%@(%@)",appEndPoint,collectionName,agencynum]]];

  

[deleteRequest setRequestMethod:@"Delete"];

  

[deleteRequest addRequestHeader:@"Content-Type" value:@"application/json; charset=UTF-8"];

  

[deleteRequest addRequestHeader:@"Accept" value:@"*/*"];

  

[deleteRequest addRequestHeader:@"x-csrf-token" value:self.cSRFToken];

  

[deleteRequest setDelegate:self];

  

deleteRequest.requestTag = tag;

  

// Start our request.

[deleteRequest startAsynchronous];


 

Regards

Siva Chandu

Hi All,

 

I am sure most of us have started working on new release of SAP Mobile Platform 3.0 SP03 (more precisely). We got many approaches to develop a mobile application like Kapsel  app development, native OData based app, REST API based app. From SUP 2.2 onwards, this mobile platform provides REST APIs which enable standard HTTP client apps running in any platform to access platform REST services. This platform provides different functionality like

 

  • Management and monitoring the apps
  • Native push notification like APNS , BES, GCM, WNS, MPNS

 

There is a proper procedure to get start with. First we have to register a client application with proper device information. Once registration is successful, we have follow REST API method to retrieve and update the application.

 

                       

Platform Required: SMP3.0 SP03 Runtime, Eclipse Junos with GWPA installed

                                Chrome browser, Advanced Rest Client

 

So lets start it:

 

  1. I have created one OData service using Integration gateway modeling tool GWPA for a given database HSQLDB.

 

http://smpserverip:8080/gateway/odata/sap/DeptHSQLDB;v=1

 

2. Open Admin cockpit by running: https://smpserver:8083/Admin/

 

  • Create an Application id by clicking on "New"

                    appid.PNG

 

  • Move to  "BACK END" tab, provides Endpoint URL

 

                    Backend.PNG

 

    NOTE: If you are accessing OData URL through a proxy then don't forget to check "Use System Proxy" option. Before that make sure you have configured SMP 3.0 to use proxy to access external resource. Check here.

 

 

 

  • Once done, move to "AUTHENTICATION" tab, There is one already existing profile admin. Save and confirm.

 

                   Authentication.PNG

 

  • To verify if request is reaching to backend server successfully, select newly created application id and click on  'Ping'.

          You will see a successful message.

                    ping.PNG

 

 

 

3.  Open Advanced REST Client (from Chrome web store)

 

 

 

    • Where: com.test.dept: application id (created in Admin cockpit)
    • localhost: smp server ip
    • Add a new header : Authorization: provides smp server login details

 

                    Auth.PNG

    • REST Client will convert Authorization values into base64 format
    • Hit the 'Send' button
    • If everything is fine, then you must receive an HTTP 200 OK as the status - this confirms the proxy connection.

 

          GET.png

 

 

    • Notice the response, you will see two entries of collection. Endpoints and Connections.

 

          Response.png,

 

Register the Application ID:

 

 

  1. For registration we have to use the "Connections" collection at the end of the

  

KEYVALUE
Content-Typeapplication/xml
Authorizationsmp server id and password
X-SMP-APPCIDBLANK

 

    • Add this xml text in the RAW body section:

 

 

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<content type="application/xml">
<m:properties>
<d:DeviceType>Android</d:DeviceType>
</m:properties>
</content> </entry>
    • Here i have added DeviceType as Android. That means registration will be for Android device.
    • Possible valid values for DeviceType are:

 

                       

 

DeviceTypeDevice
iPhoneApple iPhone

iPad

Apple iPad
iPodApple iPod
iOSiOS devices
BlackberryBlackberry devices
Windowsincludes desktop or servers with Windows OS,
such as Windows XP, Windows Vista, Windows 7, and Windows Server series OS
WinPhone8includes Windows mobile
Windows8includes Windows desktop version

 


Note: Any other value for above mentioned DeviceType returns a value "Unknown" in the DeviceType column.


Here you go,


        POST.png



Response:


    Status as 201 created and in the Response headers you will see the newly created X-SMP-APPCID



201.png


 

2. To Verify the same device registration in the Admin cockpit:

 

     Here, you can see that total registration against com.test.dept application is '1'.

AppReg.png

 

Go to REGISTRATIONS tab:

 

Here, userName is smpAdmin for the DeviceType Android.

 

REg.png

 

 

CRUD operation for the given OData service through SMP server:


Since we have already created one application id for the given Odata service. Now we have to test if we are able to do GET, POST,PUT, DELETE operation for the same.


GET (Reading a record)

 

Method; GET

 

 

URIhttp://localhost:8080/com.test.dept (http://smpserverip:8080/appid)


Header Sections:


 

KeyValue
Authorizationsame smpuserid and password
Content-Typeapplication/xml
X-CSRF-TokenFETCH


For information, SMP 3.0 SP03 Integration gateway has a feature to enable the CSRF Token handling. It is required to catch a Token before posting data. Basically CSRF Token are used to creation data successfully with security.See Cross-Site Request Forgery (CSRF)  for additional details.

Response:


GET1.png

 

 

 

<?xml version="1.0" encoding="UTF-8"?>
<service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xml:base="http://localhost:8080/com.test.dept/">
   <workspace>
      <atom:title>Default</atom:title>
      <collection href="DEPARTMENT">
         <atom:title>DEPARTMENT</atom:title>
      </collection>
   </workspace>
</service>

Here, you can see the collection details e.g. DEPARTMENT

 

More precisely, To view the content for the DEPARTMENT table, run this URL http://localhost:8080/com.test.dept/DEPARTMENT

 

 

<?xml version="1.0" encoding="UTF-8"?>
<feed 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" xml:base="http://localhost:8080/com.test.dept/">
   <id>http://localhost:8080/com.test.dept/DEPARTMENT</id>
   <title type="text">DEPARTMENT</title>
   <updated>2014-07-01T22:55:58.367+05:30</updated>
   <author>
      <name />
   </author>
   <link href="DEPARTMENT" rel="self" title="DEPARTMENT" />
   <entry>
      <id>http://localhost:8080/com.test.dept/DEPARTMENT('101')</id>
      <title type="text">DEPARTMENT</title>
      <updated>2014-07-01T22:55:58.367+05:30</updated>
      <category term="DEPARTMENT.DEPARTMENT" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
      <link href="DEPARTMENT('101')" rel="edit" title="DEPARTMENT" />
      <content type="application/xml">
         <m:properties>
            <d:DEPT_ID>101</d:DEPT_ID>
            <d:DEPT_NAME>ADMIN</d:DEPT_NAME>
            <d:DEPT_LOCATION>ITC-1</d:DEPT_LOCATION>
         </m:properties>
      </content>
   </entry>
   <entry>
      <id>http://localhost:8080/com.test.dept/DEPARTMENT('102')</id>
      <title type="text">DEPARTMENT</title>
      <updated>2014-07-01T22:55:58.368+05:30</updated>
      <category term="DEPARTMENT.DEPARTMENT" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
      <link href="DEPARTMENT('102')" rel="edit" title="DEPARTMENT" />
      <content type="application/xml">
         <m:properties>
            <d:DEPT_ID>102</d:DEPT_ID>
            <d:DEPT_NAME>HR</d:DEPT_NAME>
            <d:DEPT_LOCATION>ITC-2</d:DEPT_LOCATION>
         </m:properties>
      </content>
   </entry>
   <entry>
      <id>http://localhost:8080/com.test.dept/DEPARTMENT('103')</id>
      <title type="text">DEPARTMENT</title>
      <updated>2014-07-01T22:55:58.368+05:30</updated>
      <category term="DEPARTMENT.DEPARTMENT" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
      <link href="DEPARTMENT('103')" rel="edit" title="DEPARTMENT" />
      <content type="application/xml">
         <m:properties>
            <d:DEPT_ID>103</d:DEPT_ID>
            <d:DEPT_NAME>FINANCE</d:DEPT_NAME>
            <d:DEPT_LOCATION>ITC-3</d:DEPT_LOCATION>
         </m:properties>
      </content>
   </entry>
   <entry>
      <id>http://localhost:8080/com.test.dept/DEPARTMENT('104')</id>
      <title type="text">DEPARTMENT</title>
      <updated>2014-07-01T22:55:58.368+05:30</updated>
      <category term="DEPARTMENT.DEPARTMENT" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
      <link href="DEPARTMENT('104')" rel="edit" title="DEPARTMENT" />
      <content type="application/xml">
         <m:properties>
            <d:DEPT_ID>104</d:DEPT_ID>
            <d:DEPT_NAME>FACILITIES</d:DEPT_NAME>
            <d:DEPT_LOCATION>ITC-4</d:DEPT_LOCATION>
         </m:properties>
      </content>
   </entry>
</feed>

Backend.PNG

For POST, PUT, DELETE

 

There is a known issue and will be addressed in next SP. Reference

For a POST request to integration gateway you need to provide the CSRF token and additionally the X-SMP-SESSID. Usually SMP will forward the client cookies/headers to the backend, only SMP specific headers e.g. X-SMP-APPCID and also the header X-SMP-SESSID will be filtered and not sent. In case of the integration gateway this seems to be really an issue.

 

 

 

Reference: REST API App Development

For more information: Follow SAP Mobile Platform Developer Center, SAP for Mobile

 

I hope this will blog will help you to understand basic concept of on-boarding of device at SMP 3.0 using REST client.

 

Your comments and feedback are most welcome.

 

Cheers,

JK  

Midhun VP

SMP 3 - Develop App and Test

Posted by Midhun VP Jun 27, 2014
Odata SDKSMP ConfigurationDevelop App and Test

 

Creating Project and Importing Libraries

Create a new Android project in eclipse > Right click on libs folder and choose Import > General > File System. Browse to Odata SDK folder . The Odata SDK can be found inside the SMP SDK as given below.

ScreenHunter_162 Jun. 27 03.03.jpg

Choose the below libraries from column on the right and click on Finish.

Common, Connectivity, Coreservices, gson, Parser, perflib, Request and sap-e2etrace.

ScreenHunter_162 Jun. 27 03.04.jpg

Right click on the project and choose Build path > Configure Build Path, click on Libraries tab, then click on Add Jars. Select the project created from the list and go inside libs folder and choose all the jar files and click on OK.

Project after adding jar files:

ScreenHunter_162 Jun. 27 03.11.jpg


Initialize application

Login.java class will be called first in the project. The application has to be initialized when it starts first time.

Clientconnection parameters has to be set before registration. You can find the App ID and security name in the code below, that was created during SMP configuration.

 

String returnMsg = "success";

  try

        {

  mApplication.setUsername("P0000000000");

  mApplication.setPassword("Initial123");

  ClientConnection clientConnection =

  new ClientConnection(getApplicationContext(),

  "com.test.android",

  null,

  "SAPSecurity",

  mApplication.getRequestManager());

  clientConnection.setConnectionProfile(true, "66.175.100.29", "8080", null, null);

         UserManager userManager = new UserManager(clientConnection);

         userManager.registerUser(true); //Registering user

 

Creating Request

After successful registration the control goes to the Registration_Success class. The service document and schema are accessed in this class. The Request manager makes HTTP requests to server. The requests are asynchronous, hence listeners to get the response. If the response of the request is success Onsuccess method is called else onError method.

 

public void onSuccess(IRequest aRequest, IResponse aResponse) {

  try {

  HttpEntity responseEntity = aResponse.getEntity();

  String responseString = EntityUtils.toString(responseEntity);

  Parser parser = mApplication.getParser();

 

 

 

  if (aRequest.getRequestTAG().contentEquals(REQUEST_SERVICE_DOCUMENT)) {

  mServiceDocument = parser.parseODataServiceDocument(responseString);

 

  } else if (aRequest.getRequestTAG().contentEquals(REQUEST_METADATA)) {

  IODataSchema schema = parser.parseODataSchema(responseString, mServiceDocument);

  mApplication.setODataSchema(schema);

  RequestBuilder.getInstance().setSchema(schema);

  }

  mSuccess = true;

  mHandler.post(mUpdateResults);

  } catch (ParseException e) {

 

  } catch (IOException e) {

 

  } catch (IllegalArgumentException e) {

 

  } catch (ParserException e) {

 

  }

 

public void onError(IRequest aRequest, IResponse aResponse,

  IRequestStateElement aRequestState) {

  //Post to UI Thread

  mSuccess = false;

  mHandler.post(mUpdateResults);

  }

  }

 

Parsing Data

In the DataAccess class a request is made with the collection ID "BusinessPartnerCollection" to retrieve the data based on a particular collection ID (In a browser it can be teste using the URL http://sapes1.sapdevcenter.com:8080/sap/opu/odata/iwbep/gwdemo/BusinessPartnerCollection).

Retrieve the data from the response using the parser.

 

public void onSuccess(IRequest aRequest, IResponse aResponse) {

  try {

  HttpEntity responseEntity = aResponse.getEntity();

  String responseString = EntityUtils.toString(responseEntity);

  Parser parser = mApplication.getParser();

  IODataSchema schema =mApplication.getODataSchema();

Entries = parser.parseODataEntries(responseString, "BusinessPartnerCollection", schema);// Parsing Data

  mSuccess = true;

  mHandler.post(mUpdateResults);

  } catch (Exception e) {

  e.printStackTrace();

  }

  }

 

The value of the property can be accessed using the below code:

List poset = new ArrayList();

for(IODataEntry entry:Entries)

    {

           String Street = entry.getPropertyValue("Company").toString();// Company is a property in Odata

           poset.add(Street);

    }

 

The property "Company" is populated in a list view in Android.

android screen list.png

 

Download Source Code


 

Midhun VP

@midhuntwit

Odata SDKSMP ConfigurationDevelop App and Test

 

Getting Started

Create a new application in Management cockpit and configure the application settings as given below:

ScreenHunter_161 Jun. 25 00.13.jpg

Define backend connection. I am using an existing Odata service from Gateway trial system: http://sapes1.sapdevcenter.com:8080/sap/opu/odata/iwbep/gwdemo/

ScreenHunter_162 Jun. 27 02.44.jpg

Under Authentication tab create a new security called "SAPSecurity" >Click on New and choose "HTTP/HTTPS Authentication". Provide the Odata URL: http://sapes1.sapdevcenter.com:8080/sap/opu/odata/iwbep/gwdemo/ . Choose Control as "Required".

The security profile defines server authentication during user on boarding.

ScreenHunter_162 Jun. 27 02.45.jpg

ScreenHunter_162 Jun. 27 02.48.jpg

Finally Save the application. Select the application created and click on "ping", that should give a success message. The created application details are used during development of native app.

ScreenHunter_162 Jun. 25 00.22.jpg

OdataSDKSMP ConfigurationDevelop App and Run

 

Odata is an open standard, and SAP's recommended way of mobile app development is using Odata. It allows access to different data sources in a common way.

ScreenHunter_162 Jun. 27 01.30.jpg

           Source: SAP

 

The Odata SDK comes with SMP SDK. Currently the Odata SDK supports Android and IOS. Native mobile applications for other mobile OS like Windows Phone or Blackberry can be developed using REST APIs. Both online and offline applications can be developed using Odata SDK (offline is supported from SP03). In this example I am developing an online application and not explaining how to achieve the offline features.

Given below are the components of Odata SDK:

ScreenHunter_162 Jun. 27 01.47.jpg

       Source: SAP

 

I am using the below components (libraries and classes) during the development of the application to register user and consume data in the device:

Request: Provides the interfaces for handling online and offline requests and handles data streaming from server to device and vise versa.

Parser: Helps in parsing the Odata feeds, service document and metadata and converts them to native objects.

Logger: For logging, error and exception handing.

Connectivity: It handles connectivity related task like synchronous and asynchronous HTTP requests.

Core Services: It provides APIs for registration, exchanging settings between client and server, client logging and push notifications.


Development Environment:

SMP 3 SP03 PL01 cloud trial version: Sign up for SMP 3 SP03 PL01 trial

SMP 3 SP03 PL01 SDK : Download and install Mobile SDK 3.0

Android SDK: Android SDK | Android Developers

Gateway Trial to access Odata service: SAP NetWeaver Gateway Developer Center

SMP3 Sizing

Very often I get asked from customers or collegues how to size a SMP3 landscape. In this post I will try to give some hints on how to perform a sizing for SAP Mobile Platform 3.0.

 

In previous SUP/SMP versions there was a Sizing Guide available, which could be used. With SMP3 the official answer to sizing questions is the "SAP Quicksizer". This is a sizing tool, which is used already for different SAP products. With the relase of SMP3.0 it got enhanced to also support sizing of SAP Mobile Platform (OData and Mobiliser) scenarios.

Below I will describe briefly how to use the SAP Quicksizer. At first I will introduce the neccessary data you need to have (or to find out) to get a correct sizing (for OData based app handling). There are mainly two indicators you need to have:

 

  1. Number of Request per Second (The Quicksizer is working with Number per Requests per hour)
  2. Average payload of the request

An HTTP request usually contains a header, which includes header variables like cookies or authorization information and optionally a body, which contains the payload (e.g. if you want to create a new object you would execute a HTTP POST request with the xml or json representation of the object inside the body). The Server (in our case SMP3) will reply to this HTTP request with an HTTP response, e.g. HTTP 200. The reponse can contain data, for example if you send a GET request to get all elements of an OData collection, you will find in the reponse many XML or JSON objects inside the response body.

 

An estimation of the number of requests is not an easy task. Think about the app or apps that should be running on SMP. How many users are using this app? Are there peak hours? With an average using of an app how manny requests will be sent to SMP?

 

In the following you will find sizing information for a single node SAP Mobile Platform 3.0 SP03. This sizing information is aquivalent to the results the SAP Quicksizer Tool will give you. The needed hardware for the SMP server is provided in categories (T-Shirt sizes like XS, S, M, L, XL, XXL) and also in concrete SAPS. The needed RAM/Memory is also provided. The Database Disk is (for this sizing) a fixed value, defined as 101 GB.

02_Number_of_Req_Sizing_Result.png

This picture should only give you a hint/an idea about your SMP sizing. For a concrete sizing please always use the SAP Quicksizer.

 

Beside the number of requests you need the average size of the payload. Some things to consider when handling with payload:
Many backends, e.g. the SAP Netweaver Gateway support compressing the payload using gzip. You could ask for compressed payload by setting the header "Accept-Encoding" with value "gzip" into your HTTP request. In a SMP3 sizing you will usually calculate with the uncompressed payload.

The payload size also differs whether you implement the app using XML or JSON for encoding the payload. JSON will be significantly smaller than XML.

 

XML vs. JSON

 

In the following picture I measured the response payload size and needed time for XML and JSON requests against the Test Netweaver Gateway System sapes1.sapdevcenter.com. More specific a defined number of records are requested from the BookingCollection of the Sample OData Flight Service (RMTSAMPLEFLIGHT), so e.g. for 10 records in JSON encoding an HTTP GET request to following url was fired: http://sapes1.sapdevcenter.com:8080/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/BookingCollection?$top=10&$format=json

 

01_XML_vs_JSON.png

As you can see, the JSON encoded HTTP reponses have a smaller payload and will thus also be transfered in less time.


SAP Quicksizer

 

Actually the SAP Quicksizer is quite easy to use. I will describe in the following on how to create a sizing for SAP Mobile Platform.

1. Open the SAP Quicksizer http://service.sap.com/quicksizer
2. Click on "Start Quick Sizer"
3. Specify your Customer number, a project name (e.g. TestSMP3Sizing) and then create a project. If you already have a project, simply specify your project name and choose "Display Project" or "Change Project".

  03_SAP_Quicksizer_Create_Project.png
4. The Quicksizer window will open. Inside the "Tree of Elements" expand the folder "Mobile" and choose "SAP Mobile Platform".
5. Now you can see on the right side a Table 1 which will help you to size OData based scenarios. So type in your number of request per hour in Thousand. Note: Nuber in Thousands means that your specified number will be multiplied with 1000. Beside that specify the average Payload for each request in Kilobyte. The time frame can be adjusted with changing both fields right to the Payload field. By default, one peak hour is specified (in this case from 12:00 to 13:00)
6. After that click on the button "Calculate result" at the top of the page

04_SAP_Quicksizer_Setting_Throughput_Values.png


7. In the next screen you will see the result. So it shows you the CPU category, the number of SAPS, the total memory and the database disk size.

05_SAP_Quicksizer_Outcome_Result.png

8. Now you got the sizing results. Note that currently the Quicksizer sizing is focussing on a single node.


SAP Mobile Platform Scaling Whitepaper

 

There is also an interesting Whitepaper from SAP and Intel available, you can access it here: http://www.intel.in/content/dam/www/public/us/en/documents/white-papers/enterprise-security-sap-mobile-platform-scaling-paper.pdf

I’ve been having a terrible time with the xCode6-beta2 Swift compiler’s auto-complete, when using objective-c headers and libs in .swift files. The application was compiling ok at build time, but after build, xCode would revert to popping an error for `unknown Type` for the objective-c classes.

I found that switching from a higher-level header search path with recursive search, to multiple specific paths without recursive search, resolved the issue.

$(PROJECT_DIR)/../../target/headers/$(BUILD_STYLE)-$(PLATFORM_NAME)/**

becomes

$(PROJECT_DIR)/../../target/headers/$(BUILD_STYLE)-$(PLATFORM_NAME)/com.sap.smp.client.ios/XScriptParser

$(PROJECT_DIR)/../../target/headers/$(BUILD_STYLE)-$(PLATFORM_NAME)/com.sap.smp.client.ios/ODataAPI

$(PROJECT_DIR)/../../target/headers/$(BUILD_STYLE)-$(PLATFORM_NAME)/com.sap.smp.client.ios/ODataOnline


usw.

I would like to show you the steps to create an admin user in SAP Managemant Cockpit.

 

Step 1:

 

Log on to SAP managment cockpit , https://<ServerName>:<Port>/Admin/

 

Step 2:

 

Go to Settings --> Security Profiles --> admin (cannot be deleted)

Note: Do not create any new security profile, use the default security profile as mentioned above. i.e admin (Cannot be deleted) profile.

SMP cockpit1.JPG

Step3 :

 

Once you click on admin(cannot be deleted) security profile, a new window appears.

 

Click New and select system Login (Admin Only) as authentication Providers as shown in below screen shot.

 

SMP cockpit2.JPG

 

Step 4:

 

Click Create and another window appears as shown in below screen shot. Type the username and password. Give the Role as Administrator. Note: If the Roles section is empty then admin user will not be created.

 

SMP cockpit3.JPG

 

Step 5:

 

A new admin user would be created and now login with your newly created admin user. The same username would be valid to access the Gateway management cockpit also.

Actions

Filter Blog

By author:
By date:
By tag: