views:

3362

answers:

4

I create a service that is host on a server that have .Net 3.5 installed and I need to call this service from a client that only have .Net 2.0 installed

Is there a way I can do this ?

I'm using c#

+1  A: 

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!

But calling that service from a .NET 2.0 client is ABSOLUTELY no problem!

Marc

marc_s
that's not 100% true. Much depends on the web service protocol.
Randolpho
yes, of course - the protocols and security settings etc. must match - but the fact the client is .NET 2.0 and the service is .NET 3.5 does NOT present any problem.
marc_s
The thing is, .NET 2.0 libraries don't support the default protocols supported by WCF -- in many cases they didn't exist or weren't finalized when .NET 2.0 came out. So it's not "absolutely no problem" at all; it's a *huge* problem.
Randolpho
i think that the point being made here is that you can configure a compiled WCF assembly to be accessible from 2.0 without re-compiling it with different settings (in the case presented, by changing the Web.config / App.config of the hosting application)
Eugarps
+3  A: 

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".

John Saunders
.NET 2.0 doesn't contain anything that can consume net.tcp or wsHttp, other than WSE, which is a worse cure than the disease.
John Saunders
ah, true...... WCF came with .NET 3.0 - keep forgetting that!
marc_s
So, what kind of binding should I use, for now I use wsHttp and it's doesn't seem to work at all
Melursus
basicHttpBinding.
John Saunders
Ok, I currently tring it but I got this error : The request failed with HTTP status 415: Cannot process the message because the content type 'application/soap+xml; charset=utf-8; action="http://tempuri.org/MyService/MyMethod"' was not the expected type 'text/xml; charset=utf-8'.. any idea ?
Melursus
Forget my last comment, I fix it (refresh my web references ...) thx for all!
Melursus
+2  A: 

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.

Randolpho
A: 

In theory Marc is correct. Web services are supposed to be independent of the client however Microsoft web services are not TRUE web services. They are proprietary web services which are only compatible with .Net and with the specific version the service is written in. Not all clients can consume a Microsoft web service. They are only dll's in a different wrapper.

Clem
-1: this is utter nonsense. Please substantiate this falsehood.
John Saunders