title: HTTP Basic Authentication for WEBService call
body: <p>I trying to  invoke a web service, which has an Basic HTTP Authentication. I generated the client code using the WSDL2JAVA tool from AXIS.</p>
  
  <p>But I am not able to set the username and password to the webservice call.</p>
  
  <p>I tried to have them in the endpoint url as </p>
  
  <blockquote>
    <p><a href="http://username:password@somwserver/wsdl" rel="nofollow noreferrer">http://username:password@somwserver/wsdl</a></p>
  </blockquote>
  
  <p>But I am getting the unauthorized error for this. I am trying to figure out a way to get this set to my call in the Java code....</p>
  
  <p>Note : I am able to invoke the same service via the soapUI and get the results. I provided the username and password in the "Aut" tab on the request.</p>
  
  <p>Here is some of the code snippets of my Stub, if this is userful for you </p>
  
  <pre><code>       _serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service);
  
  
      _serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(
              targetEndpoint));
      _serviceClient.getOptions().setUseSeparateListener(useSeparateListener);
  
          //adding SOAP soap_headers
       _serviceClient.addHeadersToEnvelope(env);
      // set the message context with that soap envelope
      _messageContext.setEnvelope(env);
  
      // add the message contxt to the operation client
      _operationClient.addMessageContext(_messageContext);
  
      //execute the operation client
      _operationClient.execute(true);
  </code></pre>
  
  <p>Any inputs will be greatly appreciated!!</p>