BT

InfoQ Homepage News Article: Getting Started With SharePoint Web Services

Article: Getting Started With SharePoint Web Services

Bookmarks

In this InfoQ exclusive article Trent Swanson provides an overview of  Microsoft Office SharePoint 2007 and its architecture.  In SharePoint, developers can use RPC which provides a more robust object model than web services however it does not support remote operations.  This is where web services must be utilized to support remote operations and gain interoperablity capabilities.

A solid understanding of IIS and ASP.NET is important when developing any SharePoint based solution.  Trent provides examples that walk through both .NET and Java in this introductory article on working with SharePoint web services.

 

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • WSRP

    by A A /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Hi,
    does Sharepoint support WSRP ? since I'd found any official resources about sharepoint interop through WSRP.

  • Java Sample Code Missing

    by Steve Reynolds /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I do not see a link to download the aforementioned Java Sample Project. Am I just missing it?

    Thanks,
    Steve

  • XSD files

    by Garth Sweet /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Very helpful article!
    In the article you mention under the "Download the XSD files" section that we can "Download the XSD files from <here>...." but <here> isn't actually a link to anything. Can you point me to the XSD files?


    </here></here>

  • Re: Java Sample Code Missing

    by Diana Baciu /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Hello Steve

    I've just added the download link.

    diana

  • Re: XSD files

    by Diana Baciu /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Hi Garth

    I've added a link for the zip file containing the XSD files

    Diana

  • NTLM Authentication

    by Steve Reynolds /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Diana,
    Thanks for posting the code. I have been trying to connect to the SharePoint Search Web Service via Axis2, but can not get it to work with NTLM Authentication. I am getting a similar error with your method: Exception in thread "main" com.sun.xml.internal.ws.client.ClientTransportException: request requires HTTP authentication: Unauthorized
    I was wondering if any has tried this with NTLM Authentication. The SharePoint server I am connecting to has Basic Authentication turned off because it sends the credentials in plain text. Note: I provided a valid administrator username and password in Main.java. Looking at the BindingProvider API, I don't see any other properties that I need to provide. I'm out of ideas.

  • Re: XSD files

    by tamer morsi /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Thanks for uploading the docs,

    The xsd.zip file; the article says: this file contains the XSD along with the completed project.
    but there are no other files in the xsd.zip,
    are their any missing files ?
    thanks again

  • Re: NTLM Authentication

    by tamer morsi /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Hey,

    check out:
    derekjmiller.spaces.live.com/blog/cns!A77124B9D...

    // Setup Authentication parameters
    String username = "Derek.Miller";
    String password = "mypassword";
    String host = "moss.syddev01.mymachine.com";
    // NOTE: Important to ensure fully qualified domain name is used
    String domain = "syddev01";
    String realm = "syddev01";
    int port = 80;

    // Configure authenticator
    HttpTransportProperties.Authenticator auth =
    new HttpTransportProperties.Authenticator();
    auth.setUsername(username);
    auth.setPassword(password);
    auth.setDomain(domain);
    auth.setHost(host);

    // Ensure NTLM authentication used
    List authPrefs = new ArrayList(1);
    authPrefs.add(AuthPolicy.NTLM);
    auth.setAuthSchemes(authPrefs);


    // Get stub
    ListsStub lists =
    new ListsStub("http://moss.syddev01.mymachine.com/_vti_bin/Lists.asmx");

    // Set authenticator
    lists._getServiceClient().getOptions().setProperty
    (org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
    // Get request and execute
    GetListCollection req = new GetListCollection();
    GetListCollectionResponse res = lists.GetListCollection(req);
    DisplayResult(req, res);

  • Re: XSD files

    by Floyd Marinescu /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    tamer, there’s another link in the article right below the image Java SharePoint Sample Project Directory and Root Files that contains the other archive (The full project and generated files are included along with couple, ...)

  • Re: XSD files

    by tamer morsi /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Thanks but there should be another c# class, that is missing : Microsoft_Query_Request.c
    This class is different from the generated xsd classes & is a wrapper class that the author refers to & the author says it is included in the xsd zip file ...
    though i maybe wrong on this;
    either way thnks

  • Re: XSD files

    by aladin sohaili /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Hi Guys,
    Thanks for the Article and for the different posts.

    i modified the absolute path for the WSDL,and i modified the Main.java to point to my sharepoint server and to use the correct credentials.

    i'm trying to run the code, i'm having this exception:

    com.sun.xml.ws.client.ClientTransportException: request requires HTTP authentication: Unauthorized
    at com.sun.xml.ws.transport.http.client.HttpClientTransport.checkResponseCode(HttpClientTransport.java:212)
    at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:149)
    at com.sun.xml.wss.jaxws.impl.SecurityClientPipe.process(SecurityClientPipe.java:208)
    at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
    at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
    at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
    at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
    at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
    at com.sun.xml.ws.client.Stub.process(Stub.java:248)

    Thanks a lot for the help.

  • Re: NTLM Authentication

    by Kathryn Steel /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I have tried this in Java and failed to get it to work with our server.
    I can get basic-authentication working but we need to get at least basic authentication with SSL or NTLM working.
    For SSL I get an
    java.lang.RuntimeException: Object reference not set to an instance of an object.
    Which suggest an object not populated that .NET is expecting.
    Code:
    I changed the URLS to be https:// for the ListsStub()


    Authenticator auth = new Authenticator();
    ArrayList authSchemes = new ArrayList();
    authSchemes.add(AuthPolicy.BASIC);
    auth.setAuthSchemes(authSchemes);
    auth.setAllowedRetry(false);

    auth.setUsername("doman\\name");
    auth.setPassword("password");
    auth.setPreemptiveAuthentication(true);

    copyStub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, auth);


    With NTLM I get Unable to respond to any of these challenges: {basic=Basic realm="melwwsinr08-basicauth"}
    org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized

    code
    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
    auth.setUsername("ksteel");
    auth.setPassword("object123#");
    auth.setDomain("nt3gwm01");
    auth.setHost("10.16.224.86");
    auth.setRealm("");

    // Ensure NTLM authentication used
    List authPrefs = new ArrayList(1);
    authPrefs.add(AuthPolicy.NTLM);
    auth.setAuthSchemes(authPrefs);
    //
    copyStub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, auth);

    Has anyone got working for SSL or can help further with NTLM ?

  • Re: NTLM Authentication

    by Kathryn Steel /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Sorry I should also say for SSL I have set up
    System.setProperty("javax.net.ssl.keyStore", "c:/client.keystore");
    System.setProperty("javax.net.ssl.keyStorePassword", "test12");
    System.setProperty("javax.net.ssl.keyStoreType", "JKS"); // JKS or PKCS12 ?

    System.setProperty("javax.net.ssl.trustStore", "c:/client.keystore");
    System.setProperty("javax.net.ssl.trustStorePassword", "test12");
    System.setProperty("javax.net.ssl.trustStoreType", "JKS"); // JKS or PKCS12 ?
    System.setProperty("javax.net.debug", "ssl");
    And I can see the SSL debug happenning and the application data content type 23 going over the wire encrypted but it gets an error. as I said saying Object reference not set to an instance of object coming back.

  • Re: NTLM Authentication

    by Ken Nagel /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Kathryn
    Did you ever get your answer? My guys are stuck here as well, and cannot get through NTLMV2 auth

  • Re: NTLM Authentication

    by Dilip Kumar Aerroju /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    PermissionsStub permissionsStub = new PermissionsStub("http://apstra-87lg198t:44894/_vti_bin/Permissions.asmx");
    permissionsStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
    GetPermissionCollection req1 = new GetPermissionCollection ();
    req1.setObjectName("");
    req1.setObjectType("web");
    GetPermissionCollectionResponse res1 = PermissionsStub.GetPermissionCollection(req1);

    UserGroupStub groupStub = new UserGroupStub("http://apstra-87lg198t:44894/_vti_bin/usergroup.asmx");
    groupStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, auth);
    GetRoleCollectionFromUser collectionFromUser = new GetRoleCollectionFromUser();
    collectionFromUser.setUserLoginName("administrator");
    GetRoleCollectionFromUserResponse collectionFromUserResponse = groupStub.GetRoleCollectionFromUser(collectionFromUser);

    my problem is that very time authenticate for permission and userinfo. is there any way authenticate only once

  • Re: XSD files

    by ian smith /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Does anyone know how the four XSD files were generated? Were they reverse engineered, or is this information available in a public place? I'm looking to interoperate with several sharepoint services using Java/JAXB.

  • org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized

    by Stefaan Somers /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I'm pulling my hairs out for the moment. I've written some code, to get a list of sharepoint-lists. For some sharepoint sites, it works without any problem. But for other I always get the error : org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized.

    There are 2 important questions I have :
    - how can I check which authentication mechanism is used (NTLM or BASIC)
    - can I get a more clear response, indicating me where the problem lies. Unauthorized is a bit too general. Moreover with the same user-name & password I can open the sharepoint URL for the list webservices.

    If anyone wants I can send the jar-file so he can try out for himself. I create a test-sharepoint side, where you can work on.

    Any help would be most welcome

  • Re: XSD files

    by HariKrishna Maharshi /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Very useful article. Thanks.
    Also, can you explain, how these XSD files were generated? Or can we get them from sharepoint server?
    I wanted to interact with remaining services from the sharepoint server (from java).

  • Re: XSD files

    by HariKrishna Maharshi /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Here is the link for Query schema on msdn site:

    msdn.microsoft.com/en-us/library/aa193736(office.11).aspx

  • Re: XSD files

    by Markus Schmidt /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Hi Aladin

    I had the same problem and solved it by enabling Basic Authentication for the WebApplication in the central administration (Application Management -> Authentication Providers).

    Hope that helps,
    Markus

  • Re: XSD files

    by Peter Trein /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    has anyone tried connecting with WSS using Java?
    This code:
    BindingProvider bp = (BindingProvider)qsp;
    //bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "Administrator");
    //bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "pass@word1");
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
    "http://barbie/_vti_bin/spsearch.asmx");

    doesn't work with ListsSoap.:/ I get error 401.

    Anyone can help?

  • Re: XSD files

    by David Dudok de Wit /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Hey Peter, I've covered your authentication problem in my tutorial that you will find here:
    Reading a SharePoint list with Java: tutorial.

    Basically the workaround to a lot of authentication problems (NTLM, SSL, ...) is to use a local copy of the WSDL file to generate stubs (just save it from your browser). After that, the Web Services just use a simple login/password problem.

    I hope this helps.

    Cheers,
    David D.

  • Re: org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized

    by Peter Trein /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Did you ever get the response for your post? I'm having the same problem.
    NTLM authentication fails with org.apache.axis2.AxisFault: Transport error: 401 Error: Unathorized.
    The question is: I have a user in a domain DOMAIN\user and the server is on port 8888. how to put it in the code because I believe this is a source of the problem?
    My code:

    import java.rmi.RemoteException;
    import java.util.ArrayList;
    import java.util.List;
    import com.microsoft.schemas.sharepoint.soap.*;
    import org.apache.axis2.AxisFault;
    import org.apache.axis2.Constants;
    import org.apache.axis2.client.Options;
    import org.apache.axis2.transport.http.HTTPConstants;
    import org.apache.axis2.transport.http.HttpTransportProperties;
    import org.apache.commons.httpclient.auth.AuthPolicy;

    public class Test {

    public static void main(String[] args) {
    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
    auth.setUsername ("user");
    auth.setPassword ("pass");
    auth.setDomain ("DOMAIN");
    auth.setHost("host");
    auth.setPort(8888);
    auth.setRealm(null);
    auth.setPreemptiveAuthentication(true);
    List<String> authPrefs = new ArrayList<String>(1);
    authPrefs.add((String)AuthPolicy.NTLM);
    auth.setAuthSchemes(authPrefs);
    ListsStub lists;
    try {
    lists = new ListsStub();

    lists._getServiceClient ().getOptions().setProperty (HTTPConstants.AUTHENTICATE, auth);
    Options options = lists._getServiceClient().getOptions();
    options.setSoapVersionURI(Constants.URI_SOAP11_ENV);
    ListsStub.GetListCollection req = new ListsStub.GetListCollection();
    ListsStub.GetListCollectionResponse res;
    System.out.println();
    res = lists.GetListCollection (req);
    System.out.println(res.toString());
    } catch (AxisFault e) {
    e.printStackTrace();
    } catch (RemoteException e) {
    e.printStackTrace();
    }
    }
    }
    </string></string>

  • Re: XSD files

    by Peter Trein /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Hi David,
    indeed you made some good job. Right now I'm having the problems as described in the post from yesterday. I will try with your new tutorial. Maybe it will work.

    cheers,

  • Re: QueryOptions

    by Leonid Sokolin /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Can anyone provide an example of how to specify QueryOptions in the request?

    I need to get a list of subfolders and it is apparently possible, if Folder option is specified as follows:

    <QueryOptions><Folder>MyDocuments\\MyFolder</Folder></QueryOptions>

    I am not sure though how to assign this value to GetListItems.QueryOptions.

  • ERROR_NO_RESPONSE

    by blue fish /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    hello,
    I'm also struggling with java and sharepoint search/query service, unable to get any query to work.

    I've dl the source, modified Main.java to point to our sharepoint server search.asmx/spsearch.asmx. Initially I got error 401, since our server only have windows authentication enabled; so I just enabled Basic auth, just for test purpose; I get response below.

    Server Status: ONLINE

    Response Status: ERROR_NO_RESPONSE


    any help is greatly appreciated
    thx

  • Re: ERROR_NO_RESPONSE

    by blue fish /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    it turns out ERROR_NO_RESPONSE only happen with spsearch.asmx, not search.asmx anyone known why ?

    also, how to get .xsd files (from java environment)?
    I can only get wsdl file from sharepoint server.

    main.java
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://myserver/_vti_bin/search.asmx"); //okay, got result

    // bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://myserver/_vti_bin/spsearch.asmx"); //Server Status: ONLINE Response Status: ERROR_NO_RESPONSE

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.