📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

What is WCF? Explain the ABCs (address, binding, contract), the common bindings, SOAP and the WS-* standards, why it was so popular in enterprises, and what replaces it on .NET 10.

Covers Windows Communication Foundation: service, data and operation contracts, endpoints, bindings (basicHttp, wsHttp, netTcp, netNamedPipe), SOAP and WS-Security/ReliableMessaging/transactions, configuration in web.config, and the modern options (gRPC, REST, CoreWCF, the WCF client packages).

Intermediate Theory Intermediate corewcf grpc legacy-migration soap wcf

🎯 Key points

  • ABC: Address (where), Binding (how: transport, encoding, security), Contract (what: [ServiceContract], [OperationContract], [DataContract])
  • [FaultContract] declares typed SOAP faults; [MessageContract] controls the SOAP envelope headers and body directly
  • Bindings: BasicHttpBinding (SOAP 1.1, ASMX-compatible), WSHttpBinding (WS-*), NetTcpBinding (binary, fast, Windows-to-Windows), NetNamedPipeBinding (same machine)
  • WS-Security gives message-level signing and encryption independent of transport; with WS-ReliableMessaging and WS-AtomicTransaction it gave interop with Java enterprise stacks
  • Popular because one programming model covered HTTP, TCP, pipes, MSMQ, with security and transactions by configuration
  • On .NET 10: WCF client via System.ServiceModel.* packages and dotnet-svcutil; server via CoreWCF (1.9 targets .NET 10), which lacks some WS-* features such as WS-AtomicTransaction
  • Replacements: gRPC for internal RPC, REST/HTTP APIs for public and browser clients, CoreWCF to keep SOAP contracts
  • Configuration-heavy system.serviceModel sections; diagnose with WCF message logging and tracing (System.Diagnostics) viewed in SvcTraceViewer, and WCF performance counters

⏱ 30-second answer

WCF (Windows Communication Foundation, .NET 3.0, 2006) is a unified framework for service communication. You define a contract ([ServiceContract] interface, [DataContract] types, [FaultContract] for typed SOAP faults) and expose it on one or more endpoints, each with an address and a binding. The binding chooses transport, encoding and security: BasicHttpBinding for SOAP 1.1 interop, WSHttpBinding for the WS-* standards (WS-Security, reliable messaging, transactions), NetTcpBinding for fast binary Windows-to-Windows calls.

It was popular because one model covered HTTP, TCP, named pipes and MSMQ, configured in XML. On .NET 10 the WCF client is still available as NuGet packages, but there is no built-in WCF server: you host SOAP services with CoreWCF (community-built, Microsoft-supported, actively developed) or replace them with gRPC (internal RPC) or REST (public and browser clients). The trade-off: CoreWCF is the cheapest move but keeps you on SOAP.

🗣 Full answer (senior)

How I would answer this in an interview

"WCF is the service framework from .NET 3.0. The model is the ABCs. The contract is an interface marked [ServiceContract], with [OperationContract] methods and [DataContract] types serialised by DataContractSerializer. The binding says how messages travel: transport, encoding and security. And the address is where the endpoint lives. One service can have several endpoints, say SOAP over HTTP for a partner and binary over TCP for an internal client, with no code change, just configuration.

The bindings people meet most are BasicHttpBinding, which is plain SOAP 1.1 and compatible with old ASMX clients; WSHttpBinding, which adds the WS-* standards like WS-Security message signing, reliable messaging and distributed transactions; NetTcpBinding, a fast binary protocol for Windows-to-Windows; and NetNamedPipeBinding for same-machine calls. Enterprises loved it because they could talk to Java and SAP systems over WS-* with security and transactions configured rather than coded.

The mistake I see is assuming WCF is gone from .NET 10. The client is still there as NuGet packages, so a .NET 10 app can call a SOAP service with dotnet-svcutil. What's missing is the server. For that you choose: gRPC for internal service-to-service calls, because it's contract-first, HTTP/2 and fast; REST for anything public or called from a browser; or CoreWCF, which is a community port that Microsoft supports, when external partners depend on the exact SOAP contract and you can't make them change. My senior line: pick per service, based on who the clients are, not one answer for the whole estate."


Bindings

Binding Transport / encoding Use Notes
BasicHttpBinding HTTP, SOAP 1.1 text Interop, ASMX clients Transport security via HTTPS
WSHttpBinding HTTP, SOAP 1.2 + WS-* Enterprise interop Message security, reliable sessions, transactions
NetTcpBinding TCP, binary Internal Windows services Fast, Windows auth, duplex
NetNamedPipeBinding Named pipes Same machine Fastest, local only
NetMsmqBinding MSMQ queues Offline / queued calls MSMQ is not in modern .NET
WebHttpBinding HTTP, JSON/XML Early REST Use ASP.NET Core instead

What replaces it

Need Choose Why
Internal service-to-service RPC gRPC (Grpc.AspNetCore) Contract-first .proto, HTTP/2, streaming, fast binary
Public API, browsers, mobile REST / HTTP APIs Universal clients, OpenAPI tooling
Partners locked to SOAP/WSDL CoreWCF Keeps contracts and most bindings
Calling someone else's SOAP service System.ServiceModel.* client + dotnet-svcutil Still supported on .NET 10
Duplex callbacks gRPC streaming or SignalR Replace CallbackContract
MSMQ queued calls Azure Service Bus or RabbitMQ MSMQ not available

Status as of November 2026

CoreWCF's Microsoft support policy lists 1.9 (with 1.9.1 patch) targeting .NET 10, supported until November 2028 or six months after the next minor release. It supports BasicHttpBinding, WSHttpBinding, NetTcpBinding, NetNamedPipeBinding and more, but not every WS-* feature (no WS-AtomicTransaction distributed transactions, for example).

Production example

A payments team with 40 WCF operations typically splits them three ways: internal calls from other .NET services move to gRPC (with p99 latency often dropping from around 25 ms to under 10 ms thanks to HTTP/2 and Protobuf), the public mobile API moves to REST, and two operations used by a bank partner stay on CoreWCF with the same WSDL so the partner changes nothing.

🔍 What the interviewer is checking

Checks that the candidate understands WCF's model and can choose a migration target per service based on its clients.

Green flags

  • Explains the ABCs and names the main bindings correctly
  • Knows the client is supported on .NET 10 but the server is not
  • Names gRPC, REST and CoreWCF and when each fits
  • Mentions contract compatibility for external clients

Red flags

  • Thinks gRPC is a drop-in for every WCF service including browser clients
  • Unaware of CoreWCF
  • Can't explain what a binding does

📚 Learn in depth

1. The channel stack

A binding is really a recipe for a channel stack. Each message passes through channels in order:

Client proxy (ChannelFactory<IOrderService>)
   │  Message (SOAP envelope)
   ▼
[Protocol channels]  WS-Security → WS-ReliableMessaging → Transaction flow
   ▼
[Encoder]            Text (SOAP XML) / Binary / MTOM
   ▼
[Transport]          HTTP / TCP / Named pipe / MSMQ
   ▼  ... network ...
Service host: transport → encoder → protocol channels → dispatcher → your method

This flexibility is why WCF was powerful and why its configuration got huge: every behaviour (throttling, instance mode, concurrency, security mode, message size quotas) is a knob.

2. Contracts

  • [ServiceContract] on an interface; [OperationContract] on each method; IsOneWay for fire-and-forget.
  • [DataContract] / [DataMember] opt-in serialisation, versioned by adding members with IsRequired = false.
  • [FaultContract] declares SOAP faults, the typed error model.
  • The WSDL is generated from these, and clients generate proxies from the WSDL (svcutil, Add Service Reference, now dotnet-svcutil).

3. Instancing and concurrency

InstanceContextMode (PerCall, PerSession, Single) and ConcurrencyMode (Single, Reentrant, Multiple) control how many service objects exist and how many threads use them. Many production bugs came from PerSession with wsHttpBinding (sessions on by default) plus ServiceThrottling limits, causing queued calls and timeouts under load.

4. Why no server in modern .NET

WCF's server depended on Windows-specific pieces (IIS/WAS activation, System.Web hosting, Windows security, MSMQ) and its WS-* stack was huge. Microsoft chose gRPC as the recommended RPC framework and left SOAP servers to the community, which built CoreWCF on ASP.NET Core. Microsoft then started supporting CoreWCF in 2022.

5. Mapping WCF to gRPC

WCF gRPC
[ServiceContract] interface service in .proto
[DataContract] message
Request/reply operation Unary RPC
Duplex callback / streaming Server, client or bidirectional streaming
FaultException<T> RpcException with Status and rich error details
Message security (WS-Security) TLS + JWT/mTLS
NetTcpBinding speed HTTP/2 + Protobuf

Caveats: gRPC needs HTTP/2 end to end (or gRPC-Web for browsers), and some proxies and load balancers handle long-lived HTTP/2 connections poorly.

Try it yourself

  1. Generate a client for a public SOAP test service with dotnet tool install --global dotnet-svcutil and call it from a .NET 10 console app.
  2. Create a CoreWCF service from the CoreWCF template, expose the same contract on BasicHttpBinding and NetTcpBinding, and call both.
  3. Write the same contract as a .proto file and a gRPC service; compare payload sizes in Wireshark or Fiddler.
  4. Add a [DataMember] to a contract and confirm an old client still works; then rename one and see it break.
  5. Benchmark one operation over CoreWCF BasicHttpBinding versus gRPC with BenchmarkDotNet or a load tool such as bombardier.

💻 Code

A WCF contract on .NET Framework, the same contract hosted with CoreWCF on .NET 10, and the gRPC equivalent.

// Before (.NET Framework 4.8): WCF service contract
using System.Runtime.Serialization;
using System.ServiceModel;

[ServiceContract(Namespace = "http://contoso.com.au/orders/2014")]
public interface IOrderService
{
    [OperationContract]
    [FaultContract(typeof(OrderFault))]
    OrderDto GetOrder(int orderId);
}

[DataContract]
public class OrderDto
{
    [DataMember] public int Id { get; set; }
    [DataMember] public decimal Total { get; set; }
}

[DataContract] public class OrderFault { [DataMember] public string Reason { get; set; } }
// After option 1 (.NET 10): same contract hosted with CoreWCF, so SOAP clients don't change
// dotnet add package CoreWCF.Http ; dotnet add package CoreWCF.Primitives
using CoreWCF;
using CoreWCF.Configuration;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddServiceModelServices();
builder.Services.AddSingleton<OrderService>();

var app = builder.Build();
app.UseServiceModel(sm =>
{
    sm.AddService<OrderService>();
    sm.AddServiceEndpoint<OrderService, IOrderService>(
        new BasicHttpBinding(BasicHttpSecurityMode.Transport), "/OrderService.svc");
});
app.Run();

// The contract types are the same shape, using CoreWCF's attributes
[ServiceContract(Namespace = "http://contoso.com.au/orders/2014")]
public interface IOrderService
{
    [OperationContract] OrderDto GetOrder(int orderId);
}

[System.Runtime.Serialization.DataContract]
public sealed class OrderDto
{
    [System.Runtime.Serialization.DataMember] public int Id { get; set; }
    [System.Runtime.Serialization.DataMember] public decimal Total { get; set; }
}

public sealed class OrderService : IOrderService
{
    public OrderDto GetOrder(int orderId) => new() { Id = orderId, Total = 129.95m };
}
// After option 2: gRPC contract for internal callers (orders.proto)
syntax = "proto3";
option csharp_namespace = "Orders.Grpc";

service OrderService {
  rpc GetOrder (GetOrderRequest) returns (OrderReply);
}
message GetOrderRequest { int32 order_id = 1; }
message OrderReply { int32 id = 1; string total = 2; } // decimal sent as string to avoid precision loss

⚠ Common mistakes

  • Mistake: Saying .NET 10 can't talk to WCF at all. Why it is wrong: The WCF client packages (System.ServiceModel.Http, .NetTcp, .Primitives) are supported and dotnet-svcutil generates proxies. Instead: Separate client support (yes) from server support (CoreWCF or replace).
  • Mistake: Choosing one replacement for every service. Why it is wrong: External SOAP partners, browsers and internal .NET callers have different needs. Instead: Decide per service based on its clients.
  • Mistake: Assuming CoreWCF supports every WS-* feature. Why it is wrong: Some features, such as WS-AtomicTransaction, are not implemented. Instead: Inventory the bindings and behaviours you actually use before choosing CoreWCF.
  • Mistake: Mapping decimal to a Protobuf double when moving to gRPC. Why it is wrong: Money loses precision. Instead: Use a string or a units-and-nanos message.
  • Mistake: Copying WCF's default large message quotas or turning them to int.MaxValue. Why it is wrong: It opens the service to memory exhaustion attacks. Instead: Set size limits to what the contract really needs.
  • Mistake: Ignoring PerSession instancing and throttling when diagnosing timeouts. Why it is wrong: Sessions on wsHttpBinding plus default throttles queue calls under load. Instead: Check InstanceContextMode and ServiceThrottlingBehavior, and prefer PerCall.

🏛 Senior insight: trade-offs

WCF migrations go wrong when they are treated as a technology swap rather than a contract change. The contract is what clients depend on: operations, data contracts, fault contracts and any message contracts that shape SOAP headers. If you own every client, moving to gRPC or REST is a normal refactoring. If a bank, a government agency or a vendor owns the client, their change cycle is your constraint, and CoreWCF (or leaving that one service on .NET Framework) is often the cheapest honest answer. Security needs separate thought: services that rely on WS-Security message-level signing must be checked against what CoreWCF supports, while gRPC and REST move you to transport security (TLS, mTLS) plus tokens. Before deciding, turn on WCF message logging and tracing on the old service for a representative period and read the traces in SvcTraceViewer: they show which operations, bindings and security modes are really used.

Option When it fits Cost When not to
CoreWCF External SOAP clients you can't change Low code change; stays on SOAP You need features CoreWCF doesn't implement
gRPC Internal .NET or polyglot service calls Medium; new contracts, HTTP/2 infrastructure Browser clients without gRPC-Web, old proxies
REST + OpenAPI Public, browser, mobile clients Medium; redesign around resources Chatty internal RPC with streaming
Leave on .NET Framework Rarely changed service, Windows hosting OK Low now Active development or Linux hosting required

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions choosing per service Why: Checks they can run two contracts side by side during a migration
    How to answer

    Pull the business logic out of the WCF service class into a plain application service. Host it on .NET 10 behind two front doors: a CoreWCF endpoint with the identical namespace, WSDL and binding for the partner, and a gRPC service for internal callers. Check first that CoreWCF supports the bindings and behaviours you use (some WS-* features and session settings need adjustment). Carry security across explicitly: the partner's transport or message security and credentials on the CoreWCF side, TLS plus JWT or mTLS for internal gRPC callers. If the service uses WCF sessions (PerSession), make it stateless or move state to a store first. Prove the SOAP contract unchanged by diffing the WSDL and replaying captured partner requests. Move internal callers to gRPC one at a time behind a feature flag, comparing results in Application Insights, and retire the old host when its traffic is zero.

  2. When: Candidate mentions the WCF client packages Why: Checks practical knowledge of consuming SOAP from modern .NET
    How to answer

    Generate a proxy with dotnet-svcutil (or Connected Services in Visual Studio), which adds the System.ServiceModel.* packages. Gotchas: there is no app.config, so bindings and endpoints are set in code (or your own configuration); the generated operations are async (Task-returning), so call them with await rather than blocking; create and close clients properly (or reuse a ChannelFactory<T>) to avoid leaking connections; set message size limits and timeouts explicitly. Security needs checking up front: transport security (HTTPS, client certificates, Windows auth) is well supported, but WS- message security* on WSHttpBinding is only partly supported in the .NET client, so confirm the service's security mode and any WS-Security requirements. Test with recorded request/response pairs or a stub service so contract changes are caught in CI.

↩ Usually asked after

More in Legacy Technologies

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me