ASP.NET
  Home arrow ASP.NET arrow Page 2 - 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  
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 a WCF Service Library and Hosting it with a Custom App Using VS2K8
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 7
    2007-10-02

    Table of Contents:
  • Developing a WCF Service Library and Hosting it with a Custom App Using VS2K8
  • Creating a WCF Service Library
  • Creating a WCF Service Library: source code
  • Build the project
  • Testing the WCF custom hosted Service: source code

  • 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 with a Custom App Using VS2K8 - Creating a WCF Service Library


    (Page 2 of 5 )

    The following are the steps required to create a WCF Service Library:

    • Open Microsoft Visual Studio 2008 Beta 2

    • Go to File || New Project

    • In the "New Project" dialog box, open "Visual Basic" project types and select WCF. The respective templates for WCF will be shown on the right side.

    • Select the "WCF Service Library" template.

    • Provide  "WCFSampleService" as the name and provide the proper path as the location.

    • Make sure that ".NET Framework 3.5" is selected at the top.

    • Once everything looks like the following (fig 01), click OK.

    • Rename "IService1.vb" to "IProductService.vb."

    • Rename "Service1.vb" to "ProductService.vb."

    Creating a WCF Service Library: application configuration

    As we created a WCF Service Library (instead of a WCF Service Application), Visual Studio adds an "app.config" file (as opposed to a "web.config" file in a WCF Service Application) to the solution. Modify the "app.config" file to match the following:

    <system.serviceModel>

    <services>

    <service name="NorthwindService.ProductService"
    behaviorConfiguration="NorthwindService.ProductServiceBehavior">

    <host>

    <baseAddresses>

    <add baseAddress="http://localhost:8181/ProductService" />

    </baseAddresses>

    </host>

    <!-- Service Endpoints -->

    <!-- Unless fully qualified, address is relative to base address supplied
    above
    -->

    <endpoint address="" binding="wsHttpBinding"
    contract="NorthwindService.IProductService" />

    <!-- Metadata Endpoints -->

    <!-- The Metadata Exchange endpoint is used by the service to describe
    itself to clients.
    -->

    <!-- This endpoint does not use a secure binding and should be secured or
    removed before deployment
    -->

    <endpoint address="mex" binding="mexHttpBinding"
    contract="IMetadataExchange" />

    </service>

    </services>

    <behaviors>

    <serviceBehaviors>

    <behavior name="NorthwindService.ProductServiceBehavior">

    <!-- To avoid disclosing metadata information, set the value below to
    false and remove the metadata endpoint above before deployment
    -->

    <serviceMetadata httpGetEnabled="True"/>

    <!-- To receive exception details in faults for debugging purposes, set
    the value below to true. Set to false before deployment 
    to avoid
    disclosing exception information
    -->

    <serviceDebug includeExceptionDetailInFaults="True" />

    </behavior>

    </serviceBehaviors>

    </behaviors>

    </system.serviceModel>

    Now it is time to specify the connection string. Using Solution Explorer, right click on project and go to properties (Fig 02):

    Within the project properties, open the Settings tab and add a new setting with the name "cnNorthwind," "Type" as "String", "Scope" as "Application" and "Value" as required connection string (to connect to database) as shown below (Fig 03):

    More ASP.NET Articles
    More By Jagadish Chaterjee


       · Hi,This is my second article focusing on developing WCF Services. This...
     

    ASP.NET ARTICLES

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek