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
post comment
     

Please elaborate more step-5. in discover tab nothing appera :( can nt proceed further....

Posted by Jeet Oct 16, 2012

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
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts