0
votes

Hi i tried the example which was mentioned in msdn site (http://msdn.microsoft.com/en-us/library/ms733069.aspx) I was successful in hosting the service in windows service. Later I tried to consume it creating a WCF client and was not able to create client code using Svcutil.exe . I tried the other way by creating a console app as client and tried giving the service as ref. But it failed saying :

There was an error downloading ‘http://localhost:8001/ServiceModelSamples/service’. Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:8001 Metadata contains a reference that cannot be resolved: ‘http://localhost:8001/ServiceModelSamples/service’. There was no endpoint listening at http://localhost:8001/ServiceModelSamples/service that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:8001 If the service is defined in the current solution, try building the solution and adding the service reference again.

Can you help me in going further?? I am stuck here.

4
Are you sure your service is not stoped? did you try to debug your windows service too see hosting done carefully?Saeed Amiri

4 Answers

2
votes

'No connection could be made because the target machine actively refused it' clearly shows that nothing is listening on the port 8001. Either your service is not launched or you're using the wrong port.

If your service is launched, check the port it is listening to with Process Explorer for example.

1
votes

Option 1-:Change port to 8080 and try
Option 2 -:Please make sure to enable Service meta data exchange

(endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /)

0
votes

Try connecting to your WCF service with the tools designed for that. If you cant connect thru them, well, your service probably isnt hosted correctly, with some endpoints being messed up ...

0
votes

I had the same problem and found that I had forgotten to launch my Windows Service (that was hosting the WCF) as suggested by @Bren. Once this was launched I copied the address from the config file into the Add ServiceReference Dialog and it found it ok.