There you can select WCF Service.
Specify the location that is http, here I selected the as shown fig above. and
click on OK button you will get another window.
After that service.cs file will
open automatically. When we creating WCF service by default some files and
folders are there.
App_Code FolderApp_Data Folder Service.svc Web.Config file
In App_Code Folder by
default two class files are generated.
IService.csService.cs
Open service.cs file write this
code
public string getname(string name)
{
return "Hello" + name;
}
next open web.config
file and add path in the endpoint
endpoint address = "http://localhost/WCFService/Service.svc " binding = "wsHttpBinding " contract = "IService ">
This end point will
be in Service.
Open Internet Information
Service, there you select your service and click on service.svc you will get a
path.
Now open visual studio 2008
command prompt type this command.
Svcutil http://localhost/WCFService/Service.svc
(this is the path of WCF Service)
Using service utility
we can create the proxy class and its configuration information.
You will get two
output files
Service.csOutput.config
Now will create
sample application in asp.net
Open Solution
Explorer Right click on Add Reference you will get a pop up window
In this window select
System.ServiceModel click on OK button.
Next right click on
Solution Explorer click on Add Service Reference; you will get a popup window
In the above window type Address
of your WCF Service path click on GO button
If path exists you
will get a Service that will be saved in your Solution Explorer.
Here we have to create a object of
service.
Add these namespaces
using System.ServiceModel;
using ServiceReference1;
On button click event
write this code
protected void btnget_Click(object sender, EventArgs e) { ServiceClient serv = new ServiceClient (); string val = txtboxuser.Text; Response.Write(serv.getname(val)); }
Here Enter any name in that text
box, it calls the method which written in Service.cs file and will get a result
This is the final output.
Happy Programming…….