ASP.NET
  Home arrow ASP.NET arrow Page 4 - Developing Business Logic using the WCF Se...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Developing Business Logic using the WCF Service Library with VS2K8 and ASP.NET 3.5
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 10
    2007-10-03

    Table of Contents:
  • Developing Business Logic using the WCF Service Library with VS2K8 and ASP.NET 3.5
  • Understanding the WCF Service Library: Employee class
  • Understanding the WCF Service Library: the app.config file
  • Understanding the WCF Service host
  • Understanding the WCF Client: ASP.NET 3.5 web site

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Developing Business Logic using the WCF Service Library with VS2K8 and ASP.NET 3.5 - Understanding the WCF Service host


    (Page 4 of 5 )

    Every WCF Service must be hosted. There are several ways of hosting (depending on the requirements) a WCF Service. In this article we focused on hosting a WCF Service using a custom application.

    The custom application (or a simple service host utility) manages the service. The main two operations for any service to manage are "start" and "stop." A separate Windows forms application (NorthwindBLLServiceHost) is developed specifically for this purpose.

    The application simply contains a form with two buttons (for "start" and "stop") and finally a label to show the status of the service. The following is the source code for both "Start" and "Stop" buttons:

    Imports System

      Imports System.ServiceModel

      Public Class Form1

      Dim hostEmpService As ServiceHost

    Private Sub btnStartNorthwindEmpService_Click(ByVal sender As
    System.Object, ByVal e As System.EventArgs) Handles
    btnStartNorthwindEmpService.Click

      hostEmpService = New ServiceHost(GetType
    (NorthwindBLLService.EmpService))

      hostEmpService.Open()

     Me.lblEmpServiceStatus.Text = "Service Started Successfully"

    End Sub

    Private Sub btnStopNorthwindEmpService_Click(ByVal sender As
    System.Object, ByVal e As System.EventArgs) Handles
    btnStopNorthwindEmpService.Click

      hostEmpService.Close()

      Me.lblEmpServiceStatus.Text = "Stopped"

    End Sub

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As
    System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

      Try

       If hostEmpService.State = CommunicationState.Opened Then

        hostEmpService.Close()

       End If

      Catch ex As Exception

     End Try

    End Sub

    End Class

    Once the application is executed and you have hit the "Start" button, it should start the service as follows:

     

    Always start the service before working with any application which tries to access the service.

    More ASP.NET Articles
    More By Jagadish Chaterjee


       · Hello guys,This is my third article in the series focusing on WCF development...
       · Do you differentiate at all between the service layer and the business layer. isnt...
       · Simply don't want to complicate the things at this moment. You will see several...
     

    ASP.NET ARTICLES

    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT