Skip to Content

The other day I was playing with the idea of consuming Gateway from PowerBuilder…so of course, I tried a few things like reading it as a WebService or a Rest Service…none work as Gateway generated OData.

PB_GW_01.png

A couple of days ago I read this awesome blog by Mark Bradley called Gateway over PowerBuilder where he was using an OData Service DataWindow…which I didn’t found on my PowerBuilder IDE…I contact Mark and he told me he was using a “not released yet” version of PowerBuilder, so my new goal was to find a new way to connect PowerBuilder and Gateway using what I currently had…

I tried a lot of things more…including the WCF Data Services for OData which didn’t work at all…

But as part of my job is break my head trying to achieve the most crazy and cool ways of doing things…I decided to took another approach…

I remembered that ruby_odata is capable of consuming Gateway, as I was one of the one that contributed to that project Ruby, Camping and…Gateway? (Sorry…will fix the code as soon as I can…old post)

Then I learned that Sinatra the classy Ruby WebFramework was capable of exposing data as a Rest Service (You need to install also the JSON gem)…so all pieces we falling together…

I wrote a small Ruby/Sinatra script to read from Gateway (For this example, I made the service anonymous…just to type it too often)…BTW…I call it Sinatra_JSON.rb

PB_GW_02.png

After launching it, I could check it on my browser…

PB_GW_03.png

With that ready…I could move to PowerBuilder…create a Solution –> Target (Specify that you want a window to start) –> And then a RESTFUL Client.

PB_GW_04.png

PB_GW_05.png

PB_GW_06.png

PB_GW_07.png

After that, we need to Generate the Proxy…

PB_GW_08.png

And create a Grid DataWindow…

PB_GW_09.png

We need to define the columns that we’re going to retrieve and show in our window.

PB_GW_10.png

We create a DataWindow inside our Window (w_window) and a button. We’re going to drag & drop the Grid DataWindow into our DataWindow.

PB_GW_11.png

Double click the button and paste the following code…

PB_GW_12.png

Go to the application and double click on it, paste this code…

PB_GW_13.png

We’re ready to run our program, and press the “Call Flights” button…

PB_GW_14.png

It works! So as a little wrap up…we read the Gateway service using Ruby_OData and expose it as REST service using Sinatra. From PowerBuilder we create a REST client, consume the Sinatra REST service and render it on a Grid DataWindow…

Hope you like it…so far…I guess is the best way to make PowerBuilder and Gateway work until we can put our hands on the latest PowerBuilder release.

The only drawback of course, is that I need to pass the filters manually instead of passing them dynamically…well…next time maybe…

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Jelena Perfiljeva

    In all honesty I couldn’t understand about 60% of it, but nevertheless appreciate the effort and attention to detail that went into the blog. Also it made me google some of the terms used, so I learned something new. 🙂 Thanks!

    Was hoping for a Sinatra song though – bummer… 😳

    (0) 
    1. Alvaro Tejada Galindo Post author

      Jelena:

      Thanks a lot for your comment 🙂 It might be not that easy to follow at first but after doing it yourself one time you will do it without thinking 😉

      About the Sinatra song…I know LOL That’s why I carefully choose the title…to confuse people 😛

      Greetings,

      Blag.

      (0) 

Leave a Reply