Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF web service does not return WSDL

Tags:

c#

wsdl

wcf

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

enter image description here

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?

like image 445
Andomar Avatar asked Jan 29 '13 18:01

Andomar


Video Answer


1 Answers

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.

like image 58
Andomar Avatar answered Oct 18 '22 00:10

Andomar