SIGN UP MEMBER LOGIN:    
ARTICLE

WCF Application Communicate with Console Application

Posted by Dinkar Chavhan Articles | WCF with C# April 19, 2011
An introduction to WCF for beginners with a simple sample Console application for communication using WCF
Reader Level:


All of you know WCF (Windows Communication Foundation). A WCF service can communicate with any application like Silverlight, webforms in Asp.Net, Console Application. So this article is an introduction to WCF for beginners with a simple sample Console application for communication using WCF.
So, let's see step by step how to do WCF.

Step 1: Go to Visual Studio 2010 – crete a new website; select WCF service; give it a name.

Step 2: Go to Iservice.cs and write this code:

{
   [OperationContract]
    int Add(int a, int b);

    [OperationContract]
    int Mul(int a, int b);

}

Step 3: Now go to Service .cs and write this one:

{
    public int Add(int a, int b)
    {
        return a + b;
        throw new NotImplementedException();
    }

    public int Mul(int a, int b)
    {
        return a * b;
        throw new NotImplementedException();
    }

}

Step 4: Now add a Console application; go to file on IDE; add New project; Console application.

Step 5: Go to the Console application and right-click; add a service reference; use the Discover option; click on Discover; give a namespace like SR.

Step 6: Now write this code in the program.cs:

{

   public int Add(int a, int b)
    {
        return a + b;
        throw new NotImplementedException();
    }

    public int Mul(int a, int b)
    {
        return a * b;
        throw new NotImplementedException();
    }
}

Step 7: Run the Application.
 

erver'>
Login to add your contents and source code to this article
share this article :
post comment
 

see maybe u create console application,right,now do 1 thing,whenever add console app in right click and add service refrence there two option reference also bt dont select that ok.when u select service reference then give some namespace SR u can give any name that u have access in console app

Posted by Dinkar Chavhan Jun 13, 2011

Good article, but could you elaborate more on steps 5-7? How I should code this console application?

Posted by marekw Jun 12, 2011
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor