Hi there!
I created a web service with two methods:
one for checking out a document and one for deleting a document.
I tried both methods with a test Windows form application and they work fine.
I published the form with full trust and a certificate, so the security should be fine.
However, when I call them from managed code within the infopath document (in exactly the same way), the checking out method always reports/throws an exception that the file is already checked out. The delete method deletes the document, however, when I want to submit the document again, I get an error message that I can not overwrite the file (I don't want to give that permission to the submit data-connection).
The methods look like this:
public string DeleteDocument(string page, string folder, string file)
{
try
{
SPSite site = new SPSite(page);
SPWeb web = site.OpenWeb();
SPFileCollection delFiles =
web.Folders[folder].Files;
delFiles.Delete(file);
web.Close();site.Close();
// ...
public string CheckOutDocument(string page, string outFile)
{
SPSite site = new SPSite(page);
SPWeb web = site.OpenWeb();
SPFile file = web.GetFile(outFile);
if (file.Exists)
{
if (SPFile.SPCheckOutStatus.None == file.CheckOutStatus)
{
try
{
file.CheckOut();
web.Close();
site.Close();
//...
I call the methods with:
SharePointService.SPService _svc = new SharePointService.SPService();
_svc.Credentials = CredentialCache.DefaultCredentials;
string result = _svc.CheckOutDocument(page,thisXDocument.URI);
Does anyone know a reason for this odd behavior?
Would be great if I could get this work ...