Question

I've got this WCF service contract (heavily simplified, but pay attention to the namespace it's in):

namespace Foo.Services.BarService
{
    [ServiceContract]
    interface BarContract {... }
}

In my app.config (client side), I configure an endpoint for some service:

<endpoint address="..."
          binding="..."
          contract="Foo.Services.BarService.BarContract" />

However, this results in an error saying that no endpoint was found in the client's configuration that supports BarService.BarContract. I can only get rid of this error by changing the contract attribute value to BarService.BarContract (i.e. by removing the namespace).

Why is that? Where could this error come from? Why must I not mention the namespace part of a contract type? Shouldn't that result even more in WCF not finding a matching endpoint?


Reply to the questions in @Ladislav Mrnka's comment below:

  • I am talking about the client side. (I forgot to mention this bit; sorry for that.) Can this error possibly come from the server side?

  • I generated the above service contract, along with a BarClient class that implements it, via Visual Studio's Add Service Reference facility. I specified the URL of the BarService, which is run by someone else. That's where I also specified that the service should be put in the Foo.Services.BarService namespace.

  • I was going to use the service directly via the BarClient class auto-generated for me, not via a ChannelFactory<BarContract>.

Was it helpful?

Solution

Creating client by Add Service reference does not recreate namespace structure from service. All created types and contracts are placed into new namespace defined by the name of the service reference. So I guess you named your service reference BarService. Client configuration must follow names of generated contracts.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top