You are eating your liver because when you try to access your Web Service your app crashes with
No connection could be made because the target machine actively refused it
The Stack Trace includes the following:
SocketException (0x274d): No connection could be made because the target machine actively refused it 127.0.0.1:1204]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224
[WebException: Unable to connect to the remote server]
Why the Pain ?
Quite possibly your Web Service is not running in any Web Server. In my case IIS was not set up on my local machine and I am therefore using Cassini, the built-in Web Server with Visual Studio.
While there was a Cassini process for my Web App there was no Cassini process for my Web Service. The sucker was moribund. No wonder it didn’t work. The solution is to start your Web Service which I did by starting a Cassini process for it.
In Visual Studio:
1) Set StartUp project as WebService
2) Run project (i.e. hit F5)
3) A Cassini Process starts up. This is the one serving your WebService. Never let it stop.
4) Now make your Web project that consumes your web Service your StartUp Project
5) Run it.
6) Another Cassini Process starts up. This one is serving your web site
7) Bob’s your nerdy cousin with the extreme ear wax. i.e. you will now be able to use your Web Service and the horrifying Active Refusal error message is gone.
So to make that clear, if you’re running Cassini, you need one Cassini Process for each Web Service you are consuming plus another Cassini Process to serve your actual Web Site. In my case I have one Web service so I need a total of two Cassini processes running to support my application.
Slightly misleading error message there. Should say “Web Service is not running.” ‘Actively refused’ makes me think of Credentials…and repressed memories about asking chicks out when I was a teenager, stuff like that.