Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do WCF endpoints ignore the hosts file?

Tags:

wcf

I have endpoints defined in a config file with a "fake" domain name. The idea being that this would make deployment easier, since instead of modifying the config files, we simply set the ip address of the "fake" domain name on the enviroments' hosts files. So for example, on my local dev box, I would have an entry in the hosts file

127.0.0.1       fake.domain

and on a user acceptance environment I might have

192.45.34.31    fake.domain

but in my config file I would just have the endpoint

<endpoint address="http://fake.domain/someServiceBase/SomeService.svc" ... />

However, WCF seems to completely ignore the hosts file. I can copy past the address into a browser, and it will come right up, but the WCF client (which is on the local dev box) will give a "host not found" error.

Why does WCF ignore the hosts file?

Edit: Additional note, everything works if I replace the endpoint address to use the actual ip address directly in the config file, e.g.

<endpoint address="http://127.0.0.1/someServiceBase/SomeService.svc" ... />
like image 553
Nathan Avatar asked Nov 06 '22 17:11

Nathan


1 Answers

Why does WCF ignore the hosts file?

Hmm, I suspect that it isn't. I'd guess that your client is making a connection, but being redirected by the service.

There's an article here that goes into great detail on endpoints:

The Windows Communication Foundation channel infrastructure revolves around the physical address since it’s responsible for receiving incoming messages using a particular transport protocol at a specific location. The Windows Communication Foundation dispatcher, on the other hand, is shielded from such networking details and instead focuses on mapping the incoming message to an endpoint, and ultimately to a method call.

like image 96
Seth Avatar answered Nov 15 '22 08:11

Seth