I was having some very frustrating behaviour on our build server and while I found a number of articles online with similar error messages none of them helped me. I thought I would just explain this here incase if helps me or anyone else in future.
The error message we were getting is:
There was no endpoint listening at http://localhostStubs.ExternalApplication/SampleService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details
Our scenario is as follows:
We have a solution where a WCF service application hosting the WCF routing service is listening to the Windows Azure Service Bus Relay. We have an acceptance test project in the solution which sends a message to the service bus which is then received by the WCF routing service and routed to SampleService.svc which is hosted in another IIS application on the same box. A response is flowed back through to the test.
In the tests there are 5 scenarios simulating a successful message, and various error conditions. On my developer machine it was working absolutely fine every time, and a clean build on my developer machine worked fine. On the build server however one or more of the tests would fail each time with the above error message. There didnt seem to be any pattern to which test would fail.
The solution was building on a Windows 2008 R2 machine with IIS 7 and AppFabric Server installed with auto-start configured for the IIS Application which would be listening to service bus.
After lots of searching online and looking at logs etc it turned out to be a simple solution to just restart the WAS service (Windows Process Activation Service) and the services it advised you to restart with it.
Hope this helps someone else