views:

454

answers:

3

Howdy,

I am trying to checkout a file from a SharePoint document library before downloading to my client application for edit.

//documentPath = https://192.168.1.10/Utility/Phys/Document%20Library/document.xml
//listWebServiceURL = https://192.168.1.10/Utility/Phys/Document%20Library/_vti_bin/lists.asmx
private void CheckOutFile(string documentPath)
{
    string listWebServiceUrl = this.GetListServiceURL(documentPath);
    bool checkedOut;

    using (Lists listWebService = new Lists())
    {
        listWebService.Credentials = CredentialCache.DefaultCredentials;
        listWebService.Url = listWebServiceUrl;
        checkedOut = listWebService.CheckOutFile(documentPath, "true", string.Empty);
    }
}

When the checkedOut = listWebService.CheckOutFile(documentPath, "true", string.Empty); line runs I get a SOAPServerException.

((System.Xml.XmlElement)((System.Web.Services.Protocols.SoapException)(ex)).Detail).InnerText Object reference not set to an instance of an object.

Any help on this would be appreciated.

Thank you,
Keith

EDIT: I have tested the above code against a SharePoint library that does not use SSL and it seems to work fine.

A: 

I believe you have to provide a time value in the last argument in listWebService.CheckOutFile. It may be complaining about the string.Empty. Try putting in a string like; "12 May 2009 22:00:00 GMT"

Jamie McAllister
http://msdn.microsoft.com/en-us/library/lists.lists.checkoutfile.aspx on the lastModified timestamp: If this parameter contains a value, the server compares the submitted lastModified value with the stored lastModified value. If the values do not match, the check-out fails and this method returns false. Will test out your suggestion.
Keith Sirmons
Ok.. Tried it with the Date Modified that is listed for that item in the document library, no luck. I tried it with null in place of string.empty, no luck. Same exception each time.
Keith Sirmons
A: 

OK. Do you have an example of the document path that is being passed into the method?

Curious to see Relative or absolute url, file extension etc.

Jamie McAllister
An example of a documentPath is in the question's code block. It is the first commented line.
Keith Sirmons
+1  A: 

Maybe this is an alternate access mapping problem (The "Object Not Set" error is a telltale sign)? You've got one for https://192.168.1.10/ in Central Administration->Operations->Global Configuration->Alternate Access Mappings, ya?

vinny
I think you may be onto something. I stumbled onto this a little earlier, by changing the url I was using from the IP address to the hostname of the server and it started to work. I will look into the Alternate Access Mappings now. Thank you.
Keith Sirmons
Yep, if you can access the site through a browser but not hit any of the web services, then alternate access mappings are your first port of call.
julianz