Interface WebServiceClientFactory


public interface WebServiceClientFactory
A factory that can create WebServiceClient objects.
Since:
2.4.0
  • Method Details

    • create

      WebServiceClient create(URI uri)
      Creates a WebServiceClient from a URI.

      Uses the URI.getHost(), URI.getPort() and URI.getPath() when creating the client. If an alternative port should be used, then one of the overloaded methods that takes a HttpClient should be used. The create(HttpClient) is useful when the port should be the default one of the HttpClient.getScheme(), namely 80 for HTTP and 443 for HTTPS. Using one of these overloads also allows the admin to configure the forwarding proxy and trust anchors (i.e., which Certificate Authorities) should be trusted when authenticating the SSL server.

      Parameters:
      uri - the URI, which for all practical purposes will be an absolute URL, where the request will be made to
      Returns:
      a WebServiceClient that can communicate with the given URI using the default SSL context (including trust anchors) and no forwarding proxy
      Since:
      3.0.0
    • create

      WebServiceClient create(HttpClient httpClient)
      Creates a WebServiceClient from an HttpClient.

      This overload allows an administrator to configure the HTTP client for use within their environment. These are settings such as:

      • The scheme (HTTP or HTTPS),
      • Authentication method,
      • Client SSL key, and
      • Trusted SSL servers.

      When this method or create(HttpClient, int) is used, the hostname will not be set (unlike when the create(URI) method is used and the hostname is gleaned from the URI). For this reason, it almost certainly required to call WebServiceClient.withHost(String) after creating the WebServiceClient, as in this example:

       WebServiceClient client = webServiceClientFactory.create(httpClient);
       client.withHost("api.example.com");
       
       

      The HttpClient can be obtained in a RequestHandler by adding such an object as a constructor argument. This will cause an object of that type to be injected into the class when it is instantiated. Alternatively, it can be obtained by adding a getter of that type to a PluginDescriptor of some kind (e.g., an AuthenticatorPluginDescriptor.

      Parameters:
      httpClient - the HttpClient that should be used when making web service calls
      Returns:
      a WebServiceClient that can communicate with a service using the given HttpClient
      Since:
      3.0.0
    • create

      WebServiceClient create(HttpClient httpClient, int port)
      Creates a WebServiceClient from a HttpClient and port
      Parameters:
      httpClient - the HttpClient that should be used when making web service calls to a service with the given port
      port - the port on which the web service is listening
      Returns:
      a WebServiceClient that can communicate with a service listening on the given port using the provided HttpClient
      Since:
      3.0.0
      See Also: