Class HttpDestinationPolicies

java.lang.Object
org.springframework.ws.transport.http.HttpDestinationPolicies

public abstract class HttpDestinationPolicies extends Object
DestinationPolicy implementations for HTTP destinations.

A policy is required for a sender to accept a remote destination, such as a WS-Addressing ReplyTo or FaultTo address:

HttpUrlConnectionMessageSender sender = new HttpUrlConnectionMessageSender();
sender.setDestinationPolicy(HttpDestinationPolicies.allowedHosts("replies.partner.example.com"));

Note: a policy sees the destination that the sender is about to connect to, and nothing beyond it. HTTP clients that follow redirects can still be steered to another host by an allowed destination, so accept only destinations that are trusted not to redirect elsewhere, or configure the underlying client that the AbstractHttpWebServiceMessageSender implementation uses to not follow redirects.

Since:
3.1.10
  • Constructor Details

    • HttpDestinationPolicies

      public HttpDestinationPolicies()
  • Method Details

    • allowedHosts

      Return a policy that accepts a remote destination only if its host is one of the given hosts, and accepts any application-supplied destination.
      Parameters:
      hosts - the host names or IPv4 literals to accept
      Returns:
      a policy accepting only those hosts for remote destinations
      See Also:
    • allowedHosts

      Return a policy that accepts a remote destination only if its host is one of the given hosts, and accepts any application-supplied destination.

      A host is compared as written, so that what is compared is what will be connected to. Each configured host must be a host name made of ASCII letters, digits, - and .. Anything else is rejected here rather than silently never matching. Use your own policy with IPv6.

      Parameters:
      hosts - the host names or IPv4 literals to accept
      Returns:
      a policy accepting only those hosts for remote destinations