cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Samo Dadela <samo_dad...@hotmail.com>
Subject RE: multiple WS calls to the same URL as different user from same VM
Date Mon, 11 Nov 2013 15:47:50 GMT
Hi, 

I did not try HttpAsyncClient but just the normal HttpClient NTCredentials. Does this matter?

I'm still getting 401 Unauthorized.

I even tried to turn off chunking... 

The code:

                URL wsdlURL = new URL(getInstance().getClass().getClassLoader().getResource("wsdl/Lists.wsdl").toExternalForm());
                Lists service = new Lists(wsdlURL, new QName("http://schemas.microsoft.com/sharepoint/soap/",
"Lists"));

                port = service.getListsSoap();
                
                Client client = ClientProxy.getClient(port);
                HTTPConduit http = (HTTPConduit) client.getConduit();
                HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
                 
                httpClientPolicy.setConnectionTimeout(36000);
                httpClientPolicy.setAllowChunking(false);
                httpClientPolicy.setReceiveTimeout(32000);
                 
                http.setClient(httpClientPolicy);
                
                ((BindingProvider)port).getRequestContext().put("thread.local.request.context",
"true");
                Credentials creds = new NTCredentials(username, password, null, domain); 
                ((BindingProvider) port).getRequestContext().put(Credentials.class.getName(),
creds);
                
                ((BindingProvider) port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
username);
                ((BindingProvider) port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
password);

                ((BindingProvider) port).getRequestContext().put(
                        BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://machine/_vti_bin/Lists.asmx");

Only issue I can think off is the format of username/password/domain. I used: "username"/"password"/"DOMAIN"
(also tried "DOMAIN\username")... 


Everything works if I use the format "DOMAIN\username" / "password" and call from main...

  NtlmAuthenticator authenticator = new NtlmAuthenticator(username, password);
  Authenticator.setDefault(authenticator);
 


class NtlmAuthenticator extends Authenticator {

    private final String username;
    private final char[] password;

    public NtlmAuthenticator(final String username, final String password) {
        super();
        this.username = username;
        this.password = password.toCharArray(); 
    }

    public PasswordAuthentication getPasswordAuthentication() {
        return (new PasswordAuthentication (username, password));
    }
}


It's also no problem if I have to create a proxy for each thread... as long authentication
works, that is.


 		 	   		  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message