Nirmal
Nirmal

Reputation:

Wcf Client Error: "The client was unable to retrieve service metadata"

"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?

Upvotes: 2

Views: 1724

Answers (3)

chakrit
chakrit

Reputation: 61568

You have to enable metadata publishing on the server-side first.

See:

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.

Upvotes: 1

mika
mika

Reputation: 6972

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.

Upvotes: 0

Marc Gravell
Marc Gravell

Reputation: 1064324

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.

Upvotes: 1

Related Questions