Question

I have a WCF service composed by two projects:

  1. WCF service library
  2. WCF Web application

The First project has a service call IMyService implemented by MyService. It is configured by using WS binding and if I press F5 on this project the WCFTestClient render the WS binding. In the web app I have an .svc file with this markup with the same name

 <%@ ServiceHost Language="C#" Debug="true" Service="[Namespace].MyService" %>

If I press F5 on this project it renders a BasicHttpBinding. Same in the Client. Why?

Was it helpful?

Solution

I have just checked that WCF Service Library project by default creates app.config with WSHttpBinding used for default service. When you run WCFTestClient it always uses this local config. If you want to use WCFTestClient to test additional services you must add their configuration to this config. This config is never used for anything else.

WCF Service application uses web.config. In WCF 4.0 it uses simplified configuration which adds endpoints based on some predefined conditions. By default it adds BasicHttpBinding endpoint to all services exposed over HTTP with common ServiceHostFactory.

OTHER TIPS

How is your config file configure? If you configure the endpoint to use the wshttpbinding, this is the one that should be used.

Would you mind adding some code here (including the binding and endpoint details from the config file), so we could take a look?

Thanks, Roberto Lopes.

I believe the original question was very poorly posed, to get a satisfactory answer you need to clearly state all the details.

First which version of Visual Studio are yo using? Since nothing is said, I'll assume it's the latest version VS2010 with SP1.

Let's say you have a visual studio solution that has two projects, one is a WCF Service Library, another is a WCF Application, both created using the default project template without any manual tweaking.

  • The WCF Service Library will have a app.config file with the following line:

in short, Visual Studio 2010 (SP1) uses wsHttpBinding for WCF Service Library projects by default.

  • The WCF Service Application project, however, will have a web.config file that contains no explicit endpoint definition, in which case, the default endpoint binding used is basicHttpBinding.

The OP said "When I pressed F5 on this project ....", this is a very misleading statement. What does it mean to "press F5 on a project"? Do you mean you selected the project node in the solution tree, then pressed F5? if that's the case, what happens will always depend on which project is set as the start-up project in the solution (not on which project node is currently selected in Visual Studio UI).

If the WCF Service Application project is the start-up project, pressing F5 will NOT cause the WCF test client to run, instead, it will cause the folder of the project to be displayed in IE.

If the WCF Service Library project is the start-up project, the WCF test client will be run, and this is only because in the debug section of the project's properties window, the start options has the following by default: /client:"WcfTestClient.exe"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top