Java WS-Addressing: A Comprehensive Guide

Author: Tatyana Milkina

About WS-Addressing

WS-Addressing specification gives an interoperable way of communicating between senders and receivers by providing a transport-neutral mechanism to address Web services and messages.

Primary concepts of WS-Addressing:

  • Endpoint References give a mechanism to encapsulate information about endpoints. Endpoint references can be propagated to other parties and then used to target the Web service endpoint they represent.
  • Message addressing properties (MAPs) are a set of well-defined WS-Addressing properties that can be represented as elements in SOAP headers and provide a standard way of conveying information, such as the endpoint to which to direct message replies or information about the relationship that the message has with other messages.

To enable WS-Addressing to configure policy sets or use annotations in code.

Next tasks can be performed by using JAX-WS 2.1 annotations and feature classes:

  • It is possible to enable WS-Addressing on the server or the client.
  • Have more control over the behavior of WS-Addressing when using policy sets.
  • Specify whether WS-Addressing is enabled and whether to use synchronous or asynchronous messaging patterns.
  • Specify actions to be associated with a Web service operation or fault response.

Example of Using @Addressing with @Action.

@WebService()
@Addressing(enabled = true, required = true)
public class ExamWS {
@WebMethod(operationName = "addExam")
    @Action(
        input="http://addExam.com/input",
        output="http://addExam.com/output")
    public String addExam(@WebParam(name = "name1") String name1, @WebParam(name = "name2") String name2) {
        return name1 + name2;
    }
}
Комментарии