file – new project – wcf -> wcf service library
It will create Iservice1.cs and service1.cs files
There is a warning here in Iservice1.cs file
 // NOTE: If you change the interface name "IService1" here, you must also update the reference to
"IService1" in App.config. (if u try to rename iservice1 file then u have to go app.config and u have
to manually do the changes .THats y i added a new service file as per my naming conventions which
automatically updates app.config file.
Please follow.
If u want ur own service file just delete this file and add another
right click on solution ->add new item .. select "wcf service" file and rename (MyWebservice) according
to ur needs.
It will automatically adds two files : IMyWebService.cs and MyWebservice.cs files.
In IMyWebService.cs file
I wrote
        int AddTwoNumbers(int firstnumber, int secondnumber);
In MyWebService.cs file I added
 public int AddTwoNumbers(int first, int second)
            return first + second;
Thats it.
Press F5 it wil open a window which shows ur added method "AddTwoNumbers"
U can test ur webmethod by giving inputs and u can check the result. Fully flexible in 2008
Then develop a client application
File -> Add new website -> selcte website 3.5 c#
right click on project : Add new reference –> system.ServiceModel
right click on project : add service reference.. click on discover and ok
in default.aspx: add using system.servicemodel
and page_load
    ServiceReference1.Service1Client cl = new ServiceReference1.Service1Client();
       Response.Write(cl.AddTwoNumbers(1, 2).ToString());
Make this as startup project ..Press f5.thats it
This procedure is same for windows,console (add code in program.cs file)

About ambatisreedhar


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s