ASP.NET
  Home arrow ASP.NET arrow Page 5 - Developing a WCF Service Library and Hosti...
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 a WCF Service Library and Hosting it as WCF Web Service Using VS2K8
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 11
    2007-10-01

    Table of Contents:
  • Developing a WCF Service Library and Hosting it as WCF Web Service Using VS2K8
  • Creating a Windows Communication Foundation (WCF) Service Library
  • Creating a Windows Communication Foundation (WCF) Service Library: application configuration
  • Deploying and Hosting a WCF Service application (WCF web service)
  • Testing the WCF Web Service: creating the WCF Client using Windows Forms

  • 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 a WCF Service Library and Hosting it as WCF Web Service Using VS2K8 - Testing the WCF Web Service: creating the WCF Client using Windows Forms


    (Page 5 of 5 )

    To test the WCF web service created in previous sections, we need to develop a WCF client. In this case, for simplicity, I would like to work with Windows Forms.

    Open a new Visual Studio environment, create a new project, select "Windows Forms Application" as the template, provide the name "WCFSampleClient" and hit OK (fig 13). 

    Figure 13

    Design a form which looks like the following (fig 14):

    Figure 14

    Add a reference to WCF Service by right clicking on project and selecting "Add Service Reference" (fig 15). 
     

    Figure 15

    Provide the previously created WCF Web Service URL as http://iisservername/WCFSampleService/EmpService.svc?wsdl and click "Go." Once it is found, designate the namespace as "EmpService" and hit OK (fig 16). 

    Figure 16

    Testing the WCF Web Service: source code 

    For the Windows form previously created, make modifications to the existing code so it matches with the following:

    Imports System.ServiceModel

    Public Class Form1

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click

    Dim proxy As New EmpService.EmpServiceClient("WSHttpBinding_IEmpService")

    Dim objEmp As EmpService.Employee = proxy.GetEmployeeInfo(Me.txtEmpno.Text)

    proxy.Close()

    With objEmp

    Me.txtEname.Text = .Ename

    Me.txtSal.Text = .Sal

    Me.txtDeptno.Text = .Deptno

    End With

    End Sub

    Private Sub btnGetAllNames_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetAllNames.Click

    Dim proxy As New EmpService.EmpServiceClient("WSHttpBinding_IEmpService")

    Me.lstNames.DataSource = proxy.GetNames

    proxy.Close()

    End Sub

    End Class

    Finally, hit F5 to execute and test the application (which accesses and retrieves information from the WCF web service hosted earlier). If everything works fine, you should be able see the output as follows (fig 17):  

    Figure 17

    I hope you enjoyed the article and any suggestions, bugs, errors, enhancements etc. are highly appreciated at http://jagchat.spaces.live.com


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hello guys,This is my first part for the series of articles on WCF. This...
       · Hello,I created a WCF service in VS2008 and when I try to browse the service in...
       · Great article! I just start doing this and learned quite a lot. I have one...
     

    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 2 hosted by Hostway
    Stay green...Green IT