Introducing DotNetFunda.com on mobile http://m.dotnetfunda.com ! Be with DotNetFunda.com on the go !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 3982 |  Welcome, Guest!   Register  Login
Home > Articles > WCF > Creating Multiple Channels in Channel factory in WCF

Creating Multiple Channels in Channel factory in WCF

1 vote(s)
Rating: 5 out of 5
Article posted by Anup1252000 on 2/11/2010 | Views: 11738 | Category: WCF | Level: Beginner red flag


In this article, We are going to see how to use Channel factory in WCF.

Introduction

     The channelFactory class is useful when you want share a common service contract dll between the client and the server. In this post I will show how to create a ChannelFactory implementation with message header using WCF.

     Let us go through this application step by step

 

Step 1:

        Create a new class Library project->give the name as Interface

Step 2:

        In this class library project give the reference to System.ServiceModel.

Step 3:

      

     Its a simple peace of code which consists of Service contract and operation contract.

Step 4:

        Now create a console application->name it as service->create a class called EchoService.cs-> give a reference to System.ServiceModel and Interface Class Library.

Step 5:

      

We get the Guid value in the message header. It takes 2 paramater one as LocalName of the XML header and another as a namespace of the XML.

Step 6:

      Now lets go to our Program.cs file and write the service hosting.

     

Here we are using binding as WSHttpBinding and the endpoint address as http://localhost:8080/Echo.

Just build the application and see if there are any errors.

Step 7:

    Now create one more Console app->name it as client->give the reference to System.ServiceModel and Interface Class Library.

   

 

In this interface we have given reference to IEchoService and IClientChannel.

 IClientChannel->It defines the behaviour of oubound request and reply channel used by client app.

Here we are creating the object for channel factory using wshttp binding. After that we are creating the channel using endpoint address http://localhost:8080/Echo. After that we are creating the Guid and then the Guid value has been added in MessageHeader.

Step 8:

    Lets run the application and see the result.

 

I hope you people like this article.

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

About anup hosur

Experience:2 year(s)
Home page:
Member since:Saturday, August 01, 2009
Level:Starter
Status: [Member]
Biography:
>> Write Response - Respond to this post and get points
Related Posts

In this article you are going to see how to use Message Queuing in WCF.

In this article we will look how we can trace and debug information in WCF services. There are some ready made tracelisteners provided by WCF. The base of these ready made trace listeners is .NET trace listener. So we will first understand the basic concept of trace listener and then go through the ready made tracelisteners provided by WCF.

WCF Security is very import when exposed to outside world. To enable Business to Business service it is always better to go with certificate authentication.

To Create and Host WCF Application in IIS Server.

In this article we will try to understand how we can implement transactions in WCF service. So we will create two WCF services which does database transactions and then unite them in one transaction. We will first understand the 6 important steps to enable transactions in WCF services. At the end of the article we will try to force an error and see how the transaction is rolled back after the error.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2012 7:42:35 AM