TechBubbles Microsoft Technology BLOG

WCF Sample in Visual studio 2008

Introduction

This post explains the procedure to develop the sample WCF Service and WCF Client  in Visual studio 2008. Get an overview on WCF and WCF Terms.

1. Start open  Visual studio 2008, Select new project option from file menu

WCF Start

2. Select the WCF ServiceApplication template from the project templates.

3. WCF Service describes the operations that perform in a service contract.

WCF-Service

4.Declare the service contract in Iservice.cs interface and implement in the above Service class.

WCF-Interface

5. To test this service, you will need to create a client and use it to call the

    service. You can do this using the svcutil.exe tool from the command line with

    the following syntax: Generating a client using svcutil.

  svcutil.exe http://localhost:53391/Service.svc?wsdl

WCFClient

6. The above command generates a code file and configuration file contains the client class. Add the two files to your client application and use the generated client class to call the service.

Generatedclient

7. Client class which call the service looks like

callingservice

8. The generated client configuration file looks like

ClientConfig

9. The service configuration file looks like

service-config

Conclusion

The above post explains shows the standard way to create a service and client and calling the service. The Next posts explains each feature in depth. 

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

9 Comments

  • I think you missed one important point. Hosting of WCF Service. You haven’t covered it in your article. This blog I think is targeted towards beginner, so it should have been end-to-end solution. This is just constructive remark to your post. Nothing personal.

  • this is great but i have no svcutil.exe in my c:/program files/microsoft visual studio 9.0 folder can you adivse on where i can get this tool thanks.

  • @scott: Go to Start -> Programs -> Microsoft Visual Studio 2008 -> Visual Studio Tools

    and open Visual Studio 2008 Command Prompt, from there you can run svcutil.exe

  • Hi folk,

    its a gr8 article. I followed the same what you have advertised. but while running the client app, iam receiving the following error:

    “Could not find default endpoint element that references contract ‘IService1’ in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.”

    The above exception arises in following line:
    Service1Client client = new Service1Client();

    Can you please help me on this.

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud