Hi Jarek
Please see below it worked for me.
HttpTransportProperties.Authenticator.DIGEST can be replaced with
HttpTransportProperties.Authenticator.BASIC if you want I.
Hope this helps.
Regards
Stefan.
<------------------Start-------------------------->
/*
* Setup the Authentication
*/
List<String> authSchemes = new ArrayList<String>();
authSchemes.add(HttpTransportProperties.Authenticator.DIGEST);
HttpTransportProperties.Authenticator auth = new
HttpTransportProperties.Authenticator();
auth.setPreemptiveAuthentication(true);
auth.setAuthSchemes(authSchemes);
auth.setUsername("username");
auth.setPassword("password");
/*
* Set the EndpointReference
*/
EndpointReference epr = new EndpointReference("http://127.0.0.1/");
/*
* Set the http options
*/
Options httpOptions = new Options();
httpOptions.setTo(epr);
httpOptions.setProperty(HTTPConstants.AUTHENTICATE, auth);
httpOptions.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
httpOptions.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,Boolean.FALSE);
httpOptions.setProperty(Constants.Configuration.ENABLE_SWA,Constants.VALUE_TRUE);
httpOptions.setProperty(Constants.Configuration.ENABLE_MTOM,Constants.VALUE_FALSE);
httpOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
httpOptions.setTimeOutInMilliSeconds(100000);
httpOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
/* To set the SOAPAction header to SOAPAction: "" */
httpOptions.setProperty(Constants.Configuration.DISABLE_SOAP_ACTION,
epr);
/*
* ServiceCleint
*/
ServiceClient serviceClient = new ServiceClient(null, null);
serviceClient.setOptions(httpOptions);
/**
* OperationClient
*/
OperationClient mepClient =
serviceClient.createClient(ServiceClient.ANON_OUT_IN_OP);
mepClient.addMessageContext(msgCtx);
<------------------End-------------------------->
On Thu, 2007-02-15 at 13:26 +0100, Jarek Kucypera wrote:
> Can somebody please show me a working example of client
> side basic authentication with axis2 1.1.1 ?
> Below is my current code (xmlbeans client) which does not work:
>
> HttpTransportProperties.Authenticator auth = new
> HttpTransportProperties.Authenticator();
> auth.setUsername("test_user");
> auth.setPassword("test_password");
> stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,auth);
>
>
> stub.ping(); // here a remote method is called, but the Autorization
> http header is not sent
>
> // J.K.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]