tags:

views:

138

answers:

2

I am working through the book Learning WCF and on the first tutorial lab HelloIndigo I am receiving the following error.

Could not connect to http://localhost:8000/HelloIndigo/HelloIndigoService. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8000.

It appears in the Client project on the line string s = proxy.HelloIndigo();

EndpointAddress ep = new EndpointAddress("http://localhost:8000/HelloIndigo/HelloIndigoService");

IHelloIndigoService proxy = ChannelFactory<IHelloIndigoService>.
            CreateChannel(new BasicHttpBinding(), ep);
string s = proxy.HelloIndigo();
Console.WriteLine(s);
Console.WriteLine("Press <ENTER> to terminate Client");
Console.ReadLine();

I have intensively googled on this but I am none the wiser.

Can anyone explain the issue and how to remedy?

+2  A: 

It could be several things, first things to check are:

  • Is the service running?
  • Is there an endpoint configured a that address?
  • Is there any firewall that is blocking the request?

Try puting the endpoint address in a browser and see if you can browse to it.

Shiraz Bhaiji
@Shiraz- If I put the endpoint address in a browser I receive a blank page - if I reduce the url to http://localhost:8000/HelloIndigo I receive: This is a Windows© Communication Foundation service Metadata publishing for this service is currently disabled. etc...
Nicholas Murray
@Shiraz - if I try to add as a service reference to another project - I receive... There was an error downloading 'http://localhost:8000/HelloIndigo/HelloIndigoService'.The request failed with HTTP status 400: Bad Request.Metadata contains a reference that cannot be resolved: 'http://localhost:8000/HelloIndigo/HelloIndigoService'.Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:8000/HelloIndigo/HelloIndigoService. The client and service bindings may be mismatched. etc
Nicholas Murray
In order to add service reference, you must have metadata exchange enabled, this is done in the mex tag
Shiraz Bhaiji
@Shiraz thanks, Is there anyway to test your bulleted points?
Nicholas Murray
@Shiraz - figured it out - the Host project and the client were in the same solution and of course I was only setting the Client as the start-up project - when I opened the Host and Client as two seperate projects and ran them it worked as expected. In the book it says Compile the solution and run the Host project first, followed by the Client project. How do you do this within a solution???
Nicholas Murray
You can mark more than one project as a startup project, I think that it is in the properties of the solution
Shiraz Bhaiji
@Shiraz - yeah tried that and it worked - great tip! Thanks.
Nicholas Murray
A: 

Nicholas - I am encountering exactly the same problem and have the same question. How do I run the Host and then the Client console programs within the same solution? Did you ever figure this out?

Bob Jones
@Bob - (glad I was not the only one ;->) In Visual Studio 2010 go to Project / Properties / Common Properites / Startup Project / Multiple StartUp Projects
Nicholas Murray