Usually I get a few mails from you regarding how to integrate with different services or systems that are not “standard” in the way we use when we are used to integration using TIBCO BW. This is so common when you are trying to consume REST services, because the standarization process is not the same in the REST Services that you can find when you are trying to integrate with a SOAP Service.
When you are trying to integrate with a SOAP Service you will always have your WSDL and that’s everything you need and the people from TIBCO only have to provide a way to generate all the artifacts from this WSDL but that’s not he same scenario when you are talking about a REST Services.
In different previous post I talked a lot about REST services and how they are so non-standard despite of the attempts like WADL in the first ages and now Swagger that maybe is the most common approach nowadays. But the purpose of this post is not to talk about the problems when you are trying to use TIBCO BW to work with REST Service but to trying to integrate with a specific REST Service: Nexmo.
Nexmo is a platform for sending SMS and they provide you an REST API to consume their services. They have a lot of documentation and samples to show you how to integrate with their API but that information is focused on “traditional languages” like Python, Java and so on. But they don’t provide any WADL file or SWAGGER document to do a “smooth” integration from our BW development. So we have to do another approach. We have to do it using the “manual” way.
So, we are using the old fashioned HTTP Palette and the resources it provides us. And we are going to create only a SOAP Wrapper to the nexmo API. So we are going to create a Web Service that’s is going to ask for the number and the text and it’s going to send a SMS to that number. That’s everything.
I’m going to focus only in the part that is relevant to the integration with API. So, we are going to use a SendHTTPRequest, and here it is where we are going to define the interface, because we have to create the parameters the Nexmo API is asking for. If we read the documentation from Nexmo, we need to provide the following arguments inside a queryString invocation:
The frist two ones are the identifying values for the person who is registerd inside their plataform and they are two numbers that acts like “passwords”. The other ones are business values (from, the number of the sender of the SMS; to, the number which is the target of the SMS, and text the content of the message).
Ok, we define this parameters in the General tabo the SendHTTPRequest activity as you can see here:
And then we only have to provide the Endpoint of the target server. The endpoint in BW 6.X splits in trhee pieces:
- The first piece is the one that belongs to the host name of the server and port number. This piece is defined by a HTTP Client Resource.
- The second piece is the one that has the Request URI and starts after the first piece until the ? signal that identify the parameters.
- The third piece is the queryString that contains the parameters
So if we have the current HTTP URI from Nemxo describes like these:
So the green part is going to be defined using a HTTP Client Resource and the third one is the one that we already define in the parameters section of the SendHTTPRequest activity. So, the second piece is the one that we need to configure it, and we are going to do it inside the Input tab of the SendHTTPRequest acitvity along with the parameters mapping, as you can see here:
And that’s everything about the REST API configuration, so now we already defined the method as Nexmo server is expecting and we have all the data mapped from the input or properties to be sending inside the request.
But that it is not going to work because as you can see when we explain the complete URL, the nexmo URL is a secure HTTP connection, so we have to configure it the SSL conection to be capable of establish a connection with Nexmo servers. But to know how to do it, we have to wait to the next post!