Thursday, March 31, 2011

Can you call a WCF with basicHttpBinding in a .net 2.0 winforms app?

Hi,

From what I know basichttpbinding is backward compatible to .net 2.0 correct?

It seems that when you reference the WCF service, the API is different.

My service uses SSL, and it has a username and password you have to set.

In .net 2.0 the API is totally different, and having issues calling an endpoint correctly.

From stackoverflow
  • WCF services are present in the .NET 3.0 and 3.5 frameworks. While your service will be executing in the 2.0 runtime (.NET 3.0 and 3.5 are just additional layers to the 2.0 framework), as long as it serializes types that are easily understood (i.e. can be resolved to basic types like strings and integers), all is well. In fact, a Java client could call into the WCF service since at the wire level, what matters is compliance with widely accepted specifications like SOAP 1.1 for example.

    From your windows forms client, you need to create a reference to the service using wsdl.exe (or using Visual Studio's Add Web Reference wizard). As far as it knows, it looks like any ASP.NET web service.

    Now, using the basicHttpBinding is not all there is to ensure your service is compatible with non-WCF clients. You also need to be sure you're sticking to the DataContractSerializer or the XmlSerializer. You'll want to avoid the use of the NetDataContractSerializer since that requires that types be shared on both the service and the client. Not that it could not be done, but you'd have to make sure your types are in a .NET 2.0 assembly and aren't using functionality only available in 3.0 or later (e.g. System.Core).

0 comments:

Post a Comment