Skip to Content
Author's profile photo Former Member

New Guides Available about How to Develop Custom Java and JavaScript Clients for SAP Mobile Documents

SAP Mobile Documents delivers not only several clients and a server component, but also an SDK that allows you to develop your own client. Some time ago, I wrote a blog about the development of a custom iOS client. See here:

How to Develop a Custom iOS Client for SAP Mobile Documents

I would like to make you aware of my two brand new how-to guides that have just been published on SCN. The guides show the development of a custom Java client and a custom Java Script client. I explain in detail what you have to do and what you have to be aware of when creating your own client, including prerequisites and necessary settings. You can even download sample code from within the guides.

So check out the following two new how-to guides:

Developing a Custom Java Client for SAP Mobile Documents

Developing a Custom JavaScript Client for SAP Mobile Documents


Simon Oehm

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Christian Schäfer
      Christian Schäfer

      Hi Simon,

      Thanks for your guide on developing a custom javascript client - that really helped me getting started!

      My question is, are there or have you any examples on uploading a existing file or picture from a mobile device? I have a JavaScript application and try to upload a picture via an ajax call and can't get it to work.


      Christian Schäfer

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Christian,

      as stated in the official CMIS specification you have to perform a HTTP multipart form request:

      Browser applications typically use HTTP multipart forms as described in [RFC2388] to create and update content.

      This is especially useful for updating file content with the addition of the FILE attribute in [RFC1867].

      In this binding, HTTP POST of multipart/form-data MUST be used to update content streams.

      The specification is a really good resource and also explains how to execute cmis operations via browser binding.

      A typical upload to SAP Mobile Documents might look like the following coding (will not work in old browsers like IE9 because there is no file api):

            var repositoryConnection = repositoryService.


                 uploadURL = repositoryConnection.getRootFolderUrl() + '?x-token=' +



                      type: "POST",

                      url: encodeURI(uploadURL),               

                      data: createRequestData(),

                      processData: false,

                      contentType: false,               

                  }).done(function(data) { // upload successful}).fail(function(error) { // upload failed});


        function createRequestData() {

                  var formData = new FormData(), i;

                  formData.append("objectid", parentFolderId);

                  formData.append("cmisaction", "createDocument");

                  formData.append("propertyId[0]", "cmis:name");

                  formData.append("propertyValue[0]", fileName);

                  formData.append("propertyId[1]", "cmis:objectTypeId");

                  formData.append("propertyValue[1]", objectTypeId);

                  formData.append("_charset_", "UTF-8");

                  formData.append("media", file); // this is the content stream of the document (a                                                              file object created with the JavaScript file api)

                  // add additional properties to the document

                  for (i = 0; i < properties.length; i += 1) {

                      formData.append("propertyId[" + (i + 2) + "]", properties[i].getName());

                      formData.append("propertyValue[" + (i + 2) + "]", properties[i].getValue());


                  return formData;


      Regarding the usage of the file api have a look here: Using files from web applications | MDN

      Good luck!

      Best Regards,


      Author's profile photo Christian Schäfer
      Christian Schäfer

      Thank you for the fast and really detailed answer!

      Nevertheless I don't get it to work. I'm getting my picture's data via .readAsBinaryString(file) and append the result to the formData with the key "media" just like you did. When the request is send, my app shows some network traffic and it takes about half a minute (for a 1.2 MB .jpg) before i get into the .done() callback. A file with my given name is created on the server, but with a size of 0KB, that I can't open or download at all. It seems like the data is sent, but the server can't process it properly. Any idea on that?

      Thank you in advance, Regards


      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Christian,

      glad to hear that you are at least able to create a document in mobile docs. This means that your request should be fine.

      Maybe you can try to create a fake blob that just contains a string in order to test if the upload works properly:

      var text = "test string",

           blob = new Blob([text]),

           newBlob = blob.slice(0, blob.size, "text/plain");


      formData.append("media", newBlob);

      If this works then you definitely have an issue with your file object.

      Best Regards,


      Author's profile photo Christian Schäfer
      Christian Schäfer

      Got it working by now!

      First I tried creating a text file like you proposed, which worked without a problem. But I had indeed a problem with my file object - I had to convert my base64 string to an Uint8Array before sending it to the server to make it work.

      Thank you very much!!

      Best Regards,


      Author's profile photo John Whelan
      John Whelan

      Hi Simon,

      I followed the guide for setting up a Java Client for SAP mobile documents.

      However, I'm getting an CMISConnectionException error: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 403 Forbidden".

      I am using my as the Mobile Documents server.

      When I don't set the proxy server settings, I get an unknown host exception.

      Any ideas how I can overcome this problem?



      Author's profile photo Former Member
      Former Member

      Hi John,

      do you face the same issue in the SAP Mobile Documents desktop client when specifying the same proxy parameters (using manual proxy) as in your java client?

      Best regards,