Post an advertisement: If you want to exercise together on weekends, contact me. You 'd better stay near Huilongguan or the West three flag. You can play basketball, table tennis, or swimming together. Contact me: MSN: jillzhang@126.com QQ: 183317744 |
PreviousArticleWSe has a routing function. It can dynamically route soap messages to a specified destination like a router. For more information about the routing function of WSE, see:WSe 1, 3.0Document Translation:Routing.
The following describes how to implement WSE routing and some details in project development through project instances. I am at a limited level. If something is wrong, please kindly advise me.
Before starting a project, let's take a look at the concept of routing. The so-called "routing" refers to the behavior and action that transfers data from one place to another. It usually includes two actions: select the optimal path and exchange data through the network. The router we usually use is the machine generated for this function. So why does WSE have the routing function? This must be the first thing we need to understand.
If you do not know SOA or have no development or O & M experience, you may not be able to understand why WSE has the routing function. On the surface, it is completely unnecessary! The client specifies a server, and both parties can exchange data! Also, in SOA, there are usually system collaboration problems between departments, between enterprises, and between organizations. If the provider has a repair problem, it will affect many clients, and these clients may be distributed in different individuals or organizations. Some coordination and communication problems in the middle will soon bring you into hell, some client systems have extremely high requirements on system stability. Therefore, if the server does not make any manual changes, you should do your best to keep the client running normally. The routing function of WSE is one of the solutions to solve such problems. In one sentence, it enables the server to modify the original route of the SOAP message through simple configuration during service maintenance, so as to ensure stable operation of the client.
To implement the routing function of WSE, there are two methods: first, through the configuration file, this configuration file is called referral cache in the WSE framework. the other is implemented based on the SOAP message content. This article first addresses how to implement WSE routing through the configuration file.
- Implement WSE routing through Configuration
To implement WSE routing, two major steps are required:
- Prepare a Routing Server (which we call it r later) and configure it.
- Configure a referral cache, which defines the routing information of the SOAP message.
We use the following scenario to demonstrate the project: currently, we have a service on the server S1, because the route has no impact on the client, so we only simulate one client, the server is C, shows the current route information:
First, let's take a look at the network services, routes, and clients that use routing.Program.
Network Service: the network service that uses the route must accept requests from the Routing Server R. Therefore, you must specify the soapactor attribute of the network service to be the URL of the route or accept all sources. Soapactor is described as follows: a SOAP message may pass through a series of soap intermediate nodes along the message path from the Start Node to the end node. A soap intermediate node is an application that can receive and forward soap messages. The middle node and the end node are differentiated by Uris. It is possible that the end node of the SOAP message does not need all parts, but one or several intermediate nodes on the message path may need the content. The role played by the receiver of the Header element is similar to a filter, preventing the portion of the messages sent to the receiver from spreading to other nodes. That is, the receiver of A Header element must not forward these header elements to the next application in the soap message path. Similarly, the receiver may insert a similar Header element. The soap actor global attribute can be used to indicate the receiver of the Header element. The value of the soap actor attribute is a URI. The soap actor attribute is omitted, indicating that the receiver is the end node of the SOAP message.
Note the following when creating and designing network services:
Except here, the network service is no different from other services that use wse3.0.
Let's take a look at the routing. The routing program is a very special program. It can contain only two configuration files without any programs. Here we will mainly describe how to set these two configuration files.
- First, we first set the wse for the created route website. We can use the integration tool of WSE and vs2005. As shown in:
In this way, the reference to Microsoft. Web. services3 is added. Note that the reference section in Web. config must be similar to the following:
Because this project does not have the bin directory, of course, if you can install the SP1 Patch and add references, the bin directory will have related DLL, as shown in. I created a website here, so this is required. Without this website, you will not be able to use WSE, so you will not be able to implement the routing function.
The following operations are also performed on the routing website. config adds an httphandler to process HTTP requests. You can customize httphandler or use Microsoft. web. services3.messaging. soaphttprouter:
Click OK.
After the above operation, the following content will be added in Web. config:Code:
You can also add them manually.
- Create a referral cache file and write the route configuration in it as follows:
The following describes the significance of each node:
<R: Referrals> A node is a root node. There is only one configuration file.
<R: ref> A node is used to identify a specific route configuration. In a configuration file, it can be either dispensable or multiple
<R: For> A node is used to indicate part of the source message.
<R: exact> A node is used to specify the details of a source information. A <R: For> node must contain either <R: exact> or <R: prefix>
<R: If> the node specifies the routing condition. One <R: For> must have one <R: If>
<R: Go> some information about the redirection indicated by the node, one <R: ref> and the other <R: Go>
<R: via> the node indicates the URL to which the message is redirected. One <R: Go> must be at least one <R: via>.
<R: refID> the node indicates the unique identifier of the route configuration.
After configuring referral cache, you need to make the following settings:
Click OK to add the following code in Web. config:
When deploying a route site, be sure to set file write permissions for the referral cache to the network user (Network Service in iis6.0 )..
There is no difference between the client and other clients, but the sending Address of the message is set as the routing address. The settings are as follows:
In this case, start the client program and the result is as shown in:
It indicates that the three parts shown in the first figure are working properly.
The following describes the advantages of routing. When the server S1 running the network needs to be repaired or the system needs to be upgraded, we can perform the following steps:
Step 1: Prepare a backup server S2, deploy the same environment on S2 and S1, and deploy network service programs.
Step 2: Prepare another referral cache configuration file and change the information in <R: Go> to the URL address of the service on S2.
Part 3: replace the referral cache on the route Server R with the new referral cache file
After these three steps, the client can have no changes or influences. The message can be sent as usual, but the actual receiver has changed to S2.
Run the client and we have the expected results.
Limited by conditions, this article simulates the client, route, and server on a machine. To download to a local program, you need to change the URL to run it.
You can also implement this function by modifying the SOAP message content, which will be further elaborated in the next article.
Project Example:Project File