How to Configure a WCF Service on Windows Server 2025
Windows Communication Foundation (WCF) is Microsoft’s unified programming model for building service-oriented applications that communicate over a wide variety of protocols, including HTTP, TCP, named pipes, and MSMQ. Although newer architectures like REST APIs and gRPC have grown in popularity, WCF remains deployed in many enterprise environments where existing .NET Framework applications rely on SOAP-based communication or binary TCP contracts. Windows Server 2025 fully supports WCF hosting through IIS, Windows Activation Service (WAS), and self-hosted Windows Services. This tutorial covers the fundamental WCF concepts, hosting options, binding types, endpoint and behavior configuration, proxy generation, and a realistic comparison of WCF to modern alternatives.
Prerequisites
- Windows Server 2025 with IIS installed (for IIS-hosted WCF)
- .NET Framework 4.8 or .NET 8 with Windows compatibility packages (WCF is primarily a .NET Framework technology; CoreWCF provides .NET 6/7/8 support)
- IIS role with WCF HTTP Activation and WCF Non-HTTP Activation Windows features enabled
- Visual Studio 2022 or later for development (WcfTestClient.exe and svcutil.exe are included)
- Administrator access on Windows Server 2025
- Basic understanding of C# and XML configuration files
Step 1: Understand WCF ABCs — Address, Binding, Contract
Every WCF service is defined by three core concepts known as the ABCs:
- Address — Where the service is located (a URI such as
http://server/MyService.svcornet.tcp://server:8080/MyService) - Binding — How communication occurs (the protocol, encoding, transport security, and reliability settings)
- Contract — What the service exposes (the interface defined with
[ServiceContract]and[OperationContract]attributes)
A minimal WCF service contract in C# looks like this:
using System.ServiceModel;
[ServiceContract(Namespace = "http://yourdomain.com/services/2025")]
public interface IOrderService
{
[OperationContract]
OrderResult SubmitOrder(OrderRequest request);
[OperationContract]
OrderStatus GetOrderStatus(string orderId);
}
public class OrderService : IOrderService
{
public OrderResult SubmitOrder(OrderRequest request)
{
// Business logic here
return new OrderResult { OrderId = Guid.NewGuid().ToString(), Success = true };
}
public OrderStatus GetOrderStatus(string orderId)
{
return new OrderStatus { OrderId = orderId, Status = "Processing" };
}
}
Step 2: Install Required Windows Features for IIS Hosting
Before hosting WCF in IIS on Windows Server 2025, install the required Windows features via PowerShell:
# Install IIS with required WCF features
Install-WindowsFeature `
-Name Web-Server, `
Web-Asp-Net45, `
Web-WMI, `
WCF-HTTP-Activation45, `
WCF-TCP-Activation45, `
WCF-Pipe-Activation45, `
WCF-MSMQ-Activation45, `
NET-Framework-45-Features, `
NET-WCF-HTTP-Activation45, `
NET-WCF-TCP-Activation45 `
-IncludeManagementTools
# Verify installation
Get-WindowsFeature | Where-Object { $_.Name -like '*WCF*' -and $_.Installed -eq $true }
Step 3: Create and Host a WCF Service in IIS
IIS-hosted WCF services use a .svc file as the entry point and web.config for endpoint configuration. Create the virtual directory or application in IIS, then add the following files:
OrderService.svc
<%@ ServiceHost Language="C#" Debug="false"
Service="YourApp.OrderService"
CodeBehind="~/App_Code/OrderService.cs"
Factory="System.ServiceModel.Activation.ServiceHostFactory" %>
web.config — system.serviceModel Section
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<!-- Service definition -->
<services>
<service name="YourApp.OrderService"
behaviorConfiguration="OrderServiceBehavior">
<!-- HTTP endpoint using basicHttpBinding (SOAP 1.1) -->
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="secureBasicHttp"
contract="YourApp.IOrderService" />
<!-- MEX endpoint for WSDL/metadata -->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<!-- Binding configuration -->
<bindings>
<basicHttpBinding>
<binding name="secureBasicHttp"
maxReceivedMessageSize="10485760"
maxBufferSize="10485760"
transferMode="Buffered">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<!-- Behavior: expose metadata (WSDL) for development -->
<behaviors>
<serviceBehaviors>
<behavior name="OrderServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceThrottling maxConcurrentCalls="100"
maxConcurrentSessions="100"
maxConcurrentInstances="100" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
Step 4: Choose the Right Binding
WCF offers several binding types suited to different communication scenarios:
basicHttpBinding — SOAP over HTTP/HTTPS
Best for interoperability with non-.NET clients, legacy systems, and any client that can consume WSDL. Uses SOAP 1.1, supports both HTTP and HTTPS. No reliable messaging or WS-Security by default:
<basicHttpBinding>
<binding name="basicHttp" maxReceivedMessageSize="5242880">
<security mode="None" />
</binding>
</basicHttpBinding>
wsHttpBinding — WS-* Standards over HTTP
Adds WS-Security, WS-ReliableMessaging, and WS-AtomicTransaction support. Best for .NET-to-.NET communication over HTTP where security and reliability features are needed:
<wsHttpBinding>
<binding name="wsSecure"
maxReceivedMessageSize="10485760"
transactionFlow="false"
reliableSession.enabled="false">
<security mode="Message">
<message clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
netTcpBinding — Binary TCP (.NET to .NET only)
Highest performance binding for .NET-to-.NET communication within an intranet. Uses binary encoding and TCP transport. Not interoperable with non-.NET clients:
<netTcpBinding>
<binding name="netTcpSecure"
maxReceivedMessageSize="20971520"
transferMode="Buffered"
portSharingEnabled="false">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
<reliableSession enabled="false" />
</binding>
</netTcpBinding>
Step 5: Self-Host WCF as a Windows Service
For services that must run independently of IIS (e.g., background processing services, non-HTTP transports), host WCF inside a Windows Service using ServiceHost in code:
using System;
using System.ServiceModel;
using System.ServiceProcess;
public class WcfWindowsService : ServiceBase
{
private ServiceHost _host;
protected override void OnStart(string[] args)
{
_host = new ServiceHost(typeof(OrderService));
// Configure endpoint programmatically
var binding = new NetTcpBinding(SecurityMode.Transport);
binding.MaxReceivedMessageSize = 20971520;
binding.ReceiveTimeout = TimeSpan.FromMinutes(10);
_host.AddServiceEndpoint(
typeof(IOrderService),
binding,
"net.tcp://localhost:8090/OrderService");
// Enable metadata exchange for TCP
var mexBinding = MetadataExchangeBindings.CreateMexTcpBinding();
_host.AddServiceEndpoint(
typeof(System.ServiceModel.Description.IMetadataExchange),
mexBinding,
"net.tcp://localhost:8090/OrderService/mex");
_host.Open();
Console.WriteLine("WCF OrderService started on net.tcp://localhost:8090/OrderService");
}
protected override void OnStop()
{
if (_host != null)
{
_host.Close();
_host = null;
}
}
static void Main()
{
ServiceBase.Run(new WcfWindowsService());
}
}
Register and start the Windows Service from an elevated command prompt:
sc create "OrderWcfService" binPath= "C:ServicesOrderWcfService.exe" start= auto
sc description "OrderWcfService" "WCF Order Processing Service"
sc start "OrderWcfService"
Step 6: Open Firewall for WCF Ports
# Allow inbound on TCP 8090 for netTcpBinding hosted service
New-NetFirewallRule `
-DisplayName "WCF OrderService TCP 8090" `
-Direction Inbound `
-Protocol TCP `
-LocalPort 8090 `
-Action Allow
# Allow inbound on TCP 443/80 for IIS-hosted basicHttpBinding
New-NetFirewallRule `
-DisplayName "WCF IIS HTTPS 443" `
-Direction Inbound `
-Protocol TCP `
-LocalPort 443 `
-Action Allow
Step 7: Test the Service with WcfTestClient.exe
WcfTestClient.exe ships with Visual Studio and provides a GUI for invoking WCF service operations without writing client code. Launch it from the Visual Studio Developer Command Prompt:
WcfTestClient.exe http://WS2025-APP/OrderService.svc
The tool will load the WSDL, display all operations, and allow you to fill in request parameters and see the raw XML response — ideal for quick smoke testing after deployment.
Step 8: Generate a Client Proxy with svcutil.exe
Use svcutil.exe to generate a strongly-typed proxy class from the service’s WSDL metadata endpoint. Run this from a developer machine or CI/CD pipeline:
:: Generate proxy from IIS-hosted service (HTTPS endpoint)
svcutil.exe ^
https://WS2025-APP/OrderService.svc?wsdl ^
/out:OrderServiceProxy.cs ^
/config:app.config ^
/namespace:*,YourClient.ServiceProxies ^
/language:CS
:: For a net.tcp hosted service using MEX
svcutil.exe ^
net.tcp://WS2025-APP:8090/OrderService/mex ^
/out:OrderServiceProxy.cs ^
/config:app.config
Include the generated OrderServiceProxy.cs and app.config in your client project. The proxy class exposes type-safe methods matching the service contract.
Step 9: WCF vs REST and gRPC in 2025
When building new services on Windows Server 2025, consider whether WCF is the right choice:
- WCF — Best for maintaining or extending existing enterprise WCF services, interoperating with legacy SOAP consumers, or using advanced WS-* features (transactions, reliable messaging). CoreWCF on .NET 8 extends WCF to modern .NET for new development.
- ASP.NET Core Web API (REST) — Preferred for new HTTP services, public APIs, and browser-accessible endpoints. Simpler tooling, broad client support, OpenAPI/Swagger documentation built in.
- gRPC (via ASP.NET Core) — Best for high-performance .NET-to-.NET or polyglot communication with strongly-typed contracts via Protocol Buffers. Significantly faster than SOAP/WCF for internal microservice calls.
Conclusion
Configuring a WCF service on Windows Server 2025 involves understanding the ABC model, selecting the appropriate binding for your transport and security requirements, and choosing between IIS hosting for HTTP-based services or a Windows Service host for TCP or non-HTTP protocols. The system.serviceModel section in web.config gives you declarative control over all aspects of service behavior, while svcutil.exe and WcfTestClient.exe provide the tooling needed to generate client proxies and verify service operation without writing consumer code. For new services, evaluate REST or gRPC as potentially simpler alternatives, but for existing WCF-dependent enterprise systems on Windows Server 2025, the platform remains fully supported and capable of serving demanding production workloads.