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

📚 Interview question

You're porting several WCF services to .NET 10. How do the WCF building blocks translate: DataContracts, FaultContracts, sessions and duplex callbacks? For each service, how do you choose between gRPC, a REST API and CoreWCF, and what do you do about existing SOAP clients you don't control?

Covers translating WCF features to modern .NET (DataContract to protobuf or JSON, FaultContract to gRPC status or ProblemDetails, duplex to streaming or SignalR, sessions), choosing gRPC, REST or CoreWCF per service, and keeping external SOAP clients working.

Mid-Level Theory Intermediate corewcf grpc legacy-migration rest soap wcf

🎯 Key points

  • CoreWCF: .NET Foundation community project with a published Microsoft support policy (1.9 targets .NET 10 as of 2026); keeps SOAP contracts with the least change
  • gRPC for internal service-to-service calls: contract-first .proto, HTTP/2, streaming, fast binary
  • REST/JSON for browsers, partners and anything public; OpenAPI as the contract
  • DataContract maps to protobuf messages (explicit field numbers) or JSON DTOs
  • FaultContract maps to RpcException status codes (gRPC callers) or ProblemDetails with HTTP status (REST callers)
  • Duplex callbacks map to gRPC streaming or SignalR; sessions do not carry over, so services become stateless
  • WS-AtomicTransaction / TransactionFlow has no modern equivalent: use the outbox pattern, idempotency and sagas
  • External SOAP clients keep a CoreWCF endpoint with the same WSDL until they move; measure, then sunset

⏱ 30-second answer

I decide per service, by who calls it. External partners on SOAP whose code I don't control get CoreWCF, which keeps the WSDL and contract with the least change (Microsoft supports it; CoreWCF 1.9 targets .NET 10). Internal service-to-service calls go to gRPC: contract-first, HTTP/2 and streaming. Anything browsers or new partners call goes to REST with OpenAPI.

The building blocks translate: DataContract becomes protobuf messages or JSON DTOs, FaultContract becomes RpcException status codes or ProblemDetails, duplex callbacks become gRPC streaming or SignalR, and sessions disappear: services become stateless. The trade-off: CoreWCF is the fastest path but keeps SOAP's complexity; gRPC and REST are cleaner but force every client to change.

🗣 Full answer (senior)

How I would answer this in an interview

"I never choose one target for all WCF services, because the right answer depends on the callers. I list every service with its bindings, who calls it, and whether we control those callers. External SOAP clients we don't control decide it for us: they need the same WSDL, so CoreWCF is the pragmatic choice. It's a port of the WCF server model to ASP.NET Core, Microsoft supports it, and version 1.9 runs on .NET 10. Internal .NET-to-.NET calls, especially NetTcpBinding ones, map naturally to gRPC: it's contract-first, binary, runs on HTTP/2 and supports streaming. Anything a browser, a mobile app or a new partner calls becomes a REST API with OpenAPI.

Then I translate the features. [DataContract] types become protobuf messages, and I give every field an explicit number, because that number is the wire contract. FaultContract<T> becomes an RpcException with a proper StatusCode plus rich error details, or ProblemDetails in REST. Duplex callbacks over NetTcpBinding become server streaming or bidirectional streaming in gRPC, or SignalR if a browser is involved. Sessions and InstanceContextMode.PerSession don't survive: I make the service stateless and move state into a database or Redis.

The mistake I see is rewriting a partner-facing SOAP service as REST and asking partners to 'just update'. They take a year. Keep the CoreWCF facade for them, move internal callers to gRPC, and retire SOAP when the last partner has moved."


Choosing the target per service

Caller Recommended target Why Watch out for
External partner, SOAP, can't change CoreWCF Same WSDL and contracts Not every WS-* feature is supported (e.g. some WS-AtomicTransaction, MSMQ needs extra packages)
Internal .NET services (NetTcp) gRPC Fast, typed, streaming Needs HTTP/2 end to end; browsers need gRPC-Web
Browser / SPA / mobile REST + OpenAPI Universal, cacheable More hand-written contracts
Internal, mixed languages gRPC or REST gRPC has codegen for most languages Load balancing of long-lived HTTP/2 connections
Fire-and-forget (MSMQ binding) Messaging (Service Bus) Durable, decoupled Different semantics, design work

Feature translation

WCF gRPC REST (ASP.NET Core)
[ServiceContract], [OperationContract] service and rpc in .proto Controllers / Minimal API endpoints
[DataContract], [DataMember(Order=n)] message with field numbers Records serialised with System.Text.Json
FaultContract<T> RpcException + Status, google.rpc details ProblemDetails (RFC 9457)
Duplex callback contract Server / bidirectional streaming SignalR or webhooks
Sessions, PerSession instancing Not supported: stateless + store Not supported: stateless + store
WSHttpBinding message security TLS + JWT / mTLS TLS + JWT / mTLS
TransactionFlow Not supported: outbox / saga Not supported: outbox / saga

Production example

In a logistics platform, 11 WCF services split into 2 CoreWCF (partner SOAP), 7 gRPC (internal) and 2 REST (portal). Internal call latency dropped from about 45 ms to 12 ms p95 after moving NetTcp to gRPC, and the partner endpoints moved to Linux containers on CoreWCF with no partner code change.

🔍 What the interviewer is checking

Checks that the candidate understands WCF well enough to translate its features, and chooses replacements by caller rather than by fashion.

Green flags

  • Chooses per service based on who calls it
  • Knows CoreWCF is supported and when it is the right answer
  • Translates faults, duplex and sessions concretely
  • Protects external SOAP clients and plans a sunset

Red flags

  • "Replace WCF with REST" for everything
  • Unaware that sessions and transactions don't carry over
  • Suggests gRPC for browsers without gRPC-Web

📚 Learn in depth

1. What WCF actually gave you

WCF unified transports (HTTP, TCP, named pipes, MSMQ), encodings (text, binary, MTOM) and protocols (SOAP 1.1/1.2, WS-Security, WS-ReliableMessaging, WS-AtomicTransaction) behind one programming model: Address, Binding, Contract. That flexibility is why enterprises loved it and why there's no single replacement.

 WCF service
   Contract  (interface + DataContracts)
   Binding   (BasicHttp | WSHttp | NetTcp | NetNamedPipe | MSMQ)
   Behaviours(instancing, concurrency, throttling, security)

 Modern .NET
   CoreWCF   -> keeps Contract + most HTTP/TCP bindings
   gRPC      -> new contract (.proto), HTTP/2 only
   REST      -> new contract (OpenAPI), HTTP/1.1, 2, 3

2. CoreWCF status (as of November 2026)

CoreWCF is a community project under the .NET Foundation with Microsoft support. Versions follow a support policy: 1.9 (April 2026, patched 1.9.1 June 2026) supports .NET 10; 1.8's support ends in late October 2026. It supports BasicHttpBinding, WSHttpBinding (with limits), NetTcpBinding, WebHttpBinding and more, hosted on ASP.NET Core. It is the right tool for preserving contracts; it is not a reason to keep building new SOAP services.

On the client side, the System.ServiceModel.* client packages (dotnet/wcf) let .NET 10 apps call existing WCF/SOAP services.

3. Contracts: DataContract vs protobuf

[DataMember(Order = 2)] controls XML element order; protobuf's field number is the identity on the wire. Rules that keep you safe:

  • Never reuse or renumber a field; reserved removed numbers.
  • Adding a field is backward compatible; renaming is free, renumbering is not.
  • Protobuf has no null for scalars: use wrapper types (google.protobuf.StringValue) or optional.
  • decimal has no native protobuf type: use a units/nanos message or string.
  • DateTime maps to google.protobuf.Timestamp (UTC only).

4. Faults

WCF faults are SOAP <Fault> elements, and FaultException<T> carried typed detail. In gRPC, the server throws RpcException(new Status(StatusCode.NotFound, "...")); for typed detail use the rich error model (Grpc.StatusProto) with google.rpc.BadRequest and friends. In REST, return ProblemDetails with an appropriate status and a type URI.

5. Duplex and sessions

Duplex WCF keeps a callback channel open over TCP, and the server calls client methods. gRPC models the same thing with streams:

WCF duplex                          gRPC
client -> Subscribe()               rpc Subscribe(Req) returns (stream Update)
server -> callback.OnUpdate(x)      server writes to IServerStreamWriter<Update>

Sessions (SessionMode.Required) tie a service instance to a client channel. Modern services are stateless behind load balancers, so session state moves to a store keyed by an explicit id.

6. Running both during migration

A common pattern: the new .NET 10 service hosts both a CoreWCF endpoint (for partners) and a gRPC service (for internal callers) over the same domain code. Partners notice nothing; internal callers move one at a time.

Try it yourself

  1. Create a CoreWCF service with dotnet new (CoreWCF templates) using a copied [ServiceContract] and call it from an old WCF client.
  2. Write the equivalent .proto for the same contract and generate a gRPC service; compare payload size with Fiddler or Wireshark.
  3. Throw RpcException with StatusCode.InvalidArgument and read it on the client.
  4. Replace a duplex callback with a server-streaming RPC and cancel it from the client with a CancellationToken.
  5. Host CoreWCF and gRPC in the same ASP.NET Core app and route by path.

💻 Code

The same contract three ways. The original WCF contract:

// BEFORE: WCF on .NET Framework 4.8
[ServiceContract(CallbackContract = typeof(IShipmentCallback))]
public interface IShipmentService
{
    [OperationContract]
    [FaultContract(typeof(ShipmentNotFoundFault))]
    ShipmentDto GetShipment(string trackingNumber);

    [OperationContract(IsOneWay = true)]
    void Subscribe(string trackingNumber); // server calls back with status changes
}

public interface IShipmentCallback
{
    [OperationContract(IsOneWay = true)]
    void OnStatusChanged(string trackingNumber, string status);
}

The gRPC contract for internal callers: explicit field numbers, and streaming replaces the duplex callback.

syntax = "proto3";
option csharp_namespace = "Contoso.Shipping.Grpc";
import "google/protobuf/timestamp.proto";

service Shipments {
  rpc GetShipment (GetShipmentRequest) returns (Shipment);
  rpc WatchStatus (GetShipmentRequest) returns (stream StatusChanged);
}

message GetShipmentRequest { string tracking_number = 1; }
message Shipment {
  string tracking_number = 1;
  string status = 2;
  google.protobuf.Timestamp updated_at = 3;
  reserved 4; // was 'legacy_depot_code': never reuse the number
}
message StatusChanged { string tracking_number = 1; string status = 2; }
// AFTER: gRPC service on .NET 10
namespace Contoso.Shipping;

using Contoso.Shipping.Grpc;
using Google.Protobuf.WellKnownTypes;
using Grpc.Core;

public sealed class ShipmentsService(IShipmentStore store, IStatusFeed feed) : Shipments.ShipmentsBase
{
    public override async Task<Shipment> GetShipment(GetShipmentRequest request, ServerCallContext context)
    {
        var s = await store.FindAsync(request.TrackingNumber, context.CancellationToken)
            // FaultContract<ShipmentNotFoundFault> becomes a status code
            ?? throw new RpcException(new Status(StatusCode.NotFound, $"Shipment {request.TrackingNumber} not found"));

        return new Shipment
        {
            TrackingNumber = s.TrackingNumber,
            Status = s.Status,
            UpdatedAt = Timestamp.FromDateTimeOffset(s.UpdatedAt)
        };
    }

    // Duplex callback becomes server streaming; ends when the client cancels
    public override async Task WatchStatus(GetShipmentRequest request,
        IServerStreamWriter<StatusChanged> responseStream, ServerCallContext context)
    {
        await foreach (var change in feed.SubscribeAsync(request.TrackingNumber, context.CancellationToken))
        {
            await responseStream.WriteAsync(new StatusChanged
            {
                TrackingNumber = change.TrackingNumber,
                Status = change.Status
            }, context.CancellationToken);
        }
    }
}

public sealed record ShipmentRecord(string TrackingNumber, string Status, DateTimeOffset UpdatedAt);
public interface IShipmentStore { Task<ShipmentRecord?> FindAsync(string trackingNumber, CancellationToken ct); }
public interface IStatusFeed { IAsyncEnumerable<ShipmentRecord> SubscribeAsync(string trackingNumber, CancellationToken ct); }

Hosting CoreWCF for partners and gRPC for internal callers in one app:

// Program.cs
using CoreWCF.Configuration;
using CoreWCF.Description;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGrpc();
builder.Services.AddServiceModelServices().AddServiceModelMetadata();
builder.Services.AddSingleton<CoreWCF.Description.IServiceBehavior, UseRequestHeadersForMetadataAddressBehavior>();

var app = builder.Build();
app.MapGrpcService<Contoso.Shipping.ShipmentsService>();

// Partners keep the same SOAP contract and WSDL (request/reply operations only)
app.UseServiceModel(sm =>
{
    sm.AddService<PartnerShipmentSoapService>();
    sm.AddServiceEndpoint<PartnerShipmentSoapService, IPartnerShipmentService>(
        new CoreWCF.BasicHttpBinding(CoreWCF.Channels.BasicHttpSecurityMode.Transport), "/soap/shipments");
});
app.Run();

⚠ Common mistakes

  • Mistake: Picking one replacement for every WCF service. Why it is wrong: callers differ: partners need SOAP, internal services want speed, browsers need HTTP/JSON. Instead: decide per service based on who calls it.
  • Mistake: Forcing external SOAP partners onto REST by a deadline. Why it is wrong: you don't control their release cycle, and breaking them breaks revenue. Instead: keep a CoreWCF endpoint with the same WSDL until they move.
  • Mistake: Renumbering protobuf fields to tidy up. Why it is wrong: field numbers are the wire contract; old clients misread data silently. Instead: add new numbers and reserved removed ones.
  • Mistake: Carrying WCF sessions forward with sticky load balancing. Why it is wrong: it breaks scale-out and rolling deployments. Instead: make services stateless and store state explicitly.
  • Mistake: Assuming distributed transactions come along. Why it is wrong: TransactionFlow / WS-AtomicTransaction across services has no gRPC or REST equivalent, so code that relied on one rollback now leaves half-done work. Instead: redesign with a transactional outbox, idempotent handlers and a saga or compensation step.
  • Mistake: Mapping every fault to StatusCode.Internal. Why it is wrong: clients can't tell retryable from permanent errors. Instead: use the right status (NotFound, InvalidArgument, Unavailable) and rich details.
  • Mistake: Choosing gRPC for a browser client. Why it is wrong: browsers can't read HTTP/2 trailers, so native gRPC doesn't work. gRPC-Web helps but supports only unary and server streaming (no client or bidirectional streaming), needs UseGrpcWeb() or a proxy such as Envoy, and adds generated JS/TS clients the front-end team must maintain. Instead: use REST for browsers unless you have a strong reason, and SignalR for push.
  • Mistake: Assuming CoreWCF supports every WS-* feature. Why it is wrong: some bindings and protocols (e.g. WS-AtomicTransaction, some message-security modes) are missing or limited. Instead: check each service's bindings against CoreWCF's supported list before committing.

🏛 Senior insight: trade-offs

The senior move is to separate contract compatibility from technology modernisation. CoreWCF buys you the first cheaply, so the platform move (Framework to .NET 10, Windows to Linux containers) can happen without negotiating with partners. It is a .NET Foundation community project, but Microsoft publishes a support policy for it (each minor version is supported for a fixed window; 1.9 covers .NET 10 into 2028), so it is a reasonable dependency, as long as you track its versions like any other. Protocol change then happens caller by caller, on the callers' timelines. I record the decision per service in an ADR, with a sunset date for each SOAP endpoint.

On errors: gRPC callers get RpcException with a status code (and google.rpc details for validation errors); REST callers get ProblemDetails with the matching HTTP status. Map them from one shared table so a not-found is a not-found on every protocol.

Then measure, before and after: p95 latency, payload size, error and retry rate per endpoint, CPU per request, and the number of active SOAP callers (log the client certificate or API key) so you know when it is safe to switch SOAP off. Run load tests at production volume before cutting traffic over, and watch the dashboards for at least a full business cycle afterwards.

Target When it fits Cost When not to
CoreWCF External SOAP callers, minimal change Keeps SOAP complexity, partial WS-* Greenfield services
gRPC Internal, typed, high volume, streaming HTTP/2 everywhere, new contracts Browsers, partners without gRPC tooling
REST + OpenAPI Public, browser, partner-friendly More hand-written mapping Chatty internal calls at high volume
Messaging Was MSMQ / one-way Redesign for async semantics Callers need an immediate answer

🔗 Follow-ups the interviewer may ask

  1. When: Candidate is vague on bindings or the ABCs Why: Checks they understand what WCF actually is before translating it
    How to 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.

  2. When: Candidate mentions running old and new endpoints side by side Why: Checks the step-by-step migration of one service with mixed callers
    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.

  3. When: Candidate mentions .NET 10 apps still calling SOAP services Why: Checks they know how the WCF client packages work on 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.

🛠 Real-world problems: how you handle them

gRPC migration breaks a partner because a fault became a generic error
Situation
A [freight] company moved [an internal NetTcp WCF service] to gRPC on .NET 10. A partner-facing CoreWCF facade called the new gRPC service internally. [Roughly 2 million] tracking requests a day.
Signals
Partner support tickets: unknown tracking numbers now returned a SOAP fault with 'Internal error' instead of the typed `ShipmentNotFoundFault`, and partner systems retried them endlessly. Retry volume rose [6x]; Application Insights showed a spike in gRPC `Internal` status codes.
Investigation
Traced one failing request end to end in Application Insights. The gRPC service threw a plain `KeyNotFoundException`, which became `StatusCode.Unknown`/`Internal`; the CoreWCF facade wrapped every `RpcException` in a generic `FaultException`.
Resolution
Immediate: in the facade, mapped `StatusCode.NotFound` back to `FaultException<ShipmentNotFoundFault>` and deployed within [hours]. Real fix: the gRPC service now throws `RpcException` with `NotFound`, and a shared error-mapping table is used in both directions.
Prevention
Contract tests that replay recorded partner SOAP requests (including faults) against the new stack; a fault-mapping table in the ADR; an alert on the ratio of `Internal` to total status codes.

How to tell it (STAR)

**S:** We'd moved [an internal WCF service] to gRPC, with CoreWCF keeping the SOAP contract for partners. **T:** Partners started retrying unknown tracking numbers endlessly, and I led the fix. **A:** I traced one request through Application Insights and found the not-found case now surfaced as a generic fault. I mapped `NotFound` back to the typed SOAP fault in the facade that day, then fixed the gRPC service to use proper status codes and added contract tests that replay recorded partner requests, including faults. **R:** Partner retry traffic dropped back to normal within [a day] (from [6x]), and the replay tests caught [two] further contract differences before they shipped.

More in Migration Topics

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me