Building a rest webservice application€¦ · Building a RESTful Web Service Application...

12
1990 South Bundy Drive, Suite 350, Los Angeles, CA 90025 Tel +1 310.828.7335 Fax +1 310.496.3130 webalo.com Building a RESTful Web Service Application Introduction By utilizing Webalo’s easy to use RESTful Web Service connector you can build a wide array of applications based on a growing number of enterprise applications that offer a RESTful API and do so with minimal configuration effort. In today’s example, we will be building an application using a Yahoo API that performs a local search for restaurants. The web service has two input parameters, one for ZIP code and the type of restaurant you would like to search for. Feel free to build along with this tutorial. As of its writing the Yahoo API is available and working. RESTful URL’s Since the Webalo system accesses RESTful applications via a URL, it is important to understand the structure of those URLs and how we will be using them to build applications. Here is the URL for today’s example: https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20local.search%20where%2 0zip%3D'94085'%20and%20query%3D'pizza'&format=json&diagnostics=true There are two sections to the above URL, the Site URL and the Base URL. The Site URL can be thought of as the base connector to a RESTful web service and can have many applications (or services) built with it. The Site URL for our example is as follows: https://query.yahooapis.com/v1/public/ The Relative URL (or the service URL) for our example is the rest of the URL. Seen here: yql?q=select%20*%20from%20local.search%20where%20zip%3D' 94085'%20and%20query%3 D'pizza'&format=json&diagnostics=true There is a lot of info in the Relative URL that tells the system what the end user is expecting the result to look like and how the system should interact with this call. As Webalo admins, all we are concerned about are the ZIP code and the type of food sections. Seen in bold above. If you paste the above URL into a browser, you get a page back that looks like this:

Transcript of Building a rest webservice application€¦ · Building a RESTful Web Service Application...

Page 1: Building a rest webservice application€¦ · Building a RESTful Web Service Application Introduction By utilizing Webalo’s easy to use RESTful Web Service connector you can build

1990 South Bundy Drive, Suite 350, Los Angeles, CA 90025 Tel +1 310.828.7335 Fax +1 310.496.3130 webalo.com

Building a RESTful Web Service Application

Introduction

By utilizing Webalo’s easy to use RESTful Web Service connector you can build a wide array of applications based on a growing number of enterprise applications that offer a RESTful API and do so with minimal configuration effort. In today’s example, we will be building an application using a Yahoo API that performs a local search for restaurants. The web service has two input parameters, one for ZIP code and the type of restaurant you would like to search for.

Feel free to build along with this tutorial. As of its writing the Yahoo API is available and working.

RESTful URL’s

Since the Webalo system accesses RESTful applications via a URL, it is important to understand the structure of those URLs and how we will be using them to build applications. Here is the URL for today’s example:

https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20local.search%20where%20zip%3D'94085'%20and%20query%3D'pizza'&format=json&diagnostics=true

There are two sections to the above URL, the Site URL and the Base URL. The Site URL can be thought of as the base connector to a RESTful web service and can have many applications (or services) built with it. The Site URL for our example is as follows:

https://query.yahooapis.com/v1/public/

The Relative URL (or the service URL) for our example is the rest of the URL. Seen here:

yql?q=select%20*%20from%20local.search%20where%20zip%3D'94085'%20and%20query%3D'pizza'&format=json&diagnostics=true

There is a lot of info in the Relative URL that tells the system what the end user is expecting the result to look like and how the system should interact with this call.

As Webalo admins, all we are concerned about are the ZIP code and the type of

food sections. Seen in bold above.

If you paste the above URL into a browser, you get a page back that looks like this:

Page 2: Building a rest webservice application€¦ · Building a RESTful Web Service Application Introduction By utilizing Webalo’s easy to use RESTful Web Service connector you can build

1990 South Bundy Drive, Suite 350, Los Angeles, CA 90025 Tel +1 310.828.7335 Fax +1 310.496.3130 webalo.com

Since we are building an application that allows our end users to search on their own we will want them to provide the ZIP code and the type of food desired at runtime. To do this we will change the hardcoded values above with delimiters ($$) and labels. Seen here:

… search%20where%20zip%3D'$$ZIP$$'%20and%20query%3D'$$Food-Type$$'&diagnostics=true

Webalo recognizes the $$ and uses the text between them as labels. We’ll see this in a minute in our configuration.

Now that we have a basic understanding of RESTful URL’s and how we can provide inputs, lets build an app with the above RESTful web service.

Page 3: Building a rest webservice application€¦ · Building a RESTful Web Service Application Introduction By utilizing Webalo’s easy to use RESTful Web Service connector you can build

1990 South Bundy Drive, Suite 350, Los Angeles, CA 90025 Tel +1 310.828.7335 Fax +1 310.496.3130 webalo.com

Configuring RESTful Web Service Applications

Start by logging into your Webalo account and clicking Connecting to Your Applications and Data.

Page 4: Building a rest webservice application€¦ · Building a RESTful Web Service Application Introduction By utilizing Webalo’s easy to use RESTful Web Service connector you can build

1990 South Bundy Drive, Suite 350, Los Angeles, CA 90025 Tel +1 310.828.7335 Fax +1 310.496.3130 webalo.com

Then choose Web Services

Then choose RESTful Web Service

Page 5: Building a rest webservice application€¦ · Building a RESTful Web Service Application Introduction By utilizing Webalo’s easy to use RESTful Web Service connector you can build

1990 South Bundy Drive, Suite 350, Los Angeles, CA 90025 Tel +1 310.828.7335 Fax +1 310.496.3130 webalo.com

Configure REST Site

We’ll first have to configure the rest site connector. This will be the Base URL for our application. Since we are using the Yahoo API here, let’s go ahead and name the site accordingly and paste in the following Base URL:

https://query.yahooapis.com/v1/public/

This being an open API we do not need to worry about authentication at this time. It is worth pointing out the authentication we do support should you need it for your other RESTful apps, they are: OAuth, Basic, Digest, NTLM, Kerberos, Proficy and OAuth 2 with password.

Once you have the fields filled in, you can press Finish to continue on to configure the rest service.

With the REST Site Connection you just built highlighted, hit Next

Configure Rest Service

We will now build the service portion of the application that basically controls what the apps does.

Page 6: Building a rest webservice application€¦ · Building a RESTful Web Service Application Introduction By utilizing Webalo’s easy to use RESTful Web Service connector you can build

1990 South Bundy Drive, Suite 350, Los Angeles, CA 90025 Tel +1 310.828.7335 Fax +1 310.496.3130 webalo.com

I am going to name this app Local Food Search and then use the Relative URL as described above with the $$ and the labels for the input parameters. As seen here:

yql?q=select%20*%20from%20local.search%20where%20zip%3D'$$ZIP$$'%20and%20query%3D'$$Food-Type$$'&format=json&diagnostics=true

The HTTP method for this app is GET and the Parameter Delimiter is $$. Note that you can specify any character to be the delimiter should it turn out that the REST app you are building contains $$ for some other purpose.

Once complete:

Once you have the values entered, Press Next

Provide a ZIP and a Food-Type on the input parameters pop-up. As seen here:

Click OK.

Page 7: Building a rest webservice application€¦ · Building a RESTful Web Service Application Introduction By utilizing Webalo’s easy to use RESTful Web Service connector you can build

1990 South Bundy Drive, Suite 350, Los Angeles, CA 90025 Tel +1 310.828.7335 Fax +1 310.496.3130 webalo.com

Edit Sample Response

The system will run the service with the suppled parameters and present back to you a sample response. Seen here:

Click Next

Page 8: Building a rest webservice application€¦ · Building a RESTful Web Service Application Introduction By utilizing Webalo’s easy to use RESTful Web Service connector you can build

1990 South Bundy Drive, Suite 350, Los Angeles, CA 90025 Tel +1 310.828.7335 Fax +1 310.496.3130 webalo.com

Customize Input Form

If needed, this step allows you to customize how the end users enter their data. There are facilities to add a date picker, drop downs and other options. For this exercise, we’ll accept the default text fields and hot Next.

Customize Output Form

On this step, you will customize how you want the app to appear to your end users. RESTful web services will oftentimes return more data than is necessary for a typical end user. In this example, we are given javascript info and diagnostics info and while both useful to some, they are not necessary for our app. Here is the collapse view of our output screen:

Page 9: Building a rest webservice application€¦ · Building a RESTful Web Service Application Introduction By utilizing Webalo’s easy to use RESTful Web Service connector you can build

1990 South Bundy Drive, Suite 350, Los Angeles, CA 90025 Tel +1 310.828.7335 Fax +1 310.496.3130 webalo.com

Scroll to the top of the outputs screen and highlight Diagnostics and then click the Hide button on the lower section of the screen. Your outputs should now look like this:

We’ve hidden all the outputs in the Diagnostics section of our result set. Repeat that process for Count, Created and Language (you may have to expand and hide sections to see all the outputs). Seen here:

The only output that shouldn’t been hidden is Results. Click Finish.

Assign the app to yourself or all users in your domain and deploy your changes.

Page 10: Building a rest webservice application€¦ · Building a RESTful Web Service Application Introduction By utilizing Webalo’s easy to use RESTful Web Service connector you can build

1990 South Bundy Drive, Suite 350, Los Angeles, CA 90025 Tel +1 310.828.7335 Fax +1 310.496.3130 webalo.com

Running the app on your mobile device

If you open Webalo and perform a refresh, you will see the app on the top of the home screen. Here it is on a split screen iPad client:

Tapping it will open the task and you will be presented with the input fields. I’ll search a local zip code for sushi:

Page 11: Building a rest webservice application€¦ · Building a RESTful Web Service Application Introduction By utilizing Webalo’s easy to use RESTful Web Service connector you can build

1990 South Bundy Drive, Suite 350, Los Angeles, CA 90025 Tel +1 310.828.7335 Fax +1 310.496.3130 webalo.com

Pressing submit will initiate the web service and a result screen will be shown to us. Seen below.

Page 12: Building a rest webservice application€¦ · Building a RESTful Web Service Application Introduction By utilizing Webalo’s easy to use RESTful Web Service connector you can build

1990 South Bundy Drive, Suite 350, Los Angeles, CA 90025 Tel +1 310.828.7335 Fax +1 310.496.3130 webalo.com

Results:

Feel free to search your local zip code for any popular food type.