Search code examples
c#wcfclient-sideblazor

Blazor client-side and WCF


I'm trying to use client-side Blazor to display some data, provided by existing WCF service. I was able to add a connected service reference, the proxy is generated. But when I'm trying to invoke it like this:

var client = new SoftConServiceClient();
await client.PingAsync(new PingRequest());

there is a bunch of errors, related to MonoTouch. By digging into the code of Mono, there is an explicit NotImplementedException in the constructor of the System.ServiceModel.DnsEndpointIdentity.

Am I right to assume that there is no way now to call legacy WCF service from Blazor client-side? If that's not the case, can anyone share a guide about how to properly do it?

Bonus question: if that is not possible, what would be the best option to approach this? Modify WCF to become REST-ish or just drop it and implement .net core api service?

Thanks a lot in advance!


Solution

  • Core does not support WCF very well instead of not at all. Especially in terms of authentication and security, such as the service created by using WS* binding. But for services created by using BasicHttpBinding or Restful styles services. We could invoke them normally on Core-based clients, whether using client proxy class or Channel Factory. Please refer to below official repository.
    https://github.com/dotnet/wcf
    I suggest you re-construct your server project with BasicHttpBinding or using Asp.net WebAPI to create the backend service.
    https://learn.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api
    Feel free to let me know if there is anything I can help with.