ESME Blog

enterprise microsharing in a process context
November 4, 2008

Pure Javascript Messaging Client

Author: dick - Categories: Background, Development, Marketing - Tags: ,

There is a now a message-receiving client for ESME that is written entirely in Javascript. This very first cut of a client was created as a proof-of-concept to show that a very simple client was possible without any dependence on the server-side programming language.  Based on the current implementation, it could be embedded in Java, C#, etc. It could run in a variety of environments including SharePoint, SAP Portal, etc.

This first version offers:

  • Long-polling
  • Flexible design
  • The client uses XSL transformation to create HTML from the XML that originates from the ESME’s REST-API

The drawbacks of this first version:

  • The UI is real ugly. Someone needs to redo the XSL file.
  • The UI is not complete. I have not added all the features that are possible (reply, etc.). I was more intent on showing ESME messages in a Javascript-based environment.
  • It is not bug-free
  • I have only tested it in Internet Explorer 6.0. Someone might have to go and try it out in FF.
  • XSL file is currently local instead of stored on server
  • The token is currently hard-coded. 
  • Documentation is still pretty poor.

Thanks to Darren for doing the initial corrections that started me out on the right foot.

The code is in the Google Code wiki.

October 3, 2008

ESME Integration: Javascript

Author: dick - Categories: Development - Tags: , ,

In preparation for our presentation at the DemoJam in Berlin, I wanted to find a way to mimic ESME functionality of applications to which I don’t have direct access. I wanted to to be able to click on a HTML page with a image (screenshot) and have an ESME message sent. I thought about it and did some digging / experimenting and finally found an easy via javascript.

The resulting code is based on the VBA code that I described in a previous blog.

To authenticate themselves, ESME users must replace “[REPLACE_TOKEN]“ with their own authorization token. Tags are currently hard-coded as well. 

<script type=”text/javascript” language=”javascript”>
   var http_request = false;
   function makePOSTRequest() {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,…
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
             http_request.overrideMimeType(’text/html’);
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject(”Msxml2.XMLHTTP”);
         } catch (e) {
            try {
               http_request = new ActiveXObject(”Microsoft.XMLHTTP”);
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert(’Cannot create XMLHTTP instance’);
         return false;
      }
     
      http_request.open(”POST”, “http://api.esme.us/esme/api/login?token=[REPLACE_TOKEN]“, false);
      http_request.send(null);
      http_request.open(’POST’, “http://api.esme.us/esme/api/send_msg?message=javascript_test+AJAX&tags=Test,javascript&via=js“, false);
      http_request.send(null);
      http_request.open(’GET’, “http://api.esme.us/esme/api/logout“, false);
      http_request.send(null);

   }
  
</script>
<form name=”myform” id=”myform”>
<input type=”button” name=”button” value=”Submit”
   onclick=”javascript:makePOSTRequest();”>
</form>

Just copy this code into an empty text file, rename it “ESMEtest.html”, load the local file in your browser and you can create ESME messages.   This code could be enhanced and placed in more complex applications.

Note:  I’ve only tried it locally and with Internet Explorer. Maybe someone can test in FF to see if it works there as well.