Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
681 views
in Technique[技术] by (71.8m points)

asp.net - what is difference with WCF and other web services?

I'm confused with WCF and other web services (such as asp.net ASMX,.net Remoting),can anybody tell me what is difference with WCF and the others and when should I use it, thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

WCF is a communication stack that allows services to be exposed over HTTP (like ASMX) and TCP (like Remoting) as well as Named Pipes (which is really an intra-machine cross process call), MSMQ and with .NET 3.5 REST.

It allows this because it's decoupled the communcation parts of the service away from the business logic. All you need to do is decorate your service classes, methods and DTO's with the appropriate contract attribute ([SeriviceContract], [OperationContract] and [DataContract] respectivly.)

This had the benefit of being able to write a service once, and allowing many different kinds of clients to consume the same service (i.e. Java clients can use HTTP, .NET clients can use TCP, legacy can use MSMQ, etc.).

WCF will still allow you do use all the features of each transport, including security, transactions, reliable messaging, etc., but you need to use some care. Not all features work on all transports, and you need to design accordingly. WCF allows you to specify in your contract which features are required. This prevents somone from trying to expose your service in a way that does not support the required feature set (i.e. if your service requires transactions, the WCF runtime will not allow the service to be accessed via a basic HTTP endpoint).

WCF is also extensible via custom behaviors (which influence how the WCF runtime works) and custom channels (which control how WCF services communicate with the outside world.)

WCF has a bit of a learning curve compared to ASMX, but the benefits ABSOLUTLY out weight this learning curve.

Hope that helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...