"The client was unable to retrieve service metadata. Make sure the service is running and exposing metadata" this error is occuring in .net 2008 while executing the wcf application. I used wcf service library template?What is the reason for the error? Is it IIS must for this?
It must allow anonymous access, and publish a "mex" endpoint. If (as a temporary measure) you host the service in IIS and navigate to the .svc, it will give you detailed instructions on how to publish "mex".
Or just fire up a clean WCF projet to get this info.
This really bugged me too but I think I got it fixed, if not solved.
Quick answer: Exclude every .cs file from the project that is not related to the service itself. Especially unit tests should be in a separate project.
What did I try?
I first tried to check namespaces according to Julie Lerman's blog post. It didn't help.
Second, I created a new WCF project and copied the original code piece by piece. Everything worked fine until I added a nunit test case .cs file and got the error. I changed the namespace of the test class but this didn't help. I tried to take the test methods out but even an empty test class triggered the error.
Finally, I excluded the test cases from the original project and it worked too.
I guess that something confuses the metadata generation here.
You have to enable metadata publishing on the server-side first.
See:
- https://blogs.msdn.com/brajens/archive/2007/04/26/accessing-description-metadata-wsdl-of-wcf-web-service.aspx
- http://www.request-response.com/blog/PermaLink,guid,c9513d28-f580-4a33-b4e8-c15476799a9d.aspx
You can expose either WSDL or MEX or both.
Or else you must share the metadata before hand, i.e. use the same interface on both side of the wire.