What is the difference between an asp.net web method and a wcf service?

前端 未结 9 976
太阳男子
太阳男子 2020-11-30 19:29

I\'m new to .Net and do not understand the difference. Can someone point me in the right direction?

相关标签:
9条回答
  • 2020-11-30 20:01

    it is quite easy to know the differences.

    ASP.NET Web Method is called ASMX [because of the file extension] (check 4GuysFromRolla about this, they have a good tutorial)

    That technology makes you expose functions as a Web Service so you can connect it from everywhere and use it. But... you can't protect the data between server and client, you can send big files clear and know what happend, etc...

    [Note] you can protect the access to the web service using certificates, but it is complicated but normally, in ASMX we use username / passsword.

    in WCF, you are in the different world about Web Services,and this s the best technology in .NET to expose Services (can you see the difference... Services! not Web Services), WCF does not need IIS to run, it can run as a System Service on the server, using a console ambient (like command line), etc, so we say that WCF is a Service not Web Service. Remember ASMX need IIS to run.

    with WCF you can use SSL to encrypt the communication (to do that in ASMX you need to use WSE - Web Services Enhancements), you can send big files and securely (to do that in ASMX you need to use MTOM - Message Transmission Optimization Mechanism).

    you can set the transmission preferences just changing one line of code, the security is much higher, etc, etc :)

    hope you get a better general overview with this, but there is much more.

    bottom line: to expose Web Services that you do not need to protect, you can use ASMX, no problem at all, but if you need to protect the communication somehow, do it in WCF!

    link: you can read here some performance comparative between the 2 services

    0 讨论(0)
  • 2020-11-30 20:04

    Main Differences between Web service and WCF are listed below.

    Web Service : Web Service is an application that is designed to interact directly with other applications over the internet.

    1) [WebService] and [WebMethod] attributes defines a web service and methods.
    2) It Can be accessed only over HTTP.
    3) Hosted in IIS.
    4) Support security services.
    5) Can not be multithreaded.
    6) Only Used Soap or XML.
    7) System.Xml.serialization name space is used for serialization

    WCF :Windows Communication Foundation (Code named Indigo) is a programming platform and runtime system for building, configuring and deploying network-distributed services.

    1) [ServiceContract] and [OperationContract] attributes defines a web service and methods.
    2) Accessed through HTTP, TCP, MSMQ, P2P, Named pipes
    3) Hosted in IIS, Self-Hosting ,WAS and Windows Service.
    4) Can be multithreaded via service behavior class.
    5) System.Runtime.Serialization namespace is used for serialization
    6) Supports different type of bindings like BasicHttpBinding, WSHttpBinding,WSDualHttpBinding etc.
    7) Support security services, reliable messaging, transactions, AJAX and REST Support

    0 讨论(0)
  • 2020-11-30 20:13

    Here's a new, big, difference: Microsoft now considers ASMX web services to be "legacy" technology. See "XML Web Services Created Using ASP.NET and XML Web Service Clients".

    0 讨论(0)
提交回复
热议问题