1

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" %>
slugster
  • 49,403
  • 14
  • 95
  • 145

1 Answers1

0

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.
Sam Holder
  • 32,535
  • 13
  • 101
  • 181
  • I set multiple startup projects and no luck. pop up window with error, "A project with an output type of class library cannot be started directly". One more thing, I changed Person.svc and now it's using factory <%@ ServiceHost Service="Person.Service.PersonService" Factory="Person.Service.PersonServiceFactory" %> And you are right, no wcf service is started, no pop up info message on taskabar – user1084557 Feb 08 '12 at 20:57
  • what is the type of the servicehost project? It shouldn't be a class library. looks like that is your problem – Sam Holder Feb 08 '12 at 21:09
  • I've changed Contact.Service project, actually I deleted and created again (insted dataclasslibrary now choose WCF service library). On debugging I have pop window with info: Usage: WCFSVCHOST.exe /service: – user1084557 Feb 08 '12 at 22:04
  • so is your problem fixed? Excellent, if it is. If this helped you can vote using the up arrow on the left :) – Sam Holder Feb 08 '12 at 22:10
  • I cannot vote, it requires 15 reputation, sorry. I accept your answer, at least that :) Thanks, all the best. – user1084557 Feb 08 '12 at 22:15