title: Preemptive authentication method in Apache Axis?
body: <p>I <em>sort of</em> understand that I'm using Apache Axis 1.4 for querying a web service.</p>
  
  <p>I was given a WSDL file, and that generated a <code>XXXXImplServiceLocator</code> class that extends <a href="http://ws.apache.org/axis/java/apiDocs/org/apache/axis/client/Service.html" rel="nofollow noreferrer"><code>org.apache.axis.client.Service</code></a> and implements a generated interface that extends <a href="http://docs.oracle.com/javaee/1.4/api/javax/xml/rpc/Service.html" rel="nofollow noreferrer"><code>javax.xml.rpc.Service</code></a>.</p>
  
  <p>My "bussiness code" calls the <code>getXXXXImplPort(URL)</code> method on a new <code>XXXXImplServiceLocator</code> instance, and then calls:</p>
  
  <pre><code>((Stub) port).setTimeout(timeout);
  ((Stub) port).setUsername(username);
  ((Stub) port).setPassword(password);
  </code></pre>
  
  <p><code>Stub</code> is <a href="http://ws.apache.org/axis/java/apiDocs/org/apache/axis/client/Stub.html" rel="nofollow noreferrer"><code>org.apache.axis.client.Stub</code></a>.</p>
  
  <p>After setting those parameters, I simply call some <code>getYYY()</code> method, that represents the query to one of the services exposed by the remote service and gives me back a "domain" object with the results.</p>
  
  <p><strong>The problem</strong> is that I have to use preemptive authentication with this service. I've tried querying via soapUI, and I won't have any result unless I set the preemptive authentication mode.</p>
  
  <p>I've tried googling how to set that mode, but found nothing. All they say about is <a href="https://stackoverflow.com/questions/2014700/preemptive-basic-authentication-with-apache-httpclient-4">Preemptive authentication with Apache HttpClient</a>, that can be very well "embedded" or used by Axis, but I really didn't see how to mix this.</p>
  
  <p>The only code I have that interacts with this <code>ServiceLocator</code> is the initial setup, and then just queries.</p>
  
  <p><strong>How can I set that preemptive authentication mode?</strong> Am I missing something? What am I not understanding so that I can't solve this issue?</p>
  
  <p>Smells like a pretty trivial problem, but maybe the fact I don't understand this very well prevents me from solving the issue.</p>
  
  <p>Thanks in advance, yeah :)</p>