Hi
Here are some few steps to create WCF in asp.net 3.5
step1.
Create one asp.net project like this
Add WCF file like this
Step 3:
Add the operation contract
int Add(int a, int b);
in IService.cs file. as shown in Image
Step4
Go to Service.Cs file and click on “IService” as shown in Image
then Click on Explicitly Implement Interface.
then it will create interface add method.
Step 5: Write the code like this
int IService.Add(int a, int b)
{
return (a + b);
}
Step 6: For checking the service,click F5 you will get output like this
Step 7: Add Service Reference like this
Step 8:Click on Discover and Give the Namespace name like this
Step 9:Click on advance and Select “Generate Asyncronous Communication” like this
Step 10: Click ok. Then Come to “Default page” and keep there 2 textbox and one Button control like this
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title></title>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>
<asp:TextBox ID=”TextBox2″ runat=”server”></asp:TextBox>
<br />
<br />
<asp:Button ID=”Button1″ runat=”server” onclick=”Button1_Click” Text=”Button” />
</div>
</form>
</body>
</html>
Step 11. Click on” Button 1″ on write the following code in code behind for calling WCF service.
protected void Button1_Click(object sender, EventArgs e)
{
WcfTest.ServiceClient ws = new WcfTest.ServiceClient();
int result = ws.Add(int.Parse(TextBox1.Text), int.Parse(TextBox2.Text));
Response.Write(result);
ws.Close();
}
Step 12:
Now compile the code and pass the input in two textbox, you will get Output like this
I hope this will help to some one.
thanks
Good sample for beginners.
Thank simple and good to understand
You are welcome.
pls give me one example of wcf project
I m creating the sample project on wcf. I will share with you.
pls give me one simple example of MVC project
plz give me one 3tier asp.net with wcf sample
I will send you on Sunday.
I just ought to tell you which you have written an exceptional and distinctive post that I really enjoyed reading. Im fascinated by how nicely you laid out your material and presented your views. Thank you. gfegefbfddee
Pretty! This has been an extremely wonderful post.
Thanks for supplying this info.
Nice post )
http://wndbl0v3.com my blog