I am trying to access SharePoint UserGroup service using a Java client. I have generated the stubs from the WSDL using axis2-1.6.2 and using the following code to access the user group but getting following exception:
org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername(username);
auth.setPassword(password);
auth.setDomain(domain);
auth.setHost(host);
auth.setPort(80);
List authPrefs = new ArrayList(1);
authPrefs.add(AuthPolicy.NTLM);
auth.setAuthSchemes(authPrefs);
UserGroupStub userGrp = new UserGroupStub("http://domainName/ProjectName/_vti_bin/UserGroup.asmx");
// Set authenticator
userGrp._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
userGrp._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION, org.apache.axis2.transport.http.HTTPConstants.HEADER_PROTOCOL_10);
userGrp._getServiceClient().getOptions().setTimeOutInMilliSeconds(10000);
// Get request and execute
GetUserCollectionFromGroup req = new GetUserCollectionFromGroup();
req.setGroupName(grpName);
GetUserCollectionFromGroupResponse res = userGrp.getUserCollectionFromGroup(req);