In our previous tutorials i have already explained How to implement WCF Services in asp.net application. Now i am going to call WCF Services from Console application as well as WindowsFormsApplications .I will call same WCF Services which i have explained previously.When you will understand the whole concepts of WCF, then you can easily implement the WCF Services in any application.It (WCF) is the full enhancement of Web services.You can easily know the differences between WCF and web services here.
There are some steps to implement each concepts in Console application which are given below:-
Step 1:- First create your own WCF Services as shown, from Step 1 to Step 5 here (previous tutorials).-->Run the WCF Services --> and copy the browser's URL as shown below:-
Step 2:- Open your visual studio --> File -->New-->Project -->Select console Application as shown below --> press OK.
Step 2:- Now open Solution Explorer -->Right click on Console Application 1 --> select Add Service References as shown below:-
Step 3:- Now Add WCF Services Address (which already copied in step 5 ) --> press Go Button as shown below -->press OK.There are some steps to implement each concepts in Console application which are given below:-
Step 1:- First create your own WCF Services as shown, from Step 1 to Step 5 here (previous tutorials).-->Run the WCF Services --> and copy the browser's URL as shown below:-
Step 2:- Open your visual studio --> File -->New-->Project -->Select console Application as shown below --> press OK.
Step 2:- Now open Solution Explorer -->Right click on Console Application 1 --> select Add Service References as shown below:-
Step 4:- Now open your console application (program.cs) -->write the following c# codes as given below:-
using System;
using ConsoleApplication1.ServiceReference1;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Istudent_dataClient obj = new Istudent_dataClient();
//call mywebssite method from below codes
string str = obj.mywebsite();
Console.WriteLine(str);
Console.WriteLine("");
//call rect_area method from below codes
Console.WriteLine("Enter two float values for calulating Rectangle area");
string s1 = Console.ReadLine();
float i = float.Parse(s1);
string s2 = Console.ReadLine();
float j = float.Parse(s2);
float area = obj.rect_area(i, j);
Console.WriteLine("rectangle area is: " + area);
//call Multiplication method from below codes
Console.WriteLine("");
Console.WriteLine("Enter two integer values for calulating multiplication of two Numbers");
int p = int.Parse(Console.ReadLine());
int q = int.Parse(Console.ReadLine());
int mult = obj.multiplication(p, q);
Console.WriteLine("Multiplication of two number is : " + mult);
//call student class method from below codes
Console.WriteLine("");
Console.WriteLine("student class member data are below:-");
ServiceReference1.student st = obj.GetData();
Console.WriteLine("Student id is : "+st.id.ToString());
Console.WriteLine("Student name is : " + st.sname.ToString());
Console.ReadLine();
}
}
}
Note:- In Above program i have called each WCF Services Methods.I have mentioned each method call in comment section of the program.Step 5: Now Run the Application (press F5)-->You will following output as shown below:-
Note:- Similarly You call WCF Services from WindowsFormsApplications also by adding Service Reference URL of WCF services as shown below:-
For More......
- How to perform insert,Edit,delete,update and print operation in Repeater control in asp.net
- How to create Generic Handler Application in asp.net
- Free download E-Post System project
- Create File Handling Real application
- Stored Procedure in sql server
- How to generate unique Number Using asp.net application
- How to print data in Gridview control
- How to use partial classes in any .NET application
- Tokens in c#
- Basic elements are used for compiling the c# codes
- How to use Microsoft Sql server
- How to use Ajax Functionality in asp.net applications
Download Whole attached file from below
Download
0 comments:
Post a Comment