How to log in to WCF Rest service from a .NET client application?

I am developing a solution in Visual Studio 2010 that has a WCF RESTful service hosted in IIS (actually Cassini at the moment) and a prototype ASP.NET MVC client. I’m all talking, but I can’t enter the service when debugging the client.

I have a class "service agent", which is used by my controllers to work with the service. The service agent uses the following code to make actual service calls:

var factory = new WebChannelFactory<IServiceContract>("theEndpointConfigName"); var channel = factory.CreateChannel(); var result = channel.CallTheService(); 

I can set a breakpoint on the last line, but pressing F11 will not switch me to the service as I expected.

Both projects exist in one solution, and I checked that the service is being called correctly, changing the response data.

What am I missing?

+4
source share
3 answers

I came across an answer. I thank Christian for unconsciously controlling mine in the right direction. Your expression about the debugger related to this or that process, but not both, made me think. It occurred to me that I had a web project, which was the only project to run in my solution. As a lark, I decided to try adding my WCF service application to the start list. Viola! That’s all you need!

So now I have both projects. I changed the setting in my WCF service application so that it does not show the page at startup. And now everything works as I expected.

Thanks for selling in the right direction!

+2
source

The Visual Studio debugger cannot cross the boundary of a process. You can either connect to the client process or the server process, but not immediately.

Here are some suggestions:

  • First, debug the client code. If the error is not there, retry the error again, but debug the service code instead of the client code.
  • Create two separate solutions for debugging purposes, one of which contains only client projects, and the other contains only service projects. You can then run both solutions in two instances of the IDE.
  • Add unit tests. It is much easier to find an error in the service if the β€œclient” is the bare-bones unit test method, and not your full client.
+3
source

See the CodeProject article below for an idea of ​​how to debug a WCF REST service.

http://www.codeproject.com/Tips/213007/Debug-WCF-REST-Service

-1
source

All Articles