This is a cool new feature that was introduced in WCF 4.0 and I have been using it since. Basically there is no need for physical svc files and the configuration is pretty simple. Below is the configuration I am using for this simple test case:
To test this out with a simple wcf service, fire up Visual Studio ( I am using Visual Studio 2013 preview but you can use 2012) and let's create a new WCF Service Application and name it WCFTestService. For best practices you would want to create a WCF Service Library to create the actual service interfaces and classes but for simplicity we are just gonna create a simple service within the same project.
After we create the project we would want to delete the default Service1.svc and IService1.cs files. Let's create a new interface file and name it ITestService:
Now, let's create the test service that is going to implement that interface:
We are just using a simple method that returns the id back to us.
We are done with the test service, let's tweak the default configuration. Open the web config file and paste the following:
After we get this hosted in IIS, we are ready to test the service. I am going to be using wcfTestClient which you can get to it thru the command line by typing wcftestclient as depicted below:
The address I specified in IIS is http://localhost:9090/SvcLessService/TestService.svc but you can specify your own address/TestService.svc. So, without the svc file I am able to download and query the wcf service method and below is the wcfTestClient result:
No comments:
Post a Comment