Question

I am trying to implement scalable wcf solution found at NetFX Harmonics: Creating Streamlined, Simplified, yet Scalable WCF Connectivity

So my solution have 4 projects

  • Contact.Service (Service and Data Contracts)
  • Contact.ServiceImpl (HostFactory and Service itself)
  • Contact.ServiceHost (Web.config and Person.svc)
  • Contact.ServiceClient

Contact.ServiceClient have App.config and Program.cs which actually call service.

App.config

<configuration> 
  <appSettings>
    <add key="PersonServiceActiveEndpoint" value="PersonServiceBasicHttpBinding" />
  </appSettings>    
  <system.serviceModel>
    <client>
      <endpoint name="PersonServiceBasicHttpBinding"
                address="http://localhost:1031/Person.svc"
                binding="basicHttpBinding"
                contract="Contact.Service.IPersonService" />
    </client>
  </system.serviceModel>  
</configuration>

Program.cs

  BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
            EndpointAddress endpointAddress = new EndpointAddress("http://localhost:1031/Person.svc");
            IPersonService personService = new ChannelFactory<IPersonService>(basicHttpBinding, endpointAddress).CreateChannel();

            Person person = personService.GetPersonData("F488D20B-FC27-4631-9FB9-83AF616AB5A6");
            Console.WriteLine(person.FirstName);

When I try running this example exception is thrown:

There was no endpoint listening at http://localhost:1031/Person.svc that could accept the message. This is often caused by an incorrect address or SOAP action.

P.S. Person.svc is in my Contact.ServiceHost project

<%@ ServiceHost Service="Contact.Service.PersonService" %>
Was it helpful?

Solution

what is the config of the service host? sounds like one of 2 problems:

  • the service host is not set up to listen on the same port.
  • the host application is not being run at all

I imagine that by checking the web.config of the service host project you'll likely find that it is either listening on a different port, or not being run at all, and hence not listening.

Is the Visual studio host starting up and hosting the service? You usually get a little 'toast' pop up window in the notification area next to the clock saying the the host is running and you can see which port it is running on. if this is not happening then it is likely that you need to configure it to start the host project as well as the client.

To enable both the client and server to start at the same time you need to:

  • Right-click on your solution file, and choose Set Startup Projects...
  • Choose Multiple startup projects and choose Start for your client and server project, leave the other ones set to none.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top