Take the 2-minute tour ×

I want access my SharePoint site through Java. I use the SharePoint's webservice, but it needs credentials, and I don't know how to fill in the credentials in Java.

Below is some code in .Net:

WSLists.Lists wslists = new WSLists.Lists();                  
wslists.Credentials = new System.Net.NetworkCredential("administrator", "pass@word1", "mosing");

Can someone give me some advice or some sample code? Thanks...

share|improve this question
add comment

1 Answer

The way sharepoint webservices perform actions from java, at least as my team and I found it, is it creates an instance of a webservice, binds a username and password to that instance, then that instance performs an action.

Below you'll see we bind a username and password to a ListSoap object, because we want to checkin or checkout a file. The code below binds the username and password to a port. Then, we can do something like port.checkOut(...). Hope this makes sense for you.

public ListsSoap sharePointListsWebServiceAuth(){
     ListsSoap port = null;
            try {
                ListsService service = new ListsService();
                port = service.getListsSoap();
                ((BindingProvider) port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
                ((BindingProvider) port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
            } catch (Exception e) {

        } else {
            System.out.println("Couldn't authenticate: Invalid connection details given.");
        return port;
share|improve this answer
add comment

Your Answer


