Use WS-Addressing protocol in axis2

Source: Internet
Author: User
Author: Dai fengjun, Tsinghua University

WS-Addressing Protocol
 
It consists of three parts: one is the endpointreference definition, which is actually a model that defines a server endpoint. SecondMapAttributeThe definition, that is, the relevant attributes that need to be set and supported for message addressing. The third is the Protocol binding method, that is, how to bind the protocol to the existing protocol implementation, such as WSDL and soap.
 
It is mainly used to solve the following problems: first, it achieves isolation from the underlying transmission. by placing the addressing information in the SOAP header, the dependency on the underlying protocol addressing is eliminated. The second is to implement message-based routing. You can implement message-based Routing Based on the replyto attribute. The third is to implement stateful sessions. Based on the messageid and relatesto attributes, the session status is saved to provide stateful services.
 
The following compares the implementation of WS-Addressing between axis2 and cxf based on the above content.
I, Axis2 Support: Supported versions: Submission (2004.8) and final (2005.8.
 
Endpointreferance is a core concept in axis2, which is implemented through the endpointreference type. The method provided by endpointreferance fully supports operations on all elements in the infoset defined by the WS-Addressing protocol. In axis2, all service positioning is based on endpointreferance.
 
The attributes defined by MDP and corresponding operation interfaces are implemented.
 
WSDL addressing-binding is not explicitly supported in the current version, but it is displayed in a development member's email that it is currently ready to provide support, but no corresponding modules have been released. Soap-binding is fully supported in the axis2 kernel. The addresing module must be explicitly introduced before processing. In fact, the corresponding processing options are only enabled in the input and output streams.
 
 
 
Usage:
 
1. Server:
 
By default, the addressing processing on the server is embedded. To add the addressing module, you need to put the addressing. Mar module under the Module Directory. The following methods can be used:
First, add <module ref = "Addressing"/> In the axis2.xml configuration file and add addressingbaseddispatcher to the corresponding pipelines, such as in flow and in faultflow. (Note: in axis2, corresponding content is added by default)
 
Second, the corresponding addressing module of engage in the management console. Add the following module references to the axis2.xml configuration file <module ref = "Addressing"/>
 
2. Client:
 
There are two ways to add the addressing processing module to the customer's end:
 
FirstProgram. (Note that you need to put addressing. Mar in an accessible path)
 
Stub. _ getserviceclient (). engagemodule (New
 
Javax. xml. namespace. QNAME (Org. Apache. axis2.constants. module_addressing ));
 
 
Second, add the following module references to the axis2.xml configuration file <module ref = "Addressing"/> (you need to create the corresponding configurationcontexst)
 
 
 
Other Instructions:
 
When locating a service in axis2, locate the service based on the following four information: HTTP request URI, soapaction, QNAME of the first child of soap Body element, WS-Addressing is enabled the address of to EPR. The above is the default order. You can change the order by changing the configuration file. When addressing is enabled, the relevant content of the SOAP header will automatically overwrite the duplicate content.
 
 
 
In axis2, addressing properties is set automatically through messagecontext. You can set the corresponding option Information in messagecontext. On the server side, addressingbaseddispatcher fills in messagecontext Based on the attribute information obtained in the message header, including from, replyto, and messagid, the above information is automatically added to the return header based on the information returned.
 
You can add serviceclient in either of the following ways:
Options = new options ();
 
Options. setto (NewEndpointreference ("http://address-to-webservice.org/MyService/MyOperation "));
 
Serviceclient sender = new serviceclient ();
 
Sender. setoptions (options );
 
 
In this way, when the addressing processing module is embedded, the corresponding to information is automatically added to the header, and the messageid is automatically generated internally to ensure that it will not be repeated. By default, the message header only includes destination URL (to address) and action. Other optional parameters are not added. If you need to add them, you can add the following statements to provide support. Options. setproperty (include_optional_headers, Boolean. True );
 
TestCodeNote:
1. Test environment: Axis2 2.1.1Tomcat 6.0. Eclipse 3.2. 2. Basetest Purpose: L Test the independence of the underlying protocol, including TCP , HTTP And Local . L Test the support for synchronous and asynchronous calls. L Test support for single and dual channels. Test procedure description: Server Myservice2.aar . Place Catalina_home/webapps/axis2/service Is Web Service. Only one Echo Method. The client includes a test master program. Basetest And a small tool class Clientutil . Basetest Select the transmission protocol, call method (synchronous or asynchronous), and whether to enable a separate listening port based on user input. Clientutil Is a helper class used to generate Omelement Object. Used Endpointreference Attribute settings and Addresing . Test results: all pass. 3. Routingtest. Purpose: L Test Based on Soap The routing function of the header information. L Test Messageid Is it possible to achieve stateful interaction. L Test Out_only And In_out Operation. L Test the server configuration. Test procedure description: The Server includes two services: Postoffice. AAR And Publisher. AAR . It is used to simulate the post office subscription service and the Mail Order Service of the publishing house respectively. The client is Routingtest. Java . It mainly provides two operations. One is to send a subscription request to the post office, which is one-way and does not need to be replied, because the post office may need to wait for the publishing house to confirm whether the book exists. Second, the reader queries the post office about his/her subscription. After receiving a message from the post office Replyto The specified address automatically forwards the message to the publisher instead of returning it to the reader. The publisher gives the corresponding subscription result information. Shows the process-based process:
 
Subscribe (messageid:)
 
Client -------------------------------------------------> postoffice
 
 
 
Getinfo (messageid: B, relatesto: NULL)
Client -----------------------------------------------ÀPostoffice
 
 
 
Printpublishinfo (messageid: C, relatesto: B)
 
Postoffice ----------------------------------------------> publisher
 
 
 
Returninfo (messageid: D, relatesto: B)
 
Publisher --------------------------------------------> Client
 
 
Note that the preceding step 4 is not implemented because you need to run a service on the client, in view of the complexity of the example. The routing method is the same as that in step 3. Therefore, only publisher prints the confirmation result. Test results. Axis2 can route the corresponding messages to other service Nodes Based on the header information to achieve completely Routing Based on the addresing header information. In addition, the Message ID can be associated while forwarding. One-way message transmission also supports good performance. You can return exception information or redirect exceptions to other nodes as needed. Tip: to view the entire message more accurately, you can use the soapmonitor tool of axis2. Open the monitoring module in the axis2 configuration file and decompress the soap_moinitor.jar file to the axis directory. InputHTTP: /localhost: 8080/axis2/soapmonitorReal-time information is displayed. Tip: run the jar package and addressing1.1.mar in axis2 on the client. Cxf Support: Supported versions: Submission (2004.8) and core 1.0 (2006.5. The endpointreference type supports WS-Addressing to define operations for all elements in infoset.
 
The property attributes defined by MDP define corresponding operation interfaces.
WSDL addressing-binding Clearly supported,
 
Soap addressing-binding is supported in cxf, but must be embedded with addresing interceptor.
 
Usage:
 
1. The server and client can use the following methods:
 
First, add the following content to the configuration file to add addressing Interceptor to the bus.
  <Cxf: Bus> <Cxf: features> <WSA: Addressing/> </Cxf: features>
 
</Cxf: Bus>,
 
The second is to add
 
Third, add
 
Let's talk about the example:
Test results: It provides better asynchronous support, but the current automatic association of routes and messageid fails. Cause .... Currently, only soap1.1 is supported, while axis2 supports soap1.1 and soap1.2.

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.