Question

I am creating a service REST type using WCF in C# Visual Studio 2010 . The service receives a JSON file and then replies back with another JSON. I have built a Windows Forms Application and got to make the service work by creating a channel. I just send the JSON via POST, and get the contents. I want to bind the application as a Windows Services (Services in Control Panel). Thus, I created a WCF Service application, but when I debug it it opens the WCF Test Client Utility, however it fails because it asks for metadata. However, as I am using REST architecture I dont think I need to use metadata at all, since I don't even want to expose the services, I just want the users who know the service, then consume them. So, my question is more like how do I debug a WCF service REST type, without having to use metadata? Seems to me, to create client own my own and then put the service on Windows Service is not very good idea, since it takes a long time to install/uninstall.

Regards

Was it helpful?

Solution

My preference is to put the WCF Service in a library, make a separate simple console application, and self-host the service within a console application. This makes debugging very simple.

Later, when you want to make it a service (in Services), you can make a Windows Service project, and just reference the service library and host it within the windows service application.

OTHER TIPS

You're correct, WcfTestClient does not work for WCF REST services. There are many ways you can do that: you can use Fiddler (instead of the WcfTestClient); you can create your own client as you say; you can use any HttpClient in tests for that...

Regarding the issue with having to install / uninstall the windows service: unless you take any dependency on the windows service environment (such as user account), for testing purposes you can self-host your service in the same process as where the tests are running. This should be good enough for testing the service logic itself for most scenarios.

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