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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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 / 11
    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...
       · Hi,You have not described the steps of adding WCF service to asp.net, how you will...
       · Great article and, refreshingly, in VB.Net too. Thank you very much.
     

    ASP.NET ARTICLES

    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...
    - Building an In-Text Advertising System Under...
    - Developing a Mini ASP.NET AJAX Server Centri...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    Stay green...Green IT