I am learning about Blazor server apps. We have an existing asp.net MVC application that communicates with a WCF service via netTcpBindings. We are now thinking about moving our development into .net Core so based on that Blazor Server seems very cool to start with.
My question is, how can I consume the existing WCF netTcpBindings service on any new Blazor Server application? I have tried googling this but could not find much on the subject. Is it even possible to consume a WCF service in .Net core (because from what it seems WCF is not brought into .Net core)?
It is still possible to consume WCF from a .Net Core application. Bear in mind that it is nothing else than a communication protocol, so it doesn't really matter what "language" you are using as long as you are able to connect to the server providing the service and you implement the protocol.
Luckily the Microsoft people have that in .Net Core so
Say you have the following service:
on your Server on the Startup.cs file you can then do something like this:
Done, you may now invoke your WCF service from your .Net Core server
Related
We have a net48 WCF client that wraps the API for this very hard to consume service (made in Java I believe, SOAP and WSDL) and that works great.
Problem is, we're in the process of porting our platform to net5 and I can't port this WCF code since WCF was largely left behind and CoreWCF is moving at a snails pace.
From an architecture standpoint, how do we integrate this into something that can be utilized? Previously we had a Windows Service that would fire off client processes to do the actual communicating. In the new architecture, we'd like to move to something like Hangfire.
Although you can call WCF services in .net core, it is subject to some restrictions. The WCF client in .net core only supports four bindings: BasicHttpBinding, CustomBinding, NetHttpBinding, NetTcpBinding, and there are not many security features in .net Core. My suggestion is to use WCF in the .net framework.
About core's support for WCF, you can refer to this link.
If you want to use WCF, I suggest you use .net framework instead of .net core. The alternative to WCF in .net core is gRPC.
After my research SignalR is a middleware I can use in ASP. Is it possible to host the server part in for example a console application or a dll?
I've read about SignalR webhost, but the guide is for .Net Framework: https://learn.microsoft.com/de-de/aspnet/signalr/overview/deployment/tutorial-signalr-self-host
Not 100% sure what you are asking.
SignalR is built into ASP.NET core, you can reference and use it within the same application, which can be running in IIS, or self hosted, even asp.net core web apps are basically console apps, but there will need to be a web (internet aspect to your application.
There are also specific Azure services to handle signal R if that helps
https://azure.microsoft.com/en-gb/services/signalr-service/
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!
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.
WCF is not supported in .NET Core out of the box, however there seems like there is a community project that is working on adding support for it in .NET Core
https://github.com/CoreWCF/CoreWCF
See What replaces WCF in .Net Core? for more info.
Am I right to assume that there is no way now to call legacy WCF
service from Blazor client-side?
Yes, you're right... WCF is not supported in Blazor client-side, and it won't be supported in the future. Microsoft has decided to stop supporting it as from .Net 5.0, and suggest to use Web Api instead.
Depending on how much you are invested in WCF, you may shift to Web API, perhaps gRPC, or go on using WCF, hoping that the efforts of the community to port and support WCF might succeed.
I was able to to put WCF 4.7.2 using techniques found with SoftCore in .Net 5.
I can also work SoftCore Hosted Example Blazor Server.
Typically a WPF application is a consumer/client of a RESTful service(s) on a web server. I would like to have it reversed - WPF application should be able to expose an web API. This would be consumed by an web app.
The flow:
web app ---sends a command to--> WPF app
** WPF app makes a 'long running job' until its user decides to stop **
WPF app ---passes data back to--> web app
The communication should be in Json format. I have prepared OpenAPI (in YAML) schema for it at the http://editor.swagger.io/. In the future it could be used to make changes to the WPF app's web API.
It allows to generate ASP.NET Core server c# code stub. What would be the requirements to run ASP.NET Core server in WPF and weither it would be light weight enough for use?
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
// somewhere in the WPF app: BuildWebHost(args).Run();
The code is auto-generated by https://github.com/swagger-api/swagger-codegen.
There is a post which failed to integrate ASP.NET Core 2.x into WPF application. Unfortunatelly, ASP.NET Core 3.0 and later will only run on .NET Core.
I have some bits here and there but not a working concept. My options could be:
Use a 3rd party framework or library. Should be able to use OpenAPI/YAML schema or Swagger generated server stub code etc.
Could ServiceStack be the missing piece here?
Integrate ASP.NET Core into WPF. Is it is even possible?
Launch a separate web server (not a self-hosting) with web services from the WPF application. Sounds bad.
Implement WCF web service(s) and requests.
...
How to implement the web server/service(s) at WPF side? Maybe there is an existing 3rd party framework which could save me from reinventing the wheel?
PS. There is a similar question how to expose a restful service inside a WPF project but it is outdated.
This sounds like your requirement:
WPF application should be able to expose an web API. This would be consumed by an web app.
But then you're against the only solution that would make it possible:
Launch a web server with web services from the WPF application. Sounds bad.
I'm not sure how else you're expecting being able to expose a Web API without launching a web server? Inside a UI App you'd want to launch a self-hosted Service.
Self Hosting
In ServiceStack you can just start a self-hosted Service in your WPF App which can either be a self-hosted .NET Framework HTTP Listener or an ASP.NET Core on .NET Framework App. Both options Microsoft have said are going to be supported indefinitely, but .NET Framework is being phased out with ASP.NET Core 3.0 only going to run on .NET Core and .NET Framework stopping development at v4.x as .NET 5 is just going to be the next version of .NET Core.
But that shouldn't change what solutions are available to you now, if you need to run a Web Service in a WPF .NET Framework App you'll need to run a self-hosted .NET Framework HTTP Server which can either be a self-hosted HTTP Listener or ASP.NET Core (on .NET FX) App.
I am still relatively new to writing API's and web services, so bear with me if I use incorrect terminology.
I want to know if it is possible to create an API in C# using nancyfx (or any other framework) or even just a simple web app and then set it up as a continually running web service using WampServer. I'm pretty new to Wamp, all I have done so far is create a few rudimentary pages with php; but I can't seem to find any information about running a web service with Wamp using a different back end language other than php.
WAMP is stand for Windows Apache MySQL PHP. As I can say, you can't run a C# web service with it base configuration. However, you actually don't need this. If you are on .net Core, there is a Kestrel web server. You can use it to serve your app. On a .net framework you have a HttpListener which can help you to implement self-hosted web service (for example, a windows service which hosts your application).
There are many other options, btw. Try google for some kind of "Hosting .net web application" or "Self-hosted .net web application"