«

»

Oct
12

Creating & Using a PowerBuilder 12.5 WCF Service


Learning To Create a WCF Web Service using PowerBuilder 12.5 .NET

This is a completion of a prior article where I talked about my first experience using PB12.NET to create a WCF Web Service.  The WCF Service accesses a Microsoft SQL Server 2008 database and is used to provide data to a web application that I wrote in ASP.NET MVC3.    If you want to get a background on my process and take a look at the web service in action then go back to my Creating a WCF Service using PowerBuilder 12.5 first.

Goals for the new WCF Service

  1. Learn how to create a WCF Service in PB 12.5
  2. Connect to and provide data from a SQL Server 2008 database.
  3. Use the Web Service in a simple ASP.NET MVC3 Web Application

Of course part of my motivation was learning… I did had an idea in mind what I wanted my web service to do.  I have been creating Web Applications in Visual Studio 2010, and there were times that I wished I had the datastore and easy database manipulation I was used to with PB.  I wasn’t sure if I’d be able to use the datastore and different data objects in a WCF web service without needing to deploy lots of PB run-times or other things like EA Server.

To my surprise, creating the Web Service was very easy.  The code inside my non-visual user object was simple as I have been working with datastore’s for years and using them comes second nature to me.  The only real difference between creating a basic non-visual in a PB application, or using one for a Web Service, are that you have to make a lot of settings on the project object that you were not used to seeing and you need to know the basics about WCF Services.    You need to think about which functions you want to be “exposed” inside the .NET application.  Then you need to understand which data types you can use without problem and how the various data types map between PB and .NET.

Step by Step Creation of the PowerBuilder WCF Service

I promised a step-by-step and was reluctant to post so many screen prints, but my goal was a “complete” reference for how to create a working Web Service.  With that said we’ll start by opening PowerBuilder 12.5 .NET

Start by File–> New   and choose Solution and click Finish.  You will have a chance to name your Solution in the next step.

PowerBuilder Workspace Creation

1. PowerBuilder Workspace Creation

The second step is naming your PowerBuilder Solution.

PowerBuilder 12.5 Solution Creation

2. PowerBuilder 12.5 Solution Name

After clicking save, click on Start –> New again.  Choose WCF Service from the Target tree view item.

PowerBuilder 12.5 WCF Service Target Creation

PowerBuilder 12.5 WCF Service Target Creation

 

Next you choose whether you want to create a new WCF Service target or create one from an existing Classic .NET Web Service Target.  I chose to create a brand new WCF Service.  Then choose next…

PowerBuilder 12.5 WCF Service Target Type

PowerBuilder 12.5 WCF Service Target Type

 

There are a lot of dialog windows in the process of creating a new WCF Service, this one is where you name the project and the PBL’s associated with it.  You also name the target file itself, I left the defaults which were populated using my Project Name selections.

PowerBuilder 12.5 Name WCF Service Target

PowerBuilder 12.5 Name WCF Service Target

 

Choosing the Library search path was another “default”.  Since I was creating a new WCF Service and didn’t have any existing PBL’s to utilize in the process I left the default which was the PBL name of my project.   Again I clicked Next…

PowerBuilder 12.5 Choose WCF Service Target Libraries

PowerBuilder 12.5 Choose WCF Service Target Libraries

 

There are a lot of questions along the way where you could just take the default. Here is where you choose what name you want to use for the actual assembly file name.   If you wanted to consume it in a .NET application you’d go and find this assembly and add it as a reference to your .NET project.  I chose a cool name here and ended up changing it later, choose anything you like here.  As much as I wanted to hit Finish by now I clicked Next again…

PowerBuilder 12.5 Choose WCF Service Assembly Name

PowerBuilder 12.5 Choose WCF Service Assembly Name

 

This one wasn’t as clear to me, but I left the default of (None) and clicked next.

PowerBuilder 12.5 Choose New Object

PowerBuilder 12.5 Choose New Initial Object

Next I took the defaults on several dialog windows of the wizard for creating WCF Service in PowerBuilder.

PowerBuilder 12.5 WCF Service Wizard

PowerBuilder 12.5 WCF Service Wizard

I didn’t add any Win32 dynamic library files…

PowerBuilder 12.5 WCF Service Wizard

PowerBuilder 12.5 WCF Service Wizard

This option I chose to create a console (Self Hosted) application rather than an IIS Service.  I based this decision on reading the dialog and believing that setting up the IIS hosted service would be more difficult.  The goal of this excise was to get one working.

Next time we’ll use the IIS option.

 

PowerBuilder 12.5 WCF Service Hosting Option

PowerBuilder 12.5 WCF Service Hosting Option

Here I set the base address to my machine name and left the port to 8001, the port that PB had chosen for me.

PowerBuilder 12.5 WCF Service Hosting Option

PowerBuilder 12.5 WCF Service Console Info

 

Please continue with the Step by Step creation of a PowerBuilder WCF Service Page 2 

 

 p.s. Before you go…  would you please, please, please click the Google +1 icon at the top of the page if you like the article?   It is an important measurement tool that Google uses to determine what is real content and what is spam.   This article took a lot of time to create.  I am easy to please just a simple pat on the back with a Google +1 keeps me going. :-)

 

No comment yet

3 pings

  1. - The Displaced Guy says:

    [...] Creating & Using a PowerBuilder 12.5 .NET WCF Service. – This step-by-step article contains over three dozen print screens and is a very detailed step by step process that I used when creating my first WCF Service.  This is intended for PB developers who have not yet created a WCF Service. [...]

  2. - The Displaced Guy says:

    [...] Back to Page 1 of the article [...]

  3. - The Displaced Guy says:

    [...] For more details continue on to the Step by Step process of creating the Web Service in PowerBuilder 12.5 .NET [...]

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>