Answered by:
How to consume WCF service in client Application ?

Question
-
Hi,
I have created WCF service Library which gives me default Interface and service method and App.config.
I have after created testClient Application which is console. with the help of SVCUTIL.exe in command prompt i have created proxy for WCF class library.
after running svcutil.exe out\ config.......
i got proxygeneraion.cs and app.config file.
now i want to consume methods available in WCF, how i consume WCF methods.
i am not getting how to access WCF methods in client.
i am not having namespace and class name here,from where i am getting these!!
Approaches are welcome!!!
Thanks.
- Edited by Maggy111 Wednesday, February 6, 2013 2:35 PM
Wednesday, February 6, 2013 2:34 PM
Answers
-
Hi Maggy,
You will have to use ServiceHost class to instantiate proxy class generated by svcutil utility.
The following forum post will help you in this regard.
http://social.msdn.microsoft.com/Forums/en/wcf/thread/74e07fed-6750-4b77-a290-bbed526ce0be
I hope this helps..
Thanks,
BR,
JollyWagoner
- Marked as answer by Maggy111 Sunday, February 10, 2013 2:26 PM
Wednesday, February 6, 2013 7:43 PM -
What is the content of your proxygeneraion.cs? If there is no class than may be something wrong is happening on your proxy generation.
The general practice is to include the proxy (.cs) and configuration file created by service utility in your console project and then instantiate the proxy to call a method.
For Step By Step understanding you can refer below materials
http://www.c-sharpcorner.com/UploadFile/mahakgupta/a-simple-example-of-wcf-service/
Lingaraj Mishra
- Marked as answer by Maggy111 Sunday, February 10, 2013 2:26 PM
Thursday, February 7, 2013 1:46 PM -
Hi,
If your client application is .Net Console application. Then just follow the bellow steps.
1. First goto the Visual Studio Solution Explorer.
2. Right click on Reference. Then Add Service Reference.
3. Now withing Add Service Reference window, input WCF service address withing Address bar (like: http://localhost:port/ServiceName.svc
Note: If don't required any port, then use (http://localhost/ServiceName.svc)
4. Then click on Go button.
5. When Serive found sucessfully. You can change the defalut name of the Namespace: From ServiceReference1 to any name according to your need.
6. Click on OK.
7. Then you can found the WCF Service reference already added into your .NET console application.
8. Now you can take the refernce of this servicce into your console application. And create a proxy client instance into your console application. Like bellow
ServiceReference1.ServiceClassName client = new ServiceReference1.ServiceClassName(); client.MethodName(); //do the rest of the job according to your need.
Happy coding.
Thanks
Knight Data Access Layer - .NET ORM, LINQ Provider, and more
https://www.kellermansoftware.com/p-47-net-data-access-layer.aspx- Marked as answer by Maggy111 Sunday, February 10, 2013 2:26 PM
- Edited by radcorpindia Monday, February 11, 2013 5:05 AM
Sunday, February 10, 2013 8:25 AM
All replies
-
Hi Maggy,
You will have to use ServiceHost class to instantiate proxy class generated by svcutil utility.
The following forum post will help you in this regard.
http://social.msdn.microsoft.com/Forums/en/wcf/thread/74e07fed-6750-4b77-a290-bbed526ce0be
I hope this helps..
Thanks,
BR,
JollyWagoner
- Marked as answer by Maggy111 Sunday, February 10, 2013 2:26 PM
Wednesday, February 6, 2013 7:43 PM -
What is the content of your proxygeneraion.cs? If there is no class than may be something wrong is happening on your proxy generation.
The general practice is to include the proxy (.cs) and configuration file created by service utility in your console project and then instantiate the proxy to call a method.
For Step By Step understanding you can refer below materials
http://www.c-sharpcorner.com/UploadFile/mahakgupta/a-simple-example-of-wcf-service/
Lingaraj Mishra
- Marked as answer by Maggy111 Sunday, February 10, 2013 2:26 PM
Thursday, February 7, 2013 1:46 PM -
Hi,
If your client application is .Net Console application. Then just follow the bellow steps.
1. First goto the Visual Studio Solution Explorer.
2. Right click on Reference. Then Add Service Reference.
3. Now withing Add Service Reference window, input WCF service address withing Address bar (like: http://localhost:port/ServiceName.svc
Note: If don't required any port, then use (http://localhost/ServiceName.svc)
4. Then click on Go button.
5. When Serive found sucessfully. You can change the defalut name of the Namespace: From ServiceReference1 to any name according to your need.
6. Click on OK.
7. Then you can found the WCF Service reference already added into your .NET console application.
8. Now you can take the refernce of this servicce into your console application. And create a proxy client instance into your console application. Like bellow
ServiceReference1.ServiceClassName client = new ServiceReference1.ServiceClassName(); client.MethodName(); //do the rest of the job according to your need.
Happy coding.
Thanks
Knight Data Access Layer - .NET ORM, LINQ Provider, and more
https://www.kellermansoftware.com/p-47-net-data-access-layer.aspx- Marked as answer by Maggy111 Sunday, February 10, 2013 2:26 PM
- Edited by radcorpindia Monday, February 11, 2013 5:05 AM
Sunday, February 10, 2013 8:25 AM