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.
Related
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
I am trying to figure out if ASP.net on the client side in order to support SignalR. I would rather not be reliant on asp.net if at all possible for the webclient. I haven't found anything thus far that leads me to believe that it is required, but I could be overlooking something obvious.
EDIT:
As noted by the comments my question was not correct. I am ultimately trying to find out if ASP.net is required to use SignalR. From Lain's comments below it doesn't sound like it is which is excellent!
Any information would be greatly appreciated.
No. ASP.Net isn't required on either the client or the server side.
ASP.Net is a server-side platform for .Net, so can't be used as part of a client.
There is a native C# / .Net client, but this is lightweight and does not require any http server platforms.
The server side or 'Hub' can be process self-hosted, or hooked into an existing IIS site. It does not use ASP.net directly, but can work side-by-side with an ASP.Net website.
You will need a hub running to connect to for your client.
For more information, see the SignalR project site, which has examples:
http://signalr.net/
SignalR is a libbrary build for asp.net that employs features like web sockets, long polling, forever frames. If you want to distant your self from asp.net you could implement any of these features with any server side language (directly not through signalR).
But for specifically using signalR without asp.net (although may be doable) is something I would prefer not to try or suggest. All that for the server side.
For client side simple javascript would suffice, so you do not need to use any microsoft technology there.
No ASP.NET is required for SignalR.
You'll need to have a class that Implements IHub and that class has to be in C# or VB which is obviously a language of .Net framework.
Also, the hub javascript file is outputted by signalr using c#
And any framework will be proud to announce itself platform agnostic, and signalr's home page's title itself mentions ASP.NET SignalR So defenitely you are going to need .Net.
And you need to have this RouteTable.Routes.MapConnection<MyConnection>(...); which is obviously c# in Global.asax, which is obviously executed only by a asp.net website.
And last but not the least, SignalR is implemented in C# and you need ASP.Net so that signalr executes c# in runtime.
That's a lot of reason, why you should definitely have asp.net :)
I am looking for guidance on how to start building a http REST server using C# and a SQL Server database?
Is there a recommended server framework for http web server? The same for REST services?
How should I start? Raising regular server and after that taking care of the SQL Server database?
Thanks.
I'm starting to evaluate REST frameworks for .Net and python. So far I like ServiceStack for .Net the best. It's simple, far easier to config than WCF, supports dependency injection, and seems to be fast.
When VS 11 and .Net 4.5 are completely released, Microsoft is also offering Web API. It can be used to build REST API's as well so it's worth looking into.
I haven't done enough research on Web API to see which would be better but those are some considerations for you.
Use OData. Have a look at Creating an OData API for StackOverflow including XML and JSON in 30 minutes
Consider using the new ASP.NET Web API:
ASP.NET Web API is a framework that makes it easy to build HTTP services . . . ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.
It is currently in beta but was built specifically for building RESTful HTTP services in .NET, unlike WCF. See SO question WCF vs ASP.NET Web API for more details.
There are samples and video tutorials, and in one they are using Entity Framework models which can be backed by SQL. This SO question specifically covers that example: How to mix Entity Framework with Web API
Does anyone tell me if it's possible to use WCF without .NET 3.0?
Our company develops a 3-tier client-server end-user solution based on .Remoting. One of the limitation of our project is using .NET 2.0. Unfortunately .NET 3.0 framework is too large to be included in our installation package and I don't know if MS license allows this.
But WCF might helps us to drastically reduce our efforts in some tasks.
Does anyone have a chance to use WCF from Mono?
Thanks in advance
--
Murat
Unfortunately this is not possible. System.ServiceModel and System.Runtime.Serialization assemblies are required and they are part of .NET 3.0.
Another important note is that WCF depends on HTTP.SYS (kernel level HTTP stack) which is available on Win2003, WinXP SP2 or higher, while you can still have .NET 2.0 installed on Win2000.
On the client side you could still have .NET 2.0 consuming the WCF service. You need to expose a basicHttpBinding endpoint for this purpose.
Could you use WCF and .Net 3.0 just on the servers at least? You could write your clients to consume simple ASMX style web service calls, and keep their install footprint small, while still getting the architectrual benefits of WCF in the server software.
That is part of the point of n-tier software... you can more easily upgrade critical peices of the application because they are on a few servers instead of on thousands of clients. I would re-examine .Net 2.0 requirement at least on your top tiers. You should see an easy cost-benefit improvement using the flexibility of the WCF platform even if you have heavy server install.
Well, there is WCF on Mono (http://www.mono-project.com/WCF) but I can't tell you how compatible it is. The whole thing would impose other restrictions as well, namely availability of Mono.
Apart from that WCF services can be exposed as web services with which you can talk to with mechanisms available on .NET 2.0
You can invoke WCF services (if they are configured to use SOAP over HTTP) from any client, using regular SOAP bindings/syntax. The service itself, however, needs to be running on .NET 3.0. If you have the ability to create just the service layer on .NET 3.x and leave the rest of your stack on 2.0, that might be a good way to go.
A lot of the features of WCF were piloted (using ASMX web services) in WSE 3.0, which runs on .NET 2.0, but you will need to look at WSE to figure out if it will actually save you time; it adds a lot of nice features for security/etc., but is not as easy to pick up and use as WCF.
We have some really old code that calls WebServices using behaviours (webservice.htc), and we are having some strange problems... since they've been deprecated a long time ago, I want to change the call.
What's the correct way of doing it? It's ASP.NET 1.1
You should be able to generate a proxy class using wsdl.exe. Then just use the web service as you normally would.
While I'm not 100% sure what the Web Service behavior does, I recall it allows client-side script to call Web Services, which would make AJAX it's contemporary replacement.
Since you're using .NET 1.1 how about using Ajax.NET Professional to connect to the web services?