PowerBuilder 12.5.NET WCF Web Service – Consumed by ASP.NET MVC4 Application

Page 3

Back to Page 2 of the article

Steps Completed

PowerBuilder 12.5.NET WCF Web Service Application

Steps Remaining

Visual Studio 2012 ASP.NET MVC4 Application that consumes the PowerBuilder 12.5.NET WCF Service

Create the ASP.NET MVC4 Application

In Visual Studio 2012 create new application.
Then choose Internet Application
Add the PowerBuilder WCF Web Service Reference to the .NET application project by “create a Web Reference”
To create it you right click on the project in the Solution Explorer, and choose Add–>  Service Reference –> Then click the Advanced Button… –>  Then click the Add Web Reference… button –> then type the address of your Web Service (as you did in the SVCUTIL.EXE step) into the URL box.    Upon entering the URL  (http://matrix:8001/n_datafactory?wsdl) click the green arrow and Visual Studio will discover your Web Services and display them.  At this point you simply click the “Add Reference” button and your Web Reference will be added.
You need to take the endpoint information from the output.config file you created from the SVCUTIL step and copy it into the main Web.config file.   If you forget to do this you’ll get errors related to the endpoint being invalid or missing for the service.   This was probably the most challenging technical hurdle and it wasn’t really that tough.
Here is my main Web.Config the System.ServiceModel section is the area you need to set the endpoint
The next steps of the Visual Studio Program are too numerous too list separately.  I will list some of the notable items.
Category Controller, Index Method
Notice, that we are using a WebService class to assist with the calling of Web Services, and we are calling the GetCategoriesAll from our PowerBuilder WCF Service Application

Web Service Class – Generic Wrapper for Calling WCF Web Services in ASP.NET MVC Applications

using System;
using System.ServiceModel;
namespace LinkDBMvc.Controllers
{
 public class WebService<T>
 {
 public static void Use(Action<T> action)
 {
 ChannelFactory<T> factory = new ChannelFactory<T>("*");
 T client = factory.CreateChannel();
bool success = false;
 try
 {
 action(client);
 ((IClientChannel)client).Close();
 factory.Close();
 success = true;
 }
 catch (EndpointNotFoundException e)
 {
 LinkDBMvc.AppViewPage.apperror.LogError("WebService", e, "Check that the Web Service is running");
}
 catch (CommunicationException e)
 {
 LinkDBMvc.AppViewPage.apperror.LogError("WebService", e, "Check that the Web Service is running");
 }
 catch (TimeoutException e)
 {
 LinkDBMvc.AppViewPage.apperror.LogError("WebService", e, "Check that the Web Service is running");
 }
 catch (Exception e)
 {
 LinkDBMvc.AppViewPage.apperror.LogError("WebService", e, "Check that the Web Service is running");
 }
 finally
 {
 if (!success)
 {
 // abort the channel
 ((IClientChannel)client).Abort();
 factory.Abort();
 }
 }
 }
 }
}

The Main Page

 

x

 

 

 

 

 

 

 

 

 

The Category List using the PowerBuilder 12.5 WCF Web Service

 

 

 

 

 

 

 

 

 

 

 

 

Create a new Category via PB WCF Web Service in ASP.NET MVC4 Application

 

 

 

 

 

 

 

 

 

 

 

 

 

The inserted Category

 

 

 

 

 

 

 

 

 

 

Category Edit Functionality

 

 

 

 

 

 

 

 

 

 

 

 

 

Category Edit after Update

 

 

 

Category Delete

 

 

 

 

 

 

 

 

 

 

 

 

 

Source Code Downloads

PB125 WCF Service – PowerBuilder 12.5.NET Solution Source Code

LinkDBMvc – Visual Studio 2012 Express ASP.NET MVC4 Solution Source Code

CategoryTable – DDL to create lm_r_category table in SQL Server 2008 Database

Steps to create the ASPNET Membership Tables if you don’t already have them in your database.

  1. Run C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regsql.exe.
  2. Hit Next.
  3. Select “Configure SQL Server for application services…” and hit Next.
  4. Select “Windows Authentication” and the “XXXX” Database and hit Next.
  5. Your settings are then presented…then hit Next.
  6. Finally you should be presented with a done screen, hit Finish.

 

 

Tags:

2 Responses

  1. Hi, i feel that i noticed you visited my blog thus i got here to go back
    the want?.I’m trying to find issues to improve my site!I suppose its
    adequate to use a few of your ideas!!

Leave a Reply to Creating & Using a PowerBuilder 12.5 WCF Service – Page 2 of 3 » The Displaced Guy Cancel reply

Your email address will not be published. Required fields are marked *