Generating WCF Proxy using SvcUtil.exe

7 08 2008

Visual Studio 2008 has made our WCF life a lot easier with the ability to self-host the services and also allow debugging in our service.

What if we were pushed to a situation wherein we need to use the tool svcutil.exe to create our proxy for the client…hmm… 🙂

To do so, we need to have our service running. Once the service is up and running, we could generate the proxy by the following command (replace the tags correspondingly) :

   1: svcutil /t:code http://<service_url> 
   2:       /out:<file_name>.cs /config:<file_name>.config

Here is my example :

   1: C:\Users\Chaks\Documents\Visual Studio 2008\Projects\MyService\MyServiceHost>
   2: svcutil /t:code http://localhost:8731/Design_Time_Addresses/MyService/WcfService/ 
   3: /out:MyServiceProxy.cs /config:MyServiceProxy.config
   4: Microsoft (R) Service Model Metadata Tool
   5: [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.648]
   6: Copyright (c) Microsoft Corporation.  All rights reserved.
   8: Attempting to download metadata from 'http://localhost:8731/Design_Time_Addresse
   9: s/MyService/WcfService/' using WS-Metadata Exchange or DISCO.
  10: Generating files...
  11: C:\Users\Chaks\Documents\Visual Studio 2008\Projects\MyService\MyServiceHost\MyS
  12: erviceProxy.cs
  13: C:\Users\Chaks\Documents\Visual Studio 2008\Projects\MyService\MyServiceHost\MyS
  14: erviceProxy.config

Now we can add this .cs file to the Client project and copy the .config file contents to the Client’s app.config file and execute the client 8)

We can also instruct svcutil to generate the proxy in the preferred language we want :

   1: svcutil /t:code /language=VB 
   2:      http://localhost:8731/Design_Time_Addresses/MyService/WcfService/ 
   3:          /out:MyServiceProxy.vb /config:MyServiceProxy.config

But svcutil already identifies the language with the extension of our output file name 8)



15 responses

26 03 2009

where do you download svcutil.exe?

1 02 2013
Anubhava Dimri

Just type on Visual Studio Command Prompt.

20 04 2009

Well the demand of proxies will keep increasing day by day. Nice article by the way!

26 06 2009


i started to search what WCF is and how to use it. i have couple questions. i followed up a tutorial and in that tutorial it says after i written the service i should run it after that i should run svcutil.exe. i didn’t get the point of that why should i run the svcutil.exe and what does it serve for?

i need to learn this quickly.
thank u for your care.


25 03 2010

Very nice article! It partially solves my problem.

Is it possible to:

1) Tell the tool that I want to generate asynchronous operations
2) Change the collection type to say Systems.Collection.Generic.List
3) Tell the tool that I want to reuse all reference types?

I’m trying to automate the “Update Service Reference” IDE command and the 3 steps above reflect the way I normally configure a WCF service.

Any help is appreciated, thank you in advance.


3 12 2010

Motivating blog

2 07 2011

thanks, i am just the beginner, this is very useful

20 07 2011
Mazhar Karimi

Nice, very helpful blog. Keep it up!


Mazhar Karimi

20 10 2011
Mona said

You should give the parameter “/language:vb” .
If you call svcutil like that you’ll get a file “MyService.vb.cs”

11 11 2011
Jaicab joshef

Pusy is wetted thing of world

31 08 2012


23 12 2012

Very Nice My friend. Enjoyed the read.

24 12 2012

Reblogged this on Ackonit and commented:
Using add service reference gives error sometime, particularly when dealing with TFS. Use SvcUtil.exe to manually generate web service and WCF Services proxies.

12 05 2013

That is very fascinating, You’re a very skilled blogger. I’ve
joined your rss feed and stay up for seeking
extra of your great post. Additionally, I have shared your web
site in my social networks

19 05 2013

Hello to every one, it’s really a good for me to visit this web page, it contains precious Information.

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

%d bloggers like this: