It is just magic that I put some file in my site’s Bin folder and place a svc file to point to some assembly pointing to my service type. And then, I could magically Add Service Reference to the url like this:
http://www.myserver.com//xxx.svc
I really want to know how what happens from my click “Add Service Reference” to the proxy is generated properly. What does the IIS do during this period?
It’s not really magic – it’s metadata exchange ! 🙂
When you do a
Add Service Referencein Visual Studio, behind the scenes, that service endpoint specified by the svc file is interrogated for its metadata. This is basically similar to a WSDL (Web Service Description Language) file – a machine-readable description of your service, its methods, what parameters they expect etc. – and a XSD (XML schema) that – again in machine-readable form – defines the parameter types used.Based on those two pieces of information, the WCF client side import can create C# or VB.NET classes that
So in the end – it’s really not magic. It’s the beauty of self-describing services and a bit of code generation that reads that metadata and creates client-side proxy classes from that metadata description
If you’re interested in more details about metadata, read the MSDN docs on WCF metadata – quite extensive and in-depth.