Hi there.

SAP Mobile Platform Enterprise Edition, Cloud Version is available for almost half a year now. Also the trial version is accessible for many months. With the openSAP course “Introduction to SAP HANA Cloud Platform”, which also covers SMP Cloud (not the official name, but much shorter) the interest in SMP Cloud is much higher than before. In this course (Week 6, Advanced Topics) I show a quick demo how to set up the SMP Cloud and use it to run a mobile Web App. One aspect that is not really visible there is, that each device (in this case it is the browser) has to be registered (also referred as “onboarding”) in order to access the data of the backend. This is a quite simple task for an app if you know how to do it. This following How-To should demonstrate how it is done. To make it more interesting for anyone I will explain it and you can follow each step by yourself in a second browser window.

So prepare yourself to use SMP Cloud with Copy & Paste.

Disclaimer: I am willing to help you if something is broken and you can’t follow the steps for some reason. But answers will be given on a best effort base only. I will do what I can, but I can’t provide 24/7 support here.

Please spend a couple of minutes to do your first steps with SMP Cloud. Well, obviously you need some prerequisites to start. So please make sure that you have the following ready at hand:

  • You need Google Chrome on your machine.
  • Please install the Postman Plugin, which allows creation of manual REST calls. You get the Plugin for Chrome from its Chrome Web Store.
    Alternatively you can use the RESTClient in Firefox.
  • Also, please register for a HANA Cloud Platform trial account if not done already.
    You can do it here: https://account.hanatrial.ondemand.com
  • We need a backend service to consume. NetWeaver Gateway is providing some sample services and we should leverage them. Create a user for the sample services here: http://scn.sap.com/docs/DOC-40986 or more directly here: https://supsignformssapicl.hana.ondemand.com/SUPSignForms
  • Make sure that you can access the backend service using your browser. Check you Email to see which is the initial password being set. Usually it is “Initial123”, but please check your Email.

Now we have everything we need. We have a device (simulated by the Chrome Postman Plugin), we have a backend OData service, and we have credentials to call the OData service. Finally we have a SMP Cloud trial account.

The overall steps we will process are like this:

  1. Create an Application in SMP Cloud
  2. Register a Device (onboard)
  3. Retrieve data from the backend via SMP Cloud
  1. Create an Application in SMP Cloud
    1. Start the SMP Cloud Admin UI using the HANA Cloud Platform Cockpit: http://account.hanatrial.ondemand.com/cockpit in a new browser window.
    2. On the left Content pane, click Services
    3. Now click the link to Mobile Platform, enterprise edition, cloud version. A new tab opens and you are now in the Admin console of SMP Cloud.
    4. Click on Applications on top of the Admin console.
    5. The list of Applications is empty and we want to create a new Application Configuration so click the New button.
    6. A dialog pops up. Provide “firstApp” as ID and your name as Name.
    7. Click Save.
    8. A new dialog appears. In the backend tab, copy the following link to the Endpoint textbox: http://sapes1.sapdevcenter.com:8080/sap/opu/odata/iwbep/gwdemo/
      This is your sample backend service.
    9. Set Connect to to Internet. This is important because it tells SMP Cloud where your service can be found.
    10. Select the Authentication tab on top of the dialog.
    11. Put in “mySecurity” in the Security Profile Name textbox.
    12. The section Authentication Type contains a textbox asking for a Authentication URL. Put again the URL of the backend in this textbox.
      http://sapes1.sapdevcenter.com:8080/sap/opu/odata/iwbep/gwdemo/
    13. Select “Internet” for the Connect to radio box.
    14. Click the Save button and confirm.
  • o. This concludes the SMP Cloud configuration.
  1. Register a Device (onboard)
    1. Start Chrome and open the Postman plugin
    2. Copy this to the adress bar in Postman:
      https://smp-{accountname}.hanatrial.ondemand.com/odata/applications/latest/firstApp/Connections
      Please substitute {accountname} with the Hana Cloud account name for your trial account. Typically it has the format of Sxxxxxxxxtrial.
    3. Set the HTTP method from GET to POST.
    4. Click the Basic Auth tab on top of the Postman.
      1. Put in your username and password for the backend service.
      2. Click Refresh headers.
      3. Click the Headers button right besides the POST URL.
      4. Add Content-Type header to the value “application/atom+xml; charset=UTF-8”. Check that you have the Content-Type header and the Authorization header listed here.
      5. Click the raw button below.
      6. h. Paste the following XML to the POST body:

<?xml version=’1.0′ encoding=’UTF-8′?>

<entry 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‘>

  <content type=’application/xml’>

<m:properties>

<d:DeviceType>Windows</d:DeviceType>

    </m:properties>

  </content>

</entry>

  1. i.      We have now everything in place to register our “device”. Click the Send button. You should see something like this:

….

<content type=”application/xml”>

<m:properties>

<d:ETag>2013-02-07 13:46:10.0</d:ETag>

<d:ApplicationConnectionId>a5d9041d-3a90-48c6-b00f-9952a4eaeacd</d:ApplicationConnectionId>

<d:AndroidGcmPushEnabled m:type=”Edm.Boolean”>false</d:AndroidGcmPushEnabled>

<d:AndroidGcmRegistrationId m:null=”true”/>

<d:AndroidGcmSenderId></d:AndroidGcmSenderId>

<d:ApnsPushEnable m:type=”Edm.Boolean”>false</d:ApnsPushEnable>

<d:ApnsDeviceToken m:null=”true”/>

  1. This is the response of a successfull registration request. It contains the ApplicationConnectionId. This information is very crucial for the subsequent step, so please copy it to your clipboard and into a textfile. This ID will be different for each registration, so obviously it will not exactly be the same like the one shown above.
  2. Retrieve data from the backend via SMP Cloud
    1. Now click the Reset button of the Postman plugin (the tiny little one on the right side of the browser window).
    2. Copy the this URL to the address bar of  Postman:
      https://smp-{accountname}.hanatrial.ondemand.com/firstApp
      Again, make sure you substitute {accountname} correctly.
    3. Add the headers for Authorization as done before. Provide the same backend credentials.
    4. Add a custom header X-SMP-APPCID and provide the APPCID from your clipboard as value.
    5. Click the Send button.

Congratulations!! You have just retrieved your first data using SMP Cloud. You can now play around and issue more OData requests. Just append OData queries to the GET URL. For instance https://smp-{accountname}.hanatrial.ondemand.com/firstApp/ FlightCollection?$format=xml

So, next steps would be easy. Just code this registration process into your App. If it’s an HTML5 App or a native App – the process is always the same here.

Also there are more things to do with SMP Cloud, this is just the beginning. If you want to read more, don’t hesitate to read the manual, you will be surprised how useful this can be. You can find the manual here: https://help.hana.ondemand.com/mobile/frameset.htm

Have Fun,

Martin Grasshoff

To report this post you need to login first.

11 Comments

You must be Logged on to comment or reply to a post.

  1. Nan Wang

    Hi martin

    thank you post a so great tutorial. I follow it but I can’t register my device correctly. when I post the xml message to https://…./connections uRL. server will post an error in the log. the respose http status is 200 but the 201. Do you have any suggestion on it? do we need to import certificate for https connetion? if so how to do it? please have a look on this post. http://scn.sap.com/thread/3452799

    thanks

    (0) 
  2. Ross HIghtower

    Thanks for the excellent tutorial.  I was able to make the application and then use it successfully in the follow up post using AppBuilder.  However, a day later when I run the app I don’t get data and I get an unauthorized error in the log.  I tried to create a second application using the same procedure and I’m able to register but when I perform a get I’m prompted for a user id: “The server https://url:443 requires a username and password.  The server says: SAP Mobile Platform.”  When I enter my credentials, I’m prompted for the username and password for the service.

    Any help would be greatly appreciated.

    Thanks,

    Ross

    (0) 
    1. Martin Grasshoff Post author

      Hi Ross.

      When you come back to your app in the second day and you issue the GET request, did you pass your X-SMP-APPCID? You have to keep that value and pass it in every request.

      Also each request needs the Authorization header.

      -Martin

      (0) 
      1. Ross HIghtower

        Thanks for responding Martin,

        Yes, I include the x-smp-appcid and the authorization header.  I can access the service document directly in postman using the same credentials and it was working the day before.  I find this in the server log file:

        <h2>What has happened?</h2><p>Call of URL https://smp-s0009700438trial.hanatrial.ondemand.com/firstApp/ terminated due to error in logon data.</p></td></tr><tr><td> </td></tr><tr><td class=”emphasize”><strong>Note</strong><br><ul><li> Logon performed in system ES1. </li><li> Logon performed for client 520 and language EN. </li></ul></td></tr><tr><td> </td></tr><tr><td><p>  </p><h2>What can I do?</h2><ul><li> Check the validity of your SSO ticket for this system. </li> <li> If you do not yet have a user ID, contact your system administrator. </li></ul>


        Ross

        (0) 
          1. Ross HIghtower

            Thanks, I will.  I noticed another odd issue.  I deleted the application connection but when I try to register I get a 403 error and the message is that the connection already exists.  When I look at the application log, it includes the 403 error and includes a APPCID.  It appears that deleting the application connection in the cockpit didn’t actually delete the connection.

            Ross

            (0) 
            1. Martin Grasshoff Post author

              Hi.

              Well, in addition to the headers Postman automatically uses cookies and if headers are absent in a request, cookies are recognised by SMP Cloud. So to resolve the issue, just clear the cookies from Postman – not from the whole browser.

              Have Fun,

              Martin

              (0) 
  3. Arpit Oberoi

    Hello Martin,

    I am trying to configure SMP settings in my app designer and I am getting following error:

    Failed to connect to SMP Onboarding Service. The error message is:

    {}

    Is there any way to debug/trace the reason for this error?

    Thanks,

    Kind Regards,

    Arpit

    (0) 
  4. Mayur Dharukiya

    Thanks Martin. I followed all the steps and it worked very well. Can you also tell me how to  Deploy App from App Builder to Mobile?

    (0) 

Leave a Reply