Using wsdl.exe /l:CS /serverInterface
, I generated a C# interface from a WDSL document. I've implemented that interface on a WCF class. The resulting service runs locally:
http://localhost:51454/TapasSim.svc
This shows the default site. The problem appears when I append ?wsdl
to the URL:
http://localhost:51454/TapasSim.svc?wsdl
Unlike what I expected, this link does not return a WDSL document! Instead, it points back to the exact web page you get without the ?wsdl
. As a result, I cannot reference the web service. If I run svcutil.exe
it gives this error:
If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or services or because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.
But I would expect that error to have the same cause as the lack of reply to ?wsdl
.
What could cause a WCF .svc
service not to generate WSDL?
As it turns out, the problem was mixing two technologies. wdsl.exe
belongs to the older "Web References" that predate WCF. The newer tool svcutil.exe
is meant for generating WCF "Service Reference" interfaces.
So what happened was that WCF looked for [ServiceContract]
and [OperationContract]
attributes. When it couldn't find any, it silently did nothing.
The silent suppression of this condition is annoying, to say the least. An error like No service with [ServiceContract] attribute found
would really have helped.
Note that you can manually add [ServiceContract]
, but that will leave you with half "Service Reference" half "Web Reference". The result probably will not work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With