WCF4.0 advanced series Chapter 1 Introduction to WCF

Source: Internet
Author: User

 

  Chapter 1 Introduction to WCF

 1. What is WCF?

If you read this book to learn how to use WCF to build distributed applications and services, what is WCF and how to use it? How to use it? To answer these questions, let's review the past.

(1) Early Personal Computer Applications
In the PC era, commercial solutions are combined by a set of applications. Generally, it includes a text processing program, a workbook processing program, and a database suite. Experienced users can store business data in databases, use workbooks to analyze data, create data-based reports and documents, or use text processing software to write analysis reports. These programs are often installed on the same computer, and their data and file formats are only owned by them. This is a typical desktop application platform. It features only for a single user and only handles multiple tasks in a very small scope.
As personal computers become cheaper and widely used as commercial tools, the challenge for applications is how to share data among multiple users. It is not a new challenge, because multi-user databases have been available for a while, but multi-user databases run on large computers rather than personal computers. Soon, network-based solutions and network operating systems appeared on the personal computer platform, connecting computers within an organization's departments to the network and sharing their resources. In addition, database vendors quickly develop database management software independent from the mainframe, which can run on personal computers on the network, people can use these software or solutions to conveniently share business data;

(2) inter-process communication technology
The network platform is only part of the story. Although network-based solutions allow PCs to communicate with each other, share printers and disks, programs also need to send data, accept data, and interoperate with programs running on other PCs at the same time. Many common inter-process communication mechanisms are gradually available, such as named pipes and sockets. These technologies were underutilized at the time, because to master them, you must have a good understanding of the network. This situation is still the same today. For example, the job of creating an application for receiving and sending data using socket is still a challenging job. On the surface, the process is quite simple, but parallel access is quite complicated. As computers and networks evolve, the types and capabilities of inter-process communication also change. For example, Microsoft developed the COM technology to communicate with each other between applications and components on the Windows platform. Developers can use COM to create reusable software components, link multiple components to build programs, and use Windows Services. Microsoft also uses COM technology to make its programs as service components to build various solutions.
Microsoft initially designed COM to solve the communication between applications and components on the same computer. Later, Microsoft launched DCOM, also known as Distributed COM, which allows applications to access components on other computers in the network. After that, DCOM developed into COM +. COM + contains many features, such as integration with Microsoft Distributed Server, allowing the program to put some operations in a group and use the group operations to communicate with each other in transaction mode. COM + also has the ability to automatically manage resources (for example, if you use a component to connect to the database, you can ensure that the component will automatically link to the data connection after the program uses the component) and asynchronous operations. COM + was later replaced by. NET Framework .. NET Framework not only extends COM +, but also provides many new features (Remoting: allows client applications to access objects on remote servers in the same way as accessing local objects ). Microsoft named this technology enterprise service.

(3) Web and Web Services
COM, DCOM, COM +, enterprise service, and. NET Framework Remoting run very well on the LAN, and they all run on Windows operating systems.
Then, when Microsoft launched COM and DCOM, the World Wide Web emerged. The World Wide Web is based on the Internet and has been developing for decades. The World Wide Web provides an architecture that developers use to build applications using components and other elements located around the world, and these applications can run under different computer systems. The first generation of web applications is very simple and only composed of some static web pages. Users can download and view these pages using a web browser on a local computer. The second generation of web applications provides developers with some programmable elements (components or plug-ins). Users can download them from the web site and run the results on the browser of the local computer. The third generation launched web services. A Web Service is an application or component that runs on the server. The Web Service can receive requests from client programs, run on the server side, and then return the results to the client sending the request. The Web service can also access another Web Service on the Internet. This is a global distributed program.
You can use visual studio and. NET Framework to create Windows-based web Services. Of course, you can also use other technologies to create web services running on non-Windows platforms. Although web services do not limit a language or platform. To create a distributed, global web service, developers must follow some principles, including the data format, protocol for sending and receiving messages, and secure processing methods. These features are irrelevant to the platform.

(4) using XML as a common data format
Different computers can use their internal representations to store the same value. For example, the top 32 is the processor and the top 32 is the processor. They use different data formats, but can store the same value. Therefore, to ensure that the same program shares data on different computers, developers must adopt a data storage format unrelated to the computer system. In short, xml is a widely accepted data storage format. Xml is a text-based, easy-to-read, and simple markup language that describes various types of data.

Person
Without effort, you can guess the real meaning of the data in seconds. A program that needs to send information can use this format to send the Person information to another program. The receiver can accept the Person information and convert it into meaningful data. Of course, the preceding data format can also be changed to the following:
JSON
There are many other possible format changes. How does an application know that its format can be correctly recognized by other programs? The answer is that both programs adopt the same layout. The layout is xml schema. Xml schema is used to describe the structure of an xml document. The sender uses it to describe the structure of the sent information. The receiver uses it to convert the received information into meaningful data.

(5) accept and send Web Service requests
By formatting data using xml and xml schema, the web service and client can clearly send data back and forth, provided that the client and the web server must adopt a unified protocol for sending and receiving requests. In addition, the client makes it clear that the messages sent by itself correspond to the messages returned from the web server.
In short, web Services and client programs communicate through the SOAP protocol. The SOAP Protocol defines the following aspects:

SOAP message format
How to encode Input
How to send messages
How to process returned messages
The Web Service can publish the WSDL document, which is an xml document that describes the acceptable messages of the web service and how to respond to the messages transmitted by the client. The client program can use this information to determine how to communicate with the service.

(6) JavaScript Object and RIA
The XML/SOAP model is used to define and disseminate formats of interchangeable messages, which is easy to understand. However, in some cases, this model is complex. Because this model produces a lot of redundancy, when it is used to transmit and accept data is relatively small. The popular RIA is a typical example.
RIA is a network application system similar to traditional desktop application software systems, but it actually interacts with remote servers through web browsers. To provide desktop interaction functions, RIA uses JavaScript and AJAX. Many vendors provide the corresponding architecture, such as Microsoft's Silverlight. Using Silverlight, developers can easily implement RIA.
Although XML is part of AJAX technology, lightweight native JavaScript formats are used to represent objects and transfer between users' networks. This format is JSON. Although its name is related to JavaScript, JSON is actually a language-independent format. Most programmers can understand it at a glance. JSON describes data by name/value. For example: {"forename": "John", "surname": "Sharp", "Age": 46 }.
You can directly read and write JSON data using code. However, most development heat sources prefer to use the JSON converter to automatically convert data in other formats to JSON, especially when the source data structure is very complex. Most modern languages provide JSON converters to create distributed applications, such as WCF.
The difference between JSON and XML lies in the fact that XML is a complete syntax, whereas JSON is not. This makes XML much more effort in program interpretation. The main reason is that the design philosophy of XML is different from that of JSON. XML uses the feature of tag Meta to provide excellent scalability, while JSON focuses on data exchange.

(7) Security and Privacy processing in a global environment
Security is used to identify users and services and authorize them to access corresponding resources. In a distributed environment, security is very important.

Related Article

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.