How to access a WCF service from F# in .NET Core 3.1?

Viewed 359

In .Net Framework 4.7.2 F#, I have been using:

FSharp.Data.TypeProviders

with

  type WSDL =  WsdlService<"http://...ServiceHost.svc">
  type AV   =  WsdlService<"http://...ServiceHost.svc">

to access my local WCF network service from an F# .fs file.

How do I access the WCF service from F# client when .NET Core 3.1 is being used?

TIA

If not, what is the recommended upgrade path for WCF/petapoco/PostgreSQL?

1 Answers

That is an old type provider from F# 3.0, and it depended on svcutil for code generation. You could reference its nuget package but it's possible (likely) there is no support for the dotnet-svcutil tool. But you can use WCF from C#, so:

  1. Add a new C# project to your solution
  2. Add Connected Service in Visual Studio and configure your end point, this will generate the necessary code, build your project (and test that it works)
  3. From your F# project, add reference to this C# project, and open ProjectName
  4. Create your type, and use it from F#. You will get intellisense on the types so the user experience is not that different from the type provider.
  5. If needed you can publish the self-contained exe:
    dotnet publish -r win10-x64 -c Release -p:PublishSingleFile=true -p:PublishTrimmed=true
Related