Products Shop Support Company |

Intro to Remoting SDK for Delphi (6:06)

Download the Video | View on YouTube

This is a video about Remoting SDK.
Watch more Remoting SDK Videos. Read more about Remoting SDK.

Transcript

This video is an introduction to using Remoting SDK for Delphi.

Remoting SDK is a multi-platform library that allows you to create services you can expose over the network, where client applications can call them.

Let's start by creating a small server that exposes some sample functionality. We'll be using Delphi, but the same steps will work with C++ Builder, or you could build your server on .NET using Elements or Visual Studio.

We start in Delphi by clicking the "File" menu, then "New", "Other", selecting "Remoting SDK" and choosing the Code First Combo service. Click "OK". Let's go to Advanced Project Options and set some names. We'll call it "FizzBuzz", disable the client project option for now, and click "OK" twice, to create the project.

Let's have a look at the server data module. This has the components that implement the core connectivity. They do all the dirty work for us so we can focus on our business logic. Everything here is highly customizable, but for now the defaults will suffice.

In the LoginService, we can handle authentication of clients if we want our service to be private. For now we'll keep the dummy logic that just checks if user name and password are the same.

Finally, let's look at FizzBuzzService. This is the actual service we expose. Let's add a new methiod called Calculate that returns the fizzbuzz value for the given number. The ROServiceMethod attribute is enough to expose this method to the world.

And that's it!

Press F9 to start the server. You'll see that by default the server app starts in GUI mode. This is usually the best option for testing and debugging but because this was the Combo template, the same .exe could also be registered as a Windows service.

If we point our browser to localhost port 8099, we see our service is responsive. Clicking view RODL shows the metadata the server provides to describe its services.

Let's look behind the scenes a bit. We've defined our service in its methods and code. This is what we call a "Code First" server. When run, the server makes the coded functionality available to be called by default using HTTP and using a highly optimized binary message format we call BinMessage. Optionally you can also choose different transport protocols, which we call Channels, or different message formats. For example, you might want to expose the same service using SOAP for 3rd parties.

In addition to its functionality, the server also provides a description of the APIs it exposes in the form of the XML file we saw earlier. We call this the RODL, for remoting definition language. The RODL file describes what services and methods are available, what parameters they take, and so on. It's what makes it easy to auto generate clean APIs that you can use in the client application we're about to create.

We'll keep using Delphi for this example, but you can create clients in other languages and for other platforms that could talk to this same server.

Back in Delphi, right-click the project group and choose "Add New Project". This time, we pick a simple Console application but really this could be any kind of project even when you might already have!

Let's rename it to "FizzBuzzClient". First we'll connect our app to the server. In the main menu, go to "Tools | Remoting SDK and Data Abstract | Connect to Remoting SDK server". The default address already matches what we need for the local server, so we can continue and click "Connect". This will load the RODL service definition we saw before from the server, and generate three new files in the project.

The .remoteRODL file is a link to the remote server. It contains its URL, so you can easily regenerate the proxy files if the server API was changed just by right-clicking and choosing this menu option.

The ServerAccess file provides a rudimentary starting point for accessing the server. As you can see it has a couple of components that handle the connection to the server and exposes a bunch of useful properties. This file is for you to update or remove as you see fit.

Finally, the _Intf interface code file contains auto-generated proxy classes that represent the service and its types. We'll never touch this file ourselves. You can see our FizzbuzzService and the Calculate method are visible here.

For our example, let's go to the main project code file and add our code there. The code first gets a LoginService and calls the Login method: remember our dummy login just needs user name and password to match in order to be happy. Finally it gets a FizzbuzzService and in a for loop calls Calculate for various numbers, printing the result to the console.

Let's run the app... And it works!

Now this may seem like a trivial app, but remember under the hood it's talking over the network to the server for the actual logic without us having to worry about it too much.

Note that Remoting SDK servers and clients are compatible between the different platforms. We have more videos to show you how to create clients for .NET, Cocoa, or Java that can also talk to this same server.