WCF Learning Journey-WCF Overview (iv)

Source: Internet
Author: User
Tags msmq

First, WCF Overview

1) What is WCF?

Windows Communication Foundation (WCF) is the framework for building service-oriented applications. With WCF, you can send data as an asynchronous message from one service endpoint to another service endpoint. A service endpoint can be part of a continuously available service that is hosted by IIS, or it can be a service hosted in an application. An endpoint can be a service client that requests data from a service endpoint. A simple message can be a single character or a single word that is sent as XML, and a complex message can be a binary data stream. Some sample scenarios include:

    • A security service that handles enterprise transactions.
    • A service that provides current data to other services, such as traffic reports or other monitoring services.
    • A chat service that enables two of people to communicate or exchange data in real time.
    • A panel application that polls one or more services to find data and display it in a logical representation.
    • Workflows that are implemented using Windows Workflow Foundation are exposed as WCF services.
    • A Silverlight application that polls the service to find the latest data source.

Although this type of application can be created before WCF exists, WCF makes the endpoint development easier than ever. Integration of the communication technology produced in Windows, including the. NET Remoting,webservice,socket mechanism, and the integration of HTTP and FTP-related technologies. is the best technology for developing distributed applications on the Windows platform. In summary, WCF design provides a manageable way to create Web services and Web service clients.

2) WCF includes the following feature sets.

    • Service Orientation

One result of using the WS standard is that WCF allows you to create service-oriented applications. A service-oriented architecture (SOA) relies on WEB services to send and receive data. These services have the general advantage of loose coupling rather than hard-coding from one application to another. A loosely coupled relationship means that any client created on any platform can connect to all services as long as the underlying contract is met.

    • Interoperability

WCF implements the modern industry standard for WEB service interoperability.

    • Multiple message modes

Exchange messages with one of several modes. The most common pattern is the request/reply pattern, where one endpoint requests data from another endpoint and the other endpoint responds. There are other patterns, such as one-way messages, where only one endpoint sends a message, rather than expecting a reply. The more complex pattern is the duplex switching mode, in which two endpoints establish a connection and send data back and forth, similar to an instant messaging program.

    • Service Meta Data

WCF supports Publishing Service metadata using the format specified in industry standards such as WSDL, XML schemas, and Ws-policy. This metadata can be used to automatically generate and configure the client to access the WCF service. You can publish metadata over HTTP and HTTPS, or you can use the WEB service metadata Exchange standard to publish metadata.

    • Data contract

Because WCF is built using the. NET Framework, it also includes a code-friendly method for providing contracts that you want to enforce. A data contract is one of the common types of contracts. Essentially, when you encode a service by using Visual C # or Visual Basic, the simplest way to work with data is to create a class that represents that data entity using properties that belong to the data entity. WCF includes a comprehensive system that handles data in such an easy way. After you create a class that represents data, the service automatically generates metadata that enables the client to conform to the design data type.

    • Security

Messages can be encrypted to protect privacy, and users can be required to authenticate themselves before they are allowed to receive messages. Security can be achieved using well-known standards, such as SSL or ws-secureconversation.

    • Multiple transmission and encoding methods

Messages can be sent through any of several built-in transport protocols and encodings. The most common protocol and encoding is the use of Hypertext Transfer Protocol (HTTP) to send text-encoded SOAP messages for use on the World Wide Web. In addition, WCF allows messages to be sent over TCP, named Pipes, or MSMQ. These messages can be encoded as text, or they can be used in an optimized binary format. Using the MTOM standard, you can send binary data efficiently. If the transmission or encoding provided does not meet your needs, you can create your own custom transports or encodings.

    • Reliable Queued Messages

WCF supports reliable session implementation using ws-reliable Messaging and reliable message exchange using MSMQ.

    • Persistent messages

Persistent messages are never lost because of a communication outage. Messages in persistent message mode are always saved to the database. If an outage occurs, the database will allow you to resume the message exchange after the connection is resumed. In addition, you can use Windows Workflow Foundation (WWF) to create persistent messages.

    • Transaction

WCF also uses one of the three transaction models to support transactions: Ws-atomicttransactions, APIs in the System.Transactions namespace, and Microsoft distributed Transaction Coordinator.

    • AJAX and REST Support

REST is an example of a growing WEB 2.0 technology. WCF can be configured to handle "plain text" XML data that is not wrapped in a SOAP envelope. WCF can also be extended to support specific XML formats, such as ATOM (the popular RSS standard), and even non-XML formats such as JavaScript Object Notation (JSON).

    • Scalability

The WCF architecture has a large number of extensibility points. If additional functionality is required, it also provides many entry points that allow you to customize the behavior of the service. For more information about the available extension points,

3) WCF Architecture

4) similarities and differences between WCF and Web APIs

WCF is the unified programming model that Microsoft provides for building service-oriented applications. With this model, developers can build secure, reliable transactional solutions that can integrate across platforms and existing investments and interact with existing investments. The ASP. NET Web API is a framework for easily generating HTTP services that can access a wide range of clients, including browsers and mobile devices. The ASP. NET Web API is the ideal platform for building RESTful applications on the. NET Framework.

Wcf

ASP. NET Web API

Enables build services that support multiple transport protocols (HTTP, TCP, UDP, and custom transports) and allows switching between those services.

HTTP only. The first type of programming model for HTTP. More suitable for access from a variety of browsers, mobile devices, etc., to achieve a wide range of access.

Enables build services that support multiple encodings (text, MTOM, and binary) of the same message type, and allows switching between those services.

Enable the build Web API that supports a wide range of media types, including XML, JSON, and so on.

Support for build services with WS-* standards, such as reliable messaging, transactions, and message security.

Use basic protocols and formats, such as HTTP, WebSocket, SSL, JQuery, JSON, and XML. Higher-level protocols, such as messaging or transactions, are not supported.

Supports request-reply, one-way and duplex message exchange modes.

HTTP is a request/response, however, integration with SignalR and WebSocket can integrate other modes.

WCF SOAP Services can be described in WSDL to generate client proxies for services with complex schemas through automated tools.

The Web API can be described in a variety of ways, from the automatically generated HTML help page that describes the snippet to the structured metadata used for the OData integration API.

provided with the. NET Framework.

provided with the. NET Framework, but it is an open source program and can be obtained out-of-band via a standalone download.

W) Benefits of WCF

In the article "Introducing Windows Communication Foundation" written by David Chappell, a fresh example is used to illustrate the advantages of WCF. Suppose we are going to develop a new application for a car rental company to make a car hire reservation service. The car hire booking service is accessed by a variety of applications, including call center, the EE-based car hire reservation service, and the partner app (Partner application)

From a functional point of view, WCF can be seen as a asmx,.net of technologies such as the Remoting,enterprise service,wse,msmq. (Note: This statement is only from a functional point of view.) In fact, WCF is far from simple and simple to set, it is a truly service-oriented product that has changed the usual development pattern. Therefore, for the above example of the car reservation service system, WCF can be used to solve the requirements including security, trustworthiness, interoperability, cross-platform communication, etc. Developers no longer have to learn about the various technologies such as. Net remoting,asmx.

In terms of actual development, the difference between ASP-based application development and WCF-based service-oriented application development:

(1) in ASP. NET-based application development. We access the application server from the client's browser and then connect to the database server through the database connection in the application server, read or manipulate the data, and sometimes one more file server. As you can see, basically all applications are placed on a single server, but for one, it is difficult for one server to support all applications due to business needs (such as interacting with external systems). Such as.

(2) Based on WCF service-oriented application development. The client uses a browser to access server A, and server A is deployed in Servers B, C, D ... for business needs with a variety of other applications. And then communicate with each other through WCF technology, visit each other ... However, the benefits of service-oriented are not only here, but he also provides the interactivity of different operating systems in different languages. Such as.

In the previous article we created a simple WCF service application. This article will transform the WCF service application above to increase the operation of the database interaction. Next we'll step through the creation of WCF service applications.

WCF Learning Journey-WCF Overview (iv)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.