Omnichannel Services – First Service

In my previous video, I started the practical exercise of setting up omnichannel services in the cloud by creating a server in the Amazon cloud. Now it’s time to create the first service, and even if I will do that using a simple PHP script, I will also indicate how it can be done on other platforms.

The example I have chosen is to get the most popular free apps from the Apple App Store, which is provided as an RSS feed in XML format. The idea is that we have an app that would show the top list of free apps. Even if this is a simple example, there is not much difference with getting information from a back-end system like SAP and Siebel. In a real-world scenario, the work of the service would be divided into different tiers with specific responsibility (low-end services to connect to back-ends, high-end services to add business logic and processes, and front-end services that provide customized functionality and data to the touch points, i.e. apps and webs).

If we start by looking at what we get from the source, we see that there’s a lot of information returned, and not only that, there is also a lot of meta-data, which comes with the XML format. What we would like to send to the app is just a few pieces of the information about each app; the name, the developer, and some images (marked with yellow). We also want this information to be in JSON format as that will minimize the overhead in terms of meta-data. The desired output should look something like that shown in the second slide, and that is obviously much more efficient to send over a low bandwidth.

When we look at the PHP code to access the service and transform the data to what the app needs, we can see that the source XML is downloaded (line 2) and parsed in to an XML object model (line 3). For each found app (line 6), the data is parsed (line 9-14) and added to an array (line 15), and then a root object (line 17) and headers (line 18-19) are added to the response before it’s converted to JSON and returned to the app (line 20).

There are also examples of how it would look in java (a JSP page) and .NET (an ASP.NET page in C#).

There are several ways you can get the code onto the server, but a very convenient way is to use a tool like Coda (https://panic.com/coda). With it you can easily set up a connection to the server by supply its domain name or IP address, the user (ubuntu), and the key pair file. When you have logged in, you can see on the left that you are in the user’s folder, and to add the service, we need to navigate to the web server’s root folder (/var/www). Once there we create a file and add the code, and save the file. Now we can test the service by opening a web browser with the URL http://0.0.0.0/getiOSApps (where 0.0.0.0 is replaced with your server’s IP address).

There you have an omnichannel service running in the cloud that can be access by your apps or webs.

You can download the source code.