How to: Extend Web Services
Updated: October 17, 2013
Applies To: Windows Server 2012 Essentials
To add a web service, follow these steps:
In Visual Studio, open the Web Service API for Windows Server Essentials template.
Create the
web.configfile. This file should contain code that is similar to the following:<configuration> <system.serviceModel> <services> <service name="mynamespace.TestService"> <endpoint kind="webHttpEndpoint" endpointConfiguration="defaultEndPoint" contract="mynamespace.ITestService" /> </service> </services> </system.serviceModel> </configuration>
If you do not want to set the endpoint configuration to the default endpoint, you can create your own endpoint configuration by following the Windows Communication Foundation (WCF) standard.
Add the code to implement your web service. The web service class must declare the
SBSWebServiceBehaviorattribute (as shown in the example below), or else it will not operate correctly within the web service framework of Windows Server Essentials.namespace mynamespace { // ... [SBSWebServiceBehavior] public class TestService : ITestService { // Class implementation details } // ... }
Set the location of the compiled binary code to
%ProgramFiles%\Windows Server\bin.Compile the project.
Copy the web service (
*.svc) file and theweb.configfile to%ProgramFiles%\Windows Server\bin\webapi\YourOwnFolder.Restart IIS.
Verify that the web service is running.