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.
7:
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)
where do you download svcutil.exe?
Just type on Visual Studio Command Prompt.
Well the demand of proxies will keep increasing day by day. Nice article by the way!
hello,
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.
guney
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.
Daniel.
Motivating blog
thanks, i am just the beginner, this is very useful
Nice, very helpful blog. Keep it up!
Regards,
Mazhar Karimi
You should give the parameter “/language:vb” .
If you call svcutil like that you’ll get a file “MyService.vb.cs”
Pusy is wetted thing of world
a
Very Nice My friend. Enjoyed the read.
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.
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
Hello to every one, it’s really a good for me to visit this web page, it contains precious Information.