WCF service (.NET 4.0) can have a .NET 2.0 client? - c#

The scenario is like this:
I have a .NET 4.0 client-Server application that works fine.
I need to create a UserControl that can access the Server, but it needs to be created in .NET 2.0 (because customer application is .NET 2.0)
Does it exist a way to access .NET 4.0 WCF service from a 2.0 client?
NOTE:
it is not a Web service, but a standalone .exe server
No autentication used
Data transfered are almost basic (class with arrays and basic types within)
it uses client callbacks so protocol il net.tcp
optionally I can change protocol if I can still be able to use callbacks

You need to expose the WCF as a Web Service:
How to: Expose WCF service also as ASMX web-service
Expose WCF Service as Traditional Style Web Service .asmx
The you work as if it was a good old .asmx service (add reference and so on).
It doesn't matter if your WCF service is hosted in a .exe, a web app, a windows service...
Supporting callbacks is not possible in .NET 2.0 with .asmx services, so that you have to simulate a callbak using something like TcpListener and TcpClient.
Unfortunately this has to de done from scratch, but you can use the logic in the WCF implementation.

If your WCF 4.0 service is using basic http binding, you can use it in .NET 2.0 or in any other language.
Just use WSDL.exe to generate the proxy and use it in .NET or in any other language.

Yes you can use the WCF service in .net 2.0 client by adding the reference of the .cs file (proxy class) in your client project.

Question solved a while ago.
Well, not really solved...
After looking at an article about performance on .NET WCF, I decided to use .NET remoting.
It is faster, compatible native .NET 2.0 and it works.

Related

Call a gRPC HTTP/2 service from a .NET Framework application without using TLS

I have a .NET Framework application which cannot be ported to net core for various reasons. Now I want to switch from Grpc.Core to Grpc.Net.Client because the first one gets deprecated.
May application makes a gRPC request to a service written in C++ which does only support HTTP/2 and does not provide TLS. According to here this connection is not supported: "Only gRPC calls over TLS are supported.". I can confirm this so far.
Is there any way to call a gRPC HTTP/2 service from a .NET Framework application without using TLS?
You could make a proxy service in which you call original gRPC with TLS.
Than from your application call this proxy service which doesn't have those restrictions.
Your app <--> proxy service <--> gRPC
Proxy service - implemented in one language you like and exposed to your application.
This is one posibility.

Windows Service written in .NET accessible from VB6

I have to develop a Windows Service in .NET/C#. The service must be accessible from a VB6 application.
My first idea was to host a WCF service in a Windows Service, but the VB6 application needs a wrapper for the service to be able to consume it. This is not an option.
Now I'm thinking of using sockets, but is this the best approach? If not, what would be the best design?
I would like to know what my options are, and what are the pros and cons for these options?
Any advice is much appreciated
You can host your WCF services as COM+ applications.
Once you have a WCF service hosted in COM+, you can generate a type library from the COM+ application and then reference that in your VB6 code.
Note that you'll have to have the .NET runtime installed on the machine that the WCF service is hosted on (but not on the machines that you install a COM+ proxy on if using distributed calls).
The WCF service is still an option, but you would have to ensure the WCF configured binding is interoperable (choose BasicHttpBinding for example as seen here: WCF Bindings In Depth).
On the VB6 side, you can call an existing SOAP endpoint, as described here for example: How to Consume a SOAP Web Service in VB6?

Can I use WCF in this case?

We have a third party application that provied its web services to us by ASMX and it is created at the time of .NET 1.1
in the old days we were using VB 6.0 and connected to it by a PocketSOAP, etc...
bt now we want to replace the VB 6.0 with C# 3.5 WinApps and still use that third party web services.
so I wish to know what are my options for doing this? which one do you recommend and which one has a faster learning curve?
Thanks All.
From what I understand, you want to use consume the old web service only and want to replace your client application which was done using VB6.0. You dont have to use WCF here, you can create your client application using Win Forms/WPF. WCF is for providing service and in your case you want a client application.
My opinion will be to use WPF or .net winforms.
I'm not sure what you mean by "which one", what is the other option you're referring to?
But yes, you can use WCF as a client to an .asmx web service.
Just add a service reference like you would to a WCF service. It will use the WSDL to generate a client proxy.
You can use the BasicHttpBinding in WCF to interoperate with legacy services.

Can I interact with .NET libraries through Javascript?

We've built a set of .NET libraries (in C#) which are used to interact with an outside resource. The outside resource provide bindings in Java and .NET, so it was necessary to build our libraries in one of those languages and we're officially a Windows shop.
We also use PHP/Javascript for a lot of our front-end web applications. Is it possible for these PHP/Javascript web applications to interact with our .NET libraries? We have both IIS and Apache web servers if that makes a difference. Communication would need to go in both directions.
The most obvious approach is exposing your .NET libraries as web services on a web server (either IIS or Apache/Mono). This allows both JS and PHP to consume the same service endpoints (JS via AJAX, PHP vs web service calls).
If extreme performance is a concern - for example, your PHP apps need to make heavy calls into the .NET libraries as if they are native, then web services are probably not the best approach. For that, you might want to look into making COM Callable Wrappers for your .NET libraries and consuming them from PHP.
Although Ajax is the usual approach, another idea for you, in case it might help, would be to use Silverlight on the client side. That way, you would embed your .NET classes into a Silverlight application, which would then be downloaded to the client where it would run inside the browser. Silverlight apps can easily interact bi-directionaly with JavaScript, as well as with remote resources.
For example, you can mark a .NET method with the [ScriptableMember] attribute, which will expose it to JavaScript.
You can pass data via AJAX calls where you communicate to and from the client via JSON. For client side data set manipulation jLinq is a great library for performing Linq queries on JSON objects.
If you are looking for a good place to start with web services, JSON and ASP.Net webforms Dave Ward's posts on Encosia are really top notch.

Call .Net 3.5 WCF service from .Net 2.0 Standard ASMX Web Service Client

I created a service that is hosted on a server that has .Net 3.5 installed and I need to call this service from a client that only has .Net 2.0 installed.
Is there a way I can do this?
If your WCF service exposes an endpoint using basicHttpBinding, then it should be possible for the .NET 2.0 client to consume it. As Marc said, "no problem".
Yes you can do it. There are some caveats, however:
You have to use protocols that match. The standard .NET 2.0 libraries don't support many secure web service features; in fact, you're pretty much stuck with using only basicHttpBinding on the WCF service if you want to be consumed by a default install of .NET 2.0. That is a severe limitation in many enterprise scenarios. However, it may be all you need.
If you need more security but are still using .NET 2.0, there are alternatives. Again, your WCF service must accommodate your .NET 2.0 client, but your .NET 2.0 client will also need to take advantage of an external library. Specifically, you'll need the Web Service Enhancements put out by Microsoft. Keep in mind, however, that these libraries implement a beta version of some SOAP protocols, while WCF (the successor to WSE in many ways) implements the standards by default. Since there were some breaking changes in the protocols (particularly WS-Addressing), you'll have to offer a customBinding endpoint on your WCF service to accommodate.
Unfortunately, I can't tell you which you'll use, as it'll depend on which protocol you want to accommodate on the service, but most of your problems will be solved by changing the messageVersion of the textMessageEncoding for the custom binding. This is not the best scenario, but it could buy you something if you're trying to integrate a client.
Bottom line, there's a lot of work to get a .NET 2.0 client to talk to a WCF service for anything other than basicHttpBinding. In many cases, basicHttpBinding may be enough. For many enterprise scenarios, it will not. I can't speak as to which will help you or not, but it is possible to get it to work -- I've done it successfully.
But it's a big pain. Look for an alternative if you can.
Yes of course - the service being hosted on .NET 3.5 doesn't require the same version of the .NET framework on the client. Heck - you can even call such a service from Java or PHP! That's the whole POINT of Service Oriented Architecture! :-)
You need to define your service contract (what's the service called; what methods are available to be called on it) and you need to decide how to host it, e.g. at what address can you call this service, and what parameters are required (e.g. HTTP vs. TCP, secured or not secured etc.) - that's a lot of work, even in WCF.
Here are three introductory articles for WCF - check them out!
MSDN
CodeProject
Dennis van der Stelt's Blog
But calling that service from a .NET 2.0 client is ABSOLUTELY no problem!
Marc

Categories