0

I'm using Visual Studio 2008 with a project that's targeting .NET 2.0. I need to add a reference to a WCF service that's defined in another project within the same solution. The WCF project targets .NET 3.5, and the service uses basicHttpBinding.

Because the client project is configured to target .NET 2.0, I don't have the option to "Add Service Reference". When I try to "Add Web Reference", and select "Web services in this solution", I get the following message:

No Web services were found in the current solution.

What am I doing wrong?

FishBasketGordo
  • 22,904
  • 4
  • 58
  • 91

1 Answers1

2

Web References are for the legacy ASMX techology. "Add Web Reference" naturally doesn't know that WCF even exists, so it shouldn't be surprising that it doesn't know about your WCF service in the solution. It's looking for .asmx files.

Try starting your service first by right-clicking the .svc file and using "View in Browser". Then give the URL of the service to the "Add Web Reference" dialog. Also, make sure your service exposes its metadata, so that the "?WSDL" will generate the WSDL for Add Web Reference.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • I don't have any .svc files. The project was created using the WCF Service Library template, which I don't think generates .svc by default. My .config file does expose a `mex` endpoint. Is this in the ball park of what I would need? – FishBasketGordo May 03 '12 at 20:16
  • This is in the ballpark, but you have to get the service hosted. One way would be to debug the service, but if you look at the Debug properties of the project, you'll see that F5 starts the wcfsvchost.exe program. You can start that manually to host the service, then use "Add Web Reference" pointing to the hosting URL. Note you can debug the service in one instance of Visual Studio, and do the "Add Web Reference" in another. – John Saunders May 03 '12 at 20:47
  • I ran my service project, which brought up the WCF Test Client, but all of the services are listed with the `mex` address. If I copy the address to a browser, I get an HTTP 400 error: Bad Request. I'm not sure how to get the WSDL data to add my web reference. – FishBasketGordo May 04 '12 at 13:24