WCF & DataContract consumed by .net 2 client - wcf

I have developed a WCF service (framework 4.0) which should communicate with a client through BasicHttpBinding.
I have kept my (data)contracts in a separate assembly cause I want them to be reused by multiple clients.
Everything works as expected if I reference my WCF Service as a service (Service References) in a .net 4 client and set "Reuse types in referenced assemblies".
The problem is I have to consume the same WCF service with a .net 2 client.
In this situation the generated proxy is different from my shared assembly datacontract and I don't seem to be able to reuse it or cast it to the generated proxy.
Is there a way to solve this issue?
Thanks for your help.

Well, .NET 2.0 has no WCF API at all because it wasn't added until 3.0. So forget sharing the library because there's nothing to really share it with. The .NET 2.0 application will have to use the older WSE (Web Service Extensions) API. Documentation on WSE is available here on MSDN and you can download the last version of the WSE API that was made, 3.0 SP3, here.
You should have no problem getting WSE to talk to WCF via a basicHttpBinding. Things would only get complicated if you started using WS-* stuff and, even then, WSE supports a lot of that. It's just hard to find help on it since it's a deprecated API.

Related

Are client service contracts still autogenerated in WCF 4.0?

I have a net.tcp binding example that apparently dates back to .NET 2.0 runtime version. The client code of the WCF Net.TCP binding example has an interface marked as "System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "2.0.x.x") or so.
it also defines some Request & Response classes where the request apparently wraps the parameters of the service operation contract and the Response class wraps the result/return value. And it also defines a controller class for the service.
Now, in a WCF hosted by winform with net.tcp binding, I have found no way to autogenerate these classes myself. I wonder, is that an old way of doing things? is it required? or can I just include in the client app a reference to the DLL that contains the service?
I made some changes and now nothing works and wondered if I can just get rid of those "autogenerated" classes (or if not, HOW can I regenerate them?).
I use Visual Studio 2012 Ultimate for .NET 4.5 under Windows 7 Ultimate. My application are two winforms (client and server) that use WCF with netTCP binding.
Apparently I have to point svcutil o the base address rather than that of the service or endpoint. Then it will generate the client code and config.

Not able to add a Web reference to a WCF Service library using basicHttpBinding

I have two instances of VS2010 running on same machine.One VS instance has a WCF service with basicHttpBinding.
Now as i have read in books, for calling this WCF service with basicHttpBinding, i have to Add a Web reference to it rather than Service Reference.
I ran the project containing the WCF service and from other VS instance try to add a Web reference, this is the URL which i gacve(I got it from WCFClientHost )
http://localhost:8732/Design_Time_Addresses/WcfServiceLibraryBasicHttpBinding/Service1/mex
But i get Http 400 error everytime i try to add the WCF service.
Please let know what i am doing wrong.
You should keep two things apart:
Add Service Reference adds a service interface based on the .NET 3.0 and up WCF runtime. It supports all WCF bindings - including basicHttpBinding
Add Web Reference is the old-style, .NET 1.x/2.x method of adding a reference to an ASMX web service ("ASP.NET web service"). This technology is outdated, and has been fully replaced by WCF as of .NET 3.0. ASMX only ever supported what is more or less equivalent to basicHttpBinding.
The ASMX technology is outdated, and you should only ever use this if you really can't make WCF work (but in my 3 years of writing and consuming a plethora of web services, I have never seen such a case) - avoid this unless you absolutely can't make WCF work - for whatever weird reason that might be...
The link you gave to the CodeProject article has a entirely plain wrong statement that you need to use Add Web Reference for basicHttpBinding - that is just plain NOT TRUE.

How to Use the WCF Service developed in .Net 4.0 in the Application developed in 2.0 or lower version?

I came across with this situation. I have one already developed Application in 2.0, Now in this application i want to use one WCF Service that is developed in 4.0. How can i do this?
I tried the following
1. Regular Method Add the Service Reference and then use that. It didn't work for me.
2. I googled it and i got one more method, using svcutil.exe, but i dont have svcutil.exe with 2.0.
Waiting for the response.
Thanks in advance.
Windows Communication Foundation (WCF) was first introduced to the .NET Framework as part of .NET 3.0. It's not available with .NET 2.0.
If the WCF service exposes a SOAP endpoint then you may be able to use it through the Web Service Extensions (WSE) that were published for old versions of Visual Studio. See here: http://www.microsoft.com/download/en/details.aspx?id=10854 for details.
If you want to use a service written in .Net 4 with a .Net 2.0 project, you should be able to use basic http binding. That should allow it to interop with a client that knows nothing about WCF. It's similar to using an old school .asmx web service.

Making the switch from WSE-enabled Web Services, is WCF the way to go?

We currently have a half a dozen of project which originally have been built using .NET Framework 1.1 and WSE 2.0. But Microsoft's support for WSE is lacking and the latest version of it (3.0) only targets .NET Framework 2.0. Our new projects will use .NET Framework 3.5 and instead of hacking our self a WSE-support, we are currently looking for alternative approaches.
Our current projects use WSE to digitally sign the SOAP-messages with a X.509 certificate. This is what we require also for our future projects.
It seems that going with the WCF-route seems to be the smart choice but is there any alternatives? WCF seems to support X.509 certifications but we are little worried of its support for other platforms than .NET. Our clients need to be able to use Java-based software to connect to out services. And they've stated that it should be as easy as it has been before (when we were using Web Services). So WCF must be configured to use HTTP and SOAP.
Given the requirements of X.509, cross-platform interoperability and ease of use (HTTP & SOAP), is Windows Communication Foundation the right solution?
Yes WCF is the solution - it is API for building Web services and it is interoperable if you don't use MS/.NET specific features. But you should be aware that sometimes there are some problems with porting WSE services to WCF. I recommend to build very simple service in WSE (like Hello World) and secure it with certificates in the same way as real services. Then create Jave client to consume the service. After that replace WSE service with WCF. It will be your proof of concept. In a case of problems you can easily share this solution here or on MSDN to get some help.

WCF Integration with Legacy Remoting Client

I am facing a problem.
Please explain if this is possible or not.
1) I created a Service Library (.Net 3.5)
2) I created a Windows Service (.Net 3.5), added ServiceHost and implemented my ServiceLibrary to work as a TCP Endpoint.
3) Next I created a Console Client (.Net 3.5) and tried to get data from my TCP Endpoint…(svcutil….proxy.cs generation). Worked absolutely fine.
4) I have a Windows Client(.Net 1.1). How do I configure it to use this new Service? I can't add Proxy.cs as it says that servicemodel cannot be found…
You will need to use a basicHttpBinding, which is backward compatible and can be consumed by a .net 1.1 client. You should be able to find plenty of useful examples on the web: Consuming WCF with .Net 1.1 Basic Binding. For example, this Link describes that binding and usage of Soap 1.1 to make it compatible with .Net 1.1.
For more details on different scenarios and the range of wcf configuration possibilities, try exploring this CodePlex Link, specifically the Application Scenarios section that provides details of different setups. I believe that you will require a basicHttpBinding rather than a netTcpBinding in order to work with legacy protocols. The netTCPBinding would assume that you have .NET 3.0 at both ends. See this MSDN Bindings Link.