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.
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.
"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
NetTcpBindingones, 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 anRpcExceptionwith a properStatusCodeplus rich error details, or ProblemDetails in REST. Duplex callbacks overNetTcpBindingbecome server streaming or bidirectional streaming in gRPC, or SignalR if a browser is involved. Sessions andInstanceContextMode.PerSessiondon'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."
| 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 |
| 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 |
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.
Checks that the candidate understands WCF well enough to translate its features, and chooses replacements by caller rather than by fashion.
Green flags
Red flags
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
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.
[DataMember(Order = 2)] controls XML element order; protobuf's field number is the identity on the wire. Rules that keep you safe:
reserved removed numbers.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).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.
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.
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.
dotnet new (CoreWCF templates) using a copied [ServiceContract] and call it from an old WCF client..proto for the same contract and generate a gRPC service; compare payload size with Fiddler or Wireshark.RpcException with StatusCode.InvalidArgument and read it on the client.CancellationToken.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();
reserved removed ones.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.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.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.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 |
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.
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.
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.
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.
Last updated 23 Nov 2026.