Browse Category by Oracle Mobile Cloud Service

MCS: Calling SOAP connector bypassing XML/JSON translator

In the MCS project we are working we have to create some SOAP Connectors to integrate with Siebel. A great thing of MCS is that although we are going to consume a SOAP web service, the XML payload is automatically translated into JSON. You can get more info in MCS Documentation.

I would like to thank Oracle Mobile PM  team, specially Grant Ronald and Frédéric Desbiens for their great help and for sharing best practices about this issue.

As soon as we create a SOAP Connector and try to test it we can see that the body we have to provide is a JSON.

But there are some cases where the translator is not perfect. We had a problem with some services that had an XML structure like this:

The translator seems not to add the  namespaces in the header therefore Siebel cannot parse the request.

The solution is to send a XML instead of a JSON, bypassing the translator.
We can test this in SOAP Connector tester. As we need the required XML, we can get it in any web service client tool like for example SoapUI.

We also have to set “Content-Type: application/xml;charset:UTF-8” and “Accept: application/xml” as header parameters.

If we test the Connector we can see that the web service call is working.

How do we implement the Custom API to send a XML payload to the connector?
The answer is to set the XML we want to send as the body of the request and set the header parameters we previously use to test the connector.

But, is this the recommended approach? Yes it is, but instead of sending a String with the SOAP message it is more secure to send it as a JavaScript object.

In order to implement this we have to follow some steps:

  1. Download and Install Node.js. link
  2. Install xml2js module.
  3. In this example test_rrs is the directory where the package.json file resides.

  4. Add xml2js as a dependency in package.json
  5. Moving to our javascript file, as I already stated before the first idea was to build the SOAP message as a string. This first image is the base implementation and we are going to make some changes to it.
  6. First we need to add var xml2js = require(‘xml2js’); at the top of our implementation.

    This is the tricky part, we need to create a JSON like this.
    ‘ $ ‘ means that we want to add attributes to the XML element.
    ‘ _ ‘ means that we want to have something inside that element.

    The last thing we have to do is to create a xml2js.Builder object and execute buildObject method using the json object we have just create. The result of this method is the body we are going to send.
After the implementation is done we just have to put everything inside the zip file and upload it to MCS.
If you want to know more about xml2js click here.

Oracle Mobile Cloud Service 3 Days Workshop in Madrid

Last week I had the chance to attend a Mobile Cloud Service 3 days workshop in Madrid. This was the first MCS training in Spain where some partners and I were able to get a good insight about what MCS offers and also a complete hands-on.

If you want to know MCS functionality you can check my previous post: Oracle Mobile Cloud Service overview.

Although I already attended Oracle Summer Camps workshop in Lisbon, we are in the middle of a MCS development and  this workshop was a perfect fit for mastering my MCS skills and also any question we made was perfectly answer by Mireille Duroussaud (Senior Principal Product Manager).

We were also able to see some of the features that will bring the next versions of Mobile Cloud Service like Mobile Application Accelerator (Oracle MAX), and hear of others like for example a JavaScript editor for implementing and debugging APIs right in the browser.
I was really impressed about Oracle MAX becasue building a Mobile Application connected to Mobile Cloud Service was just a matter of 10 minutes. Although the things you can do with Oracle MAX are limitted, it is likely possible that we will be able to donwload the source code of the generated application to extend it wich is a nice feature.
I think this is a must-attend workshop it you are planning to start a Mobile Cloud Service project anytime soon. You can also check Oracle Mobile Platform Youtube channel where you can find more than 50 videos about MCS.

MCS: Custom API that calls a SOAP Web Service

In one of the other posts about MCS i showed how easy we can create an API that makes a call to an external REST web service. MCS Connectors also allows to connect to a SOAP web service. Although there is a couple of different things I am going to start the process from the beginning.

  • Creating the connector

We have to head to Connectors page, click on New Connector button and pick SOAP sub menu.
In the popup we need to fill some information including the SOAP web service URL.
We are going to use a public weather service:
http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL 

Our connector has been created. Now we can configure settings like connection timeout or add security policies.

In this example we are not going to add any extra setting so we can continue to the last step, Test.
As you can see although this is a SOAP web service, the tester let us introduce a JSON payload.
This is one of the great things of MCS, the SOAP Connector uses a JSON translator and transforms automatically the JSON that we are going to use to the xml that the SOAP web service needs.

Now if we set a zip code into the JSON and click on Test Endpoint we can see that the web service returns us the weather of that zip code.

  • Create and Implement a Coustom API.

Now that the connector is up and running we need to create a Custom API that will make the call to the connector.
We have to navigate to APIs page and click on New API.

In the popup we have to fill the name of the API and a short description or upload a RAML file.

Now there is a setting we have to change in order to avoid authentication and having to create users. Head to Security option and be sure to select On  in Allow Anonymous User Access.

We need to create an Endpoint we click on New Resource and add {zipcode}. This is the parameter that our API will need to send it to the connector call.

After that, clicking on methods (in the right hand side) we will add a GET method.

Now that we have designed the API, we need to implement it by downloading the JavaScript Scaffold.

In the zip file there are 4 files.

package.json is the file where we can set the dependencies of our API, in this case we have to add our connector’s URI.

In myweatherapi.js file we have to make the implementation.
There is a couple of things that differs from the REST connector call.
  1. In the URI of the connector we also have to add the name of the method that we are going to call, in this case GetCityForecastByZIP.
  2. We need to build the JSON that we will send to the connector.
To achieve the second point we can use the example payload from the connector tester and put zipcode parameter.
After building the JSON we have to make a post call to the connector.

Once we have finished the implementation we have to pack the files in the same zip filethat we have downloaded and upload it to MCS.
The last step is to test out API. Just type a zip code, select the MBE and version and click on Test Endpoint. You will see that the API works and returns us the weather forecast.

Oracle Mobile Cloud Service: Create an API that calls a REST web service

In the lasts post about Oracle Mobile Cloud Platform I already told that you can connect to a external SOAP/REST web service, but you have to do it through a connector. We have also to keep in mind that with REST API or Android/iOS SDK you cannot call directly a connector, you have to call a custom API that will make the call to that connector so we will also have to make a implementation of out custom API using node.js.
You can download this example from my Github repository.

In this post I am going to show with a quick example  how easy is to create an API that makes a call to an external REST web service.

The steps we are going to do are:

  1. Create a Mobile Backend (MBE)
  2. Create a Connector
  3. Create, design and implement an API.

Create a Mobile Backend (MBE)

A Mobile Backend is the gateway through we will make any API (custom or platform) call, so the first step is to create one.
In the Developer Portal we have to make click on Mobile Backend and in the next page we have to click on “New Mobile backend” and fill the required fields like name and description.

Create a connector
A connector will let us to make a external webservice call from MCS, so in the Developer Portal we have to navigate to Connectors.
In connectors page we have to click on “New Connector”, as type we pick REST and then we fill the name and the web service url.

In this example I have picked a public rest weather API:

api.openweathermap.org/data/2.5/weather?q=Madrid

Once we have created the connector we can skip until the last step, “Test” and just click on “Test Connector” to test our connector.

As you can see the web services give us weather data of Madrid as we put ‘Madrid’ in the url parameter.

Now we have connected MCS with a external web service, but as you can imagine we should make our connector parameterized so we don’t have to create a connector per city.

we have to make a couple of things to get it working:

First we have to edit the connector url and remove “?q=Madrid” from it.

And we have also to add a rule to our connector. To do this we have to go to rules step in our connector and click on add new rule.
In this case we are going to add a new parameter that will be associated to all the calls that we will make to this connector.
It is possible to associate a rule to a specific resource or a certain HTTP methods.

Now we are going to test that our connector works with the parameter.
We have to navigate to ‘Test’ and fill the input next to ‘Local URI’ with ‘?q=Barcelona’.
If we don’t fill the input the connector would use the default value we set in the rule.

As you can see the call has been successfuly made and the connector gives us the weather of Barcelona.

Create, design and implement an API

In the last step we are going to create an API that will call the connector.
Inside our MBE we have to create a new API.

We have to fill the name of the API and click on ‘Create’

Now that we have created the API, we have to design it.
In order to call the API anonymously so we can avoid creating any users or roles we have to head to Security and select ‘Allow Anonymous User Access’.

The next thing we have to do is define the endpoint of our API.
Our endpoint is going to have a parameter that we will define as {ciudad}. We have also to define endpoint methods.

In this case we are going to create a GET method so we have to click on ‘Add method’ button and select ‘GET’. At this point we can define the diferent responses that we want and add mock data so our mobile application developer can start building the app. 

As we are not going to use any static data and we are going to make a call to the connector we are not going to add any response.

Now we click on ‘Save’ and then head to ‘Implementation’.
Here we can implement our API logic using node.js by downloading a JavaScript Scaffold.

The JavaScript Scaffold is a zip file that contains:
  • package.json: This is a config file where we can add the API dependencies.
  • tiempoporciudad.js: This is the javascript file where we will add the logic to our API. The name is the same as the API in MCS.
  • samples.txt:  This file contains some implementation examples.
To start the implementation we have to add the connector as a depencency to our API. So we have to edit package.json and add the connector URI and connector version.
After that we will edit the lavascript file tiempoporciudad.js.
The point here is to get the parameter (ciudad) of the request and execute a GET call to the connector passing the value we get as parameter. The last thing is to include the response of the connector’s call in the API response,

Once we have our API implemented we have to put both files inside the zip that we downloaded and upload it to MCS.

At this point we have created the Mobile backend, we have connected to a external web service using a connector and we have created an API associated to the Mobile backend that makes a call to the connector.

The last step is to test our API to see if everything works fine.
We have to head to our API and click on ‘Test’ button and fill the name of the city. We will use Barcelona again to test.

If we click on ‘Test Endpoint we can see that the API returns the weather of Barcelona.

Oracle Fusion Middleware Summer Camps 2015: Mobile Cloud Service

Last week I had the opportunity to attend to Oracle Fusion Middleware Summer Camps in Lisbon that Oracle organizes for EMEA partners. This year was the fifth edition and there were many new Oracle PaaS products to choose: Integration Cloud Service, Process Cloud Service, Java Cloud Service and the one I attended, Mobile Cloud Service. 

I have to say that it was the very first in class MCS training.

Oracle Mobile Cloud Service course was delivered by Frank NimphiusGrant Ronald (Oracle Product Management Team) and Jürgen Menge (Oracle Sales Consultant).

From the first minute we could start playing with MCS and also try the functionallity with a MAF application.

If you want to know MCS functionality you can check my previous post: Oracle Mobile Cloud Service overview.


Having such great trainers, we learnt some advices, good practices and tricks when using MCS. We saw a lot of interesting things, here comes some of them:

  • Notifications

MCS offers an API that allow us to abstract of the providers and fully manages notifications.
We can also send notifications to users in a specific role or platform, schedule notifications and monitor to see if notifications have been sent.

  • Cache and offline 

Thanks to the API we have a cache in the client that allow us to manage the synchronization with policies and also working in offline mode. We can get better performance, better usability, decrease network usage and increase battery life.

  • REST API y SDKs

With REST API and the SDKs we can call MCS Platform API and the custom API that we will create to integrate our applications with external systems. In future releases a JavaScript API will be available.

  • Analytics

Besides having metrics of all the API calls that our application make, we can also create our own events and funnels. We can use these, for example, in our mobile shopping application to know the step where users leave, evaluate the process and improve it.

 I would like to thanks Jürgen Kress for the great organization of the event and all the trainers for the outstanding tranning. See you next summer camp!!