title: JerseyClient using DefaultHttpClient
body: <p>I need to access a JAX-WS webservice protected by SSL using Jersey Client. I have successfully got this working with limited configuration and just letting the Client use the default HTTPURLConnection API. </p>
  
  <p>This approach wont work however for my overall solution because it does not allow me the flexibility to change the credentials used when making a request to the WS. I'm trying to use DefaultHTTPClient instead and then passing it to the Client object on intialization. </p>
  
  <pre><code>NTCredentials credentials = new NTCredentials("username", "password",
      computerName, domainName);
  DefaultHttpClient httpClienttemp = new DefaultHttpClient();
  DefaultHttpClient httpClient = wrapClient(httpClienttemp);
  httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, credentials );
  ClientConfig config = new DefaultClientConfig();
  </code></pre>
  
  <p>The wrapClient method creates an X509TrustManager and overrides the necessary methods so that all certificates are accepted. It also creates a SchemeRegistry entry for https access on port 443. This configuration results in a Connection refused exception.</p>
  
  <p>The strange thing is, if i add an additional entry in the SchemeRegistry for http and give it a port of 443 then the request does get sent however a Connection Reset exception then gets thrown. </p>
  
  <p>The Url i use to create the WebResource object is https however the SOAPAction i declare in the header uses http. Any ideas where im going wrong?</p>