By doing the project, there is a whole new understanding of WCF. So what's the difference between him and webservice, and which one of them is better? It should be the benefits of each.
What is WCF?
. NET platform, a series of application frameworks that support data communication developed by Microsoft are the best practices for developing distributed applications on the Windows platform.
In short, it is a distributed programming framework for building service-oriented applications that enables developers to build enterprise-class, connected application solutions that are cross-platform, secure, reliable, and support transactional processing.
The basic concept of WCF is to define a contract to communicate the agreement between the two parties, the contract must be represented by the interface, the actual service code must be derived and implemented by these contract interfaces.
Architecture for WCF:
Contract: A contract is part of a service disclosure interface, a service contract that defines the methods exposed by the server, the transport protocol used, the message format that can be accessed by the address, and so on.
Service run: The service run aspect defines the specific behavior of the service at run time.
Message: The message aspect contains the way the message is transmitted, the encoding and decoding of the message. The content of the message basically belongs to the concrete implementation within the service boundary. The specific delivery implementation must conform to the binding protocol defined in the contract.
Activation and hosting: A WCF service needs to be hosted in a running program, often including self-hosted, IIS hosted, was, Windows services, COM + components, and so on.
ServiceContract: Includes ServiceContract and operationcontract,servicecontract for classes or structs, to indicate that WCF such or struct can be called remotely OperationContract is used on a method in a class to indicate that WCF can be called remotely by this method.
<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" >[SERVICECONTRACT] public interface Ibasicorganizationservice { #region queryallorganization-Agency information Inquiry-Olivia Zhao-May 19, 2015 20:17:28 [OperationContract] list< Basicorganizationviewmodel> queryallorganization (); #endregion #endregion }</span>
DataContract: Divided into DataContract and datamember,datacontract for class or structure, indicating that WCF such or struct can be serialized or transmitted, or can be used instead of [seralizable] DataMember can only be used on properties or fields of a class or struct to instruct WCF that the property or field can be serialized for transmission.
<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" >[classes ("title")] [DataContract] public class Basicjobviewmodel { [Colum ("Job Code", DbType = dbtype.string)] [DataMember] [DisplayName ("Code")] public String JobCode {get; set;} } </span>
Faultcontract: Error contract, by default, the exception that is thrown by the service is passed to the client by the FaultException type, which lists the types of errors that the service can throw.
MessageContract: A message contract that can customize the message format, including the message header, the body of the message, and whether to encrypt and sign the contents of the message.
What is WebService?
Platform-independent, low-coupling, self-contained, programmable web-based applications that use Open XML standards to describe, publish, orchestrate, and configure these applications for the development of distributed, interoperable applications.
In short: access to and use of remote Web Services provides access to data in different systems. When used, a Web Service Web application can not only share data, but also invoke data generated by other applications, regardless of how other applications generate the data.
Features: openness, cross-platform; Returns data instead of returning a page.
Summary: The use of Web Services enables data reuse and software reuse, which facilitates the establishment of a loosely coupled distributed system, the implementation of Web Services requires HTTP, SMTP, SOAP, WSDL and UDDI protocols such as support; building a WCF service requires a service definition file, Service interface files and service logic processing files. When using a WCF service, you need to first add a service reference and then apply it to a Web form
than a WebService and WCF