You are on page 1of 10

PowerBuilder and the Cloud

It was great to see so many former colleagues and customers at SAP TechEd and Sybase TechWave a little over a week ago in Las Vegas. Thanks especially to those that sat in on my two ‘cloudy’ PowerBuilder talks; I hope they were informative and gave you some ideas about how various features of the Windows Azure cloud can be relevant to your PowerBuilder applications, even those you may have built years ago. My slides and demos are available – where else – in the cloud at: http://jimoneil.blob.core.windows.net/presentations/2011/TechWave2011.zip. This post provides a quick overview of each of the demos, in case you’d like to try to run them on your own using the code in the download. You’ll be able to run some of the samples out-of-the-box, but if you really want to kick the tires of Windows Azure, I recommend downloading the Windows Azure Tools for Visual Studio 2010 and getting your free trial account. Then you can run my samples as well as experiment with your own code. Let me know what great applications you come up with, and if you run into issues with getting my samples to run, I’d be happy to help.

PowerBuilder Connection to Windows Azure
There’s wasn’t really any code to this, I just demonstrated how to create a database on SQL Azure and then connect to it via the PowerBuilder Database painter. We used the pipeline to create the EAS Demo DB Customer table in SQL Azure and then view the data in the painter via the ODBC driver. It’s really that easy to connect, since SQL Azure uses the same native Tabular Data Stream (TDS) protocol that SQL Server does. The trickiest part is specifying the correct server name (which ends in database.windows.net) and the user name, which must be in the format user@server; you can always get the ODBC connection string (see below) from the Windows Azure portal via the View Connection String… button in the Properties pane for the selected database. Note: you will not be able to connect to the database noted below since the firewall rules are not set up to support it, and I’ve not given you my password! If you provision a Windows Azure trial account though, it will take you only minutes to get to this point.

client-server setups. I built a simple PowerBuilder 12. you will get an error that the catalog tables cannot be created. A number of the containers in this account are marked for public access. Keep that in mind if you design desktop applications to access SQL Azure. and be sure to code defensively! PowerBuilder and Windows Azure Blob Data In this sample (PB_and_BlobStorage). and this is currently an unsupported database as far as PowerBuilder is concerned. If you try the SQL Native Client driver (SNC). this occurs because one or more of them do not include a clustered index. . so it’s very easy to use the GetUrl method in PowerBuilder (which has been around since PowerBuilder 5!) to retrieve the data and populate a DataWindow (I used an XML import template here). The tables can be created via the standalone scripts available with the PowerBuilder installation after you update them to specify a clustered index on each table. and that construct is not supported in SQL Azure. you’ll get an error in the Database painter because the driver makes use of cross-database references to tempdb to populate the table list (and likely other metadata). that seems to work. One last thing to keep in mind is that if you connect from a PowerBuilder Windows application to a SQL Azure database. which is a requirement of all tables in SQL Azure. I haven’t tested all data types thoroughly.5 Classic application to access my Windows Azure blob storage account. Note.Upon connecting in the Database painter. If you build your DataWindows with the ODBC driver and execute them with the native driver. you’re making a trip to one of the six data centers across the earth (you pick which one when you create the server). Latency and timeouts are therefore more likely to be an issue than with your on-premises.

asmx type. The service code in pokerhand. Create an MSI for the PowerBuilder Web Service (an option in the PowerBuilder project painter). which are ok for demos but not really viable for a production system: 1. The client code in fauxphoneclient. and you’ll see a list of PowerPoint and other files that I’ve hosted for distribution via Windows Azure.pbl uses the SOAP client capability of PowerBuilder to invoke that Web Service hosted in Windows Azure.5). .pbl was deployed as a .Try changing the directory to “presentations” in the window above.5 Classic to access a PowerBuilder Web Service that was deployed to Windows Azure. so there’s a bit of manual intervention needed to get the service running in the cloud. Unfortunately. PowerBuilder Web Service Deployed to Windows Azure In this demo (PB_WebService) I faked out a Windows Phone 7 interface with PowerBuilder 12.NET Web Service (the older .NET version of PowerBuilder 12. not a WCF service in the case – though that would be possible in the . The approach I used involved the following steps. at this point PowerBuilder doesn’t have a strong deployment story for Windows Azure.

3. Note. if you have problems let me know. When that service is invoked (via a separate ASP. 5. so you can certainly run the application as is. you’ll need your own Windows Azure account to perform them.net/ in Windows Azure). a new window pops up on the client machine displaying the message within a window of the desired background color. PowerBuilder and the Service Bus This demo (PB_ServiceBus).NET application running at http://alertjim. will not be present by default in the cloud. If you just can’t wait for native support in PowerBuilder and would like further details about about a more production-ready approach to setting up a PowerBuilder Web Service in the cloud (using the Windows Azure VM role). The demo code and service should be operational. Generate an MSI using the PowerBuilder Runtime Packager to collect the required PowerBuilder runtime files.cloudapp. If you are interested in following the steps I mentioned above. 4. This is currently required since the Web Service MSI installer cannot be run in silent mode. please contact me and I can elaborate. is where all audience control was lost! The scenario here involves a PowerBuilder 12. which also pushes the two MSI files to a Virtual Machine in the cloud.2. of course. the project is merely the vehicle to move your PowerBuilder files to Windows Azure. as I expected. Note that with a few tweaks to the PowerBuilder MSI installers – primarily the support of silent installation – the deployment can be completely automatic as well as resilient in the event of VM reboots or fail-overs in Windows Azure (which is not the case using the mechanism above). which. Deploy the Web Role project from Visual Studio. . you don’t need to write a lick of C# code.5 NET application that hosts a small WCF service (implemented by n_AlertService) with a simple interface to accept a color value and a message. Incorporate the two MSI files as content files in a Visual Studio 2010 Web Role project (see the vs directory for this demo). Remote Desktop to the Web Role in the cloud and run the two MSI installers interactively.

behind your ISP’s firewalls.That may sound underwhelming..servicebus. you’ll see the code to host the service with an endpoint URI constructed as follows: endpointUri[1] = ServiceBusEnvironment.AutoDetect . if you run the PowerBuilder application on your home network behind your firewall.net/AlertService.net/.SystemConnectivity. behind the cb_listen button on w_window. he can send a message directly to your machine! If you look at the PowerBuilder code. etc.windows. "techwave". "AlertService") That translates to a URL of sb://techwave.Mode = ConnectivityMode.CreateServiceUri("sb". e As EventArgs) Handles Button1.cloudapp. but the key here is that the service can be invoked from anywhere even though the machine hosting the service is behind a firewall and not otherwise publically accessible! For instance. and then text your buddy across the country to visit the public site http://alertjim.Click 2: 3: ServiceBusEnvironment. which is the same endpoint that the Visual Studio web application talks to as a client with the following code (note especially Line 4): 1: Protected Sub Button1_Click(sender As Object.

4: Dim serviceUri = ServiceBusEnvironment.Behaviors. you’ll be greeted with the following dialog.Credentials.Close() 21: 22: End Sub That endpoint is simply a namespace hosted in the Windows Azure cloud and created declaratively using the Windows Azure Portal – yes it’s that easy! Note that only one application can establish the endpoint listener at a time.SharedSecret. txtMessage.CreateServiceUri("sb". so if someone else happens to be running the PowerBuilder example at exactly the same time you try.IssuerName = "owner" 8: sharedSecretServiceBusCredential.AlertJim(ddlbColors.CreateChannel() 15: channel. "techwave".IssuerSecret = "REDACTED" 9: 10: Dim cf = New ChannelFactory(Of IAlertChannel)(New NetTcpRelayBinding().SelectedValue. Accommodating this scenario isn’t hard.Open() 16: 17: channel.Text) 18: 19: channel.Add(sharedSecretServiceBusCredential) 12: 13: Dim channel As IAlertChannel 14: channel = cf.Close() 20: cf.SharedSecret. but it will require that you set up a Service Bus endpoint in your own account to experiment further. . New EndpointAddress(serviceUri)) 11: cf.SharedSecret 7: sharedSecretServiceBusCredential.CredentialType = TransportClientCredentialType.Endpoint.Credentials. "AlertService") 5: Dim sharedSecretServiceBusCredential = New TransportClientEndpointBehavior() 6: sharedSecretServiceBusCredential.

NET. http://odata. The specific service I used is publically available from Netflix. it’s *just* HTTP and XML (or JSON). SAP Netweaver Gateway. Yakov Werde.netflix. Although PowerBuilder itself does not yet have explicit OData support (that was cited as a proposed feature for PowerBuilder 15). so I’ll refer you to that for the mechanics.PowerBuilder and RESTful data My PowerBuilder and RESTful data application (PB_Netflix) focused on using the new functionality to create a REST client in PowerBuilder 12. and a number of free and subscription data services at the Windows Azure DataMarket. OData. so there are no real technical barriers.com/ PowerBuilder and OData While Netflix is an OData source. . in fact. My good friend and PowerBuilder guru. the mechanism I used for the prior demo didn’t really exploit on the fact it is. OData itself is a huge gateway to amazing number of data providers including SharePoint 2010. has written some excellent articles on how to exercise this functionality.5 .

One way to incorporate an OData source today in your PowerBuilder . Add the assembly generated from Visual Studio as a reference to your PowerBuilder 12. I’ve done just that with a demo (PB_DataMarket) that leverages crime statistics from Data.NET proxy classes. Note to run the sample.5. http://odata. Access the data returned via the . functionality for the REST endpoint (e.NET application: • • • • • Create a .NET class you created in the second step above. subscribe to the data set. Add methods to this class library to perform the desired queries on the underlying data source. NET application.com/v2/Catalog).netflix.g. and modify the code behind the command button to refer to your Live ID and account key that is assigned when you subscribe to the DataMarket. and invoke the desired query method.. you’ll have to get your own (free) account on the Windows Azure DataMarket. Instantiate the . .gov.NET Class Library and generate a proxy class using the Add Service Reference..

16: context. key).Net.DataMarket. 17: } 18: 19: public List<VSProxy.DataMarket.CityCrime crimeRecord int i . 11: 12: public CrimeData(String uid.Year == 2008)).CityCrime.Collections.Generic.CrimeData crimeProxy crimeProxy = create VSProxy.datagovCrimesContainer( 15: new Uri("https://api.List <VSProxy.ashx/data. When PowerBuilder .oneil@live.com". 23: ToList<VSProxy. 1: using System. 2: using System.The code in the Visual Studio project is pretty straightforward.datamarket. you should be able to write the code below directly in PowerScript (at the moment.DataMarket.CityCrime> CrimeByState(String state) 20: { 21: return context.CityCrime>(). 24: } 25: } 26: } The PowerBuilder code to populate the WPF graph DataWindow looks like this (after pulling in a reference to the . I’m finding PowerBuilder crashes whenever I try to write this analogous code directly in the IDE).azure.NET supports extension methods.CrimeByState(ddlb_state.com/Data. & "REDACTED") System. 5: 6: namespace VSProxy 7: { 8: public class CrimeData 9: { 10: private DataMarket. Note how Line 6 invokes the method defined at Line 19 in the C# script above: 1: 2: 3: 4: 5: 6: 7: 8: 9: VSProxy. and of course.Credentials = new NetworkCredential(uid.DataMarket.Generic.Collections.CrimeData("jim.Linq. 22: Where(s => (s.NET assembly created by the Visual Studio project). String key) 13: { 14: context = new DataMarket.Text) VSProxy. you can add additional query functionality and parameters.CityCrime> crimeList crimeList = crimeProxy.gov/Crimes")).State == state) && (s.datagovCrimesContainer context. 4: using System. 3: using System.

City) dw_crime. crimeRecord.2op7ma2J.Population) next dw_crime. I have to say this one excites me the most.dpuf . but it would be a great open-source project to contribute back to the PowerBuilder and OData community! There are similar libraries already out there for Python.SetItem(rowNum. "population".Population) dw_crime. If you try some of these demos out.ViolentCrime * 1000) / crimeList[i]. & Double(crimeRecord. there isn’t a convenient wrapper class to handle all of the HTTP calls necessary. None are of production quality at this point.msdn.NET proxy assembly with a COM Callable Wrapper (CCW).SetItem(rowNum. crimeList. let me know what you think. Alternatively.Visible = True Of all the technologies I covered during my two talks. .Reset() // only show first 10 records (pagination left to the reader :) for i = 1 to Min(10. "violentcrime". Ruby.SetItem(rowNum. crimeRecord. so it can be consumed ‘natively’ in PowerBuilder Classic as well. Objective C and other languages.Count) crimeRecord = crimeList[i] rowNum = dw_crime.com/b/jimoneil/archive/2011/09/26/techwave-2011powerbuilder-and-the-cloud.SetItem(rowNum.InsertRow(0) dw_crime. but hopefully they’ll get you started exploring what PowerBuilder and Windows Azure can accomplish together.See more at: http://blogs. "city".ViolentCrime) dw_crime.aspx#sthash. it should be possible to access this same . so it would be a bit of work to pull it off. and you can use a similar process for pulling any of that data in and mashing it up with your own data to offer some incredible new functionality and value in your applications. There are a host of free services in the DataMarket.10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: int rowNum dw_crime. If you are still using PowerBuilder Classic. OData is really just HTTP and Atom/JSON. crimeRecord. "rate". Unfortunately.