This is the second article in the introductory teaching of Windows Azure AppFabric, which can be said to be a formal beginning to learn appfabric. For subsequent learning to proceed smoothly make sure that you have browsed through the first article of this tutorial, and that you have completed the creation of the AppFabric project and namespace in this article. As we know, APPFABIRC is made up of service bus and Access Control service. This teaching with a simple echo program to all of you briefly introduce service bus, so that we can have a preliminary understanding.
The program demonstrates that the client sends a message to the service and the service responds with the same message (Echo). Shows how service bus helps communicate with different programs in different network environments.
Preconditions
For the following tutorials to work smoothly, make sure that the software or components below are installed:
· Microsoft. NET Framework 3.5 SP1
· Microsoft Visual Studio 2008 SP1 (or adjective)
· AppFabric SDK
Please make sure you have some WCF programming experience, if not, please browse here for a quick preliminary understanding of WCF.
Finally, make sure that you have created a AppFabric project and a service namespace. Please refer to here.
principle:
Let's start with how the Echo program works.
Step 1,2,4,5 is to make use of Access Control Service (ACS) services in AppFabric to ensure security, which is beyond the scope of this tutorial, and we will explain the principles and application of ACS in a later tutorial.
We are primarily concerned with steps 3 and 6 through 9. Step 3 is the process of establishing a connection between the server program and the cloud. Steps 6 through 9 to invoke the service for the client.
Service bus simplifies many communication challenges by providing a common set of naming conventions for services, providing direct or indirect communication between nodes that are independent of the network topology and configuration.
Service Bus allows a WCF application to listen to a public network address even if it is behind a NAT or network firewall. This feature allows applications to communicate without regard to their network structure. Using service bus eliminates the need to write and maintain complex logic and code to communicate across different networks.
Code:
After understanding the principles of communication, let's look at how the specific code is written.
Service side:
1. To create a new project in Visual Studio 2008, make sure the. NET Framework 3.5 is selected and named after the service, and Basicsample creates the console creator for the solution name.