Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, September 4, 2013 6:41 AM
Hi,
I am working on an example in a book and I cannot add a service reference. I enter the correct address and click go (in Visual Studio) and I get an error :
There was an error downloading 'http://localhost:8080/MagicEightBallService/_vti_bin/ListData.svc/$metadata'. Unable to connect to the remote server No connection could be made because the target machine actively refused it 127.0.0.1:8080 Metadata contains a reference that cannot be resolved: 'http://localhost:8080/MagicEightBallService'. There was no endpoint listening at http://localhost:8080/MagicEightBallService 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:8080 If the service is defined in the current solution, try building the solution and adding the service reference again.
Can you help ? I tried the code in the book instead of my own but I get the same error. It seems as though there should be something running in order for the service reference to pick it up but I don't know ? The example in the book is pretty straighforward and I can't figure out why it returns an error.
All replies (7)
Wednesday, September 4, 2013 4:11 PM
There is some steps I am missing from the example.
In the book it says to make a new console application called a WCF Client App ( I already have the host working ).
Then it says to type in the following on the Developer Command prompt :
svcutil http://localhost:8080/MagicEightBallService /out:myProxy.cs /config:app.config
It says if you want you can copy the two files (myProxy.cs and app.config) to your project. It says if you want you can include these two files into a client project and use the proxy type to communicate with the remote WCF service. But it then says it will use Visual Studio to generate proxy code instead.
I think I am missing something. I thought the config file (with its endpoint included) would provide the necessary link to the service and operations.
I do get an warning in the config file though
<client> <endpoint address="http://localhost:8080/MagicEightBallService" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IEightBall" contract="IEightBall" name="BasicHttpBinding_IEightBall" /> </client>
Warning 1 The 'contract' attribute is invalid - The value 'IEightBall' is invalid according to its datatype 'clientContractType' - The Enumeration constraint failed. C:\MyCode\Chapter25\MagicEightBallServiceClient\MagicEightBallServiceClient\App.config 13 27 MagicEightBallServiceClient
something wrong with IEightBall ?
Sunday, September 8, 2013 11:33 PM
HI aindriu
According to your description aboveI can hardly give precise troubleshooting, if you want to add a Service Reference, you can follow the method below,
To add a reference to an external service
1.In Solution Explorer, right-click the name of the project that you want to add the service to, and then click Add Service Reference.
The Add Service Reference dialog box appears.
2. In the Address box, enter the URL for the service, and then click Go to search for the service. If the service implements username/password security, you may be prompted for a username and password.
A progress bar is displayed while the search is being performed. You can stop the search at any time by clicking Stop.
3. In the Service list, expand the node for the service that you want to use and select a service contract.
4. In the Namespace box, enter the namespace that you want to use for the reference.
5. Click OK to add the reference to the project.
6. A service client (proxy) is generated, and metadata describing the service is added to the app.config file.
To add a reference to a service in the current solution
1.In Solution Explorer, right-click the name of the project that you want to add the service to, and then click Add Service Reference.
The Add Service Reference dialog box appears.
2.Click Discover.
All WCF services in the current solution are added to the Service list.
3.In the Service list, expand the node for the service that you want to use and select a service contract.
4.In the Namespace box, enter the namespace that you want to use for the reference.
5.Click OK to add the reference to the project.
6.A service client (proxy) is generated, and metadata describing the service is added to the app.config file.
Regards
Monday, September 9, 2013 6:57 AM
hi,
Thanks for the reply. I know how to use VisualStudio and add a service reference. Its just a matter of going to the menu.
When I try to add a service reference (like in the above steps) nothing appears.
I have added a service reference working in other examples but in that case I hosted the service. It was a CMD command I typed in order to get the service running which I then saw in service (in control panel) which I could select and then click start service. When I then went into add service reference and select go it appeard.
The exampe that would not work for me was a simple WCF example that avoided using Visual Studio WCF project templates. I created a class library called MagicEightBallServiceLib which implements a single WCF service. Then I created a console app MagicEightBallServiceHost that acted as host and produced a service. Once I had that done I ran :
svcutil http://localhost:8080/MagicEightBallService /out:myProxy.cs /config:app.config
It gave me a client side config file and a proxy file. I included the 2 files into a new client app called MagicEightBallServiceClient. Once I did that it said to add a service reference straight away. Nothing would come up when I entered the URI in the address bar of Add Service Reference.
It give me the above error in the original post.
The last part of the project was a console app that consumend the service.
In the example I was trying to get running there was no mention of hosting a service
Tuesday, September 10, 2013 3:31 AM
Hello,
It give me the above error in the original post.
Try by turning off your firewall and/or anti virus software.
Tuesday, September 10, 2013 3:59 AM
hi aindriu80,
Good day,
If you are following a tutorial to create and consume services in your workstation, please make sure that your created service is running with website before going to add service reference to your solution.
if you are having service as one application and consumer as another application let your asp.net webserver still connected with your service.
then your consumer application will able to listen to the service.
Tuesday, September 10, 2013 5:13 PM
Firewall / Virus checker is nothing to do with it.
I went through the steps but like I said it was an example that didn't use the templates. I guess I would need to type in everything that was listed in the book but that would take a while.
WWF isn't exactly WPF so I can understand if its a tricky one.
Tuesday, September 10, 2013 5:20 PM
Good day,
If you are following a tutorial to create and consume services in your workstation, please make sure that your created service is running with website before going to add service reference to your solution.
if you are having service as one application and consumer as another application let your asp.net webserver still connected with your service.
then your consumer application will able to listen to the service.
I created the service and had it running in CMD (the command DOS tool). The thing that wouldn't work is trying to find the service. I am not sure what I need to do in order to 'host' the service. It doesn't come up in Visual Studio - Add Service Reference.
I don't think it needs a ASP.NET webserver to run it though.