You may receive a "Document Locked" error message in the BizTalk Server 2004 error log when you save an InfoPath document directly to a Windows SharePoint Services site

Article translations Article translations
Article ID: 891441 - View products that this article applies to.
Expand all | Collapse all

On This Page

SUMMARY

When you use the BizTalk SharePoint Messaging Adapter in your Microsoft BizTalk Server 2004 Solution, you may receive the following error message in the event log:
An error occurred in updating the column for item 'http://<localhost>/sites/BASSite/<Outbox>/4ccd0eab-e48d-4575-a0e7-7c780c3c9107_Approve_localhost.xml'.

Document Locked

The document you are attempting to edit is locked and cannot be updated. It may be in use by another user or undergoing content indexing. For more information, see Help and Support Center at http://support.microsoft.com.
You may receive this error message if a document has been saved directly into the Windows SharePoint Services site by using the following methods in Microsoft Office InfoPath:
  • By clicking Save As on the File menu.
  • If the InfoPath solution uses scripts or managed code that uses the DAVAdapter component to perform the save.
The failure is intermittent and it can occur in different ways.

Note Sometimes, the BizTalk SharePoint Messaging Adapter will not process the document, and sometimes the document is processed but the adapter will not successfully update the document status.

MORE INFORMATION

The BizTalk SharePoint Messaging Adapter does not support the scenarios that are described in the "Summary" section. The correct way to save a document into the Outbox document library is to use managed code or scripts that perform a WebDAV HTTP PUT Web request against the Outbox document library. Do this to persist the document in the Windows SharePoint Services site.

The BAS tutorial that is included with the BizTalk Server 2004 SDK provides samples that show how to do this. To view the BAS tutorial, visit the following Microsoft Web site:

The following file is available for download from the Microsoft Download Center:
Collapse this imageExpand this image
Download
Download the BizTalk Server 2004 Tutorials package now.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following managed code and JavaScript code samples demonstrate the WebDAV HTTP PUT Web request for BizTalk Server 2004:

Managed code sample

// The following function handler is created by Microsoft Office InfoPath. Do not
// modify the type or number of arguments.
[InfoPathEventHandler(EventType=InfoPathEventType.OnSubmitRequest)]
public void OnSubmitRequest(DocReturnEvent e)
{	
	// If the submit operation is successful, set
	// e.ReturnStatus = true;
	// Write your code here.

	// Create an XmlDocument object from the MSXML 5.0 object.
	System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
	string xml = this.thisXDocument.DOM.xml;
	doc.LoadXml(xml);

	bool success = false;
	// The URL of the following file can be computed from the Outbox URL.
	// The Outbox URL can be retrieved by invoking the TPPubWS.GetOutboxDocumentLibraries method that is defined
	// in the TPPubWS Web service. For additional information, see the BizTalk Server 2004 documentation.
	success = PutUtf8File(xml,"http://<servername:serverport>/sites/BASSite/Outbox/Form2.xml", false);
	e.ReturnStatus = success;
}

/// <summary>
/// The method uses WebDAV protocol to create a file at the specified URL.
/// The code performs an HTTP PUT Web request to create an UTF-8 encoded XML file
/// at the specified location on the Windows SharePoint Services site.
/// </summary>
/// <param name="utf8XmlDoc">XML document that has the encoding attribute set to "UTF-8" or has no encoding attribute at all.</param>
/// <param name="fileUrl">The URL where the document will be created. It must include the file name.</param>
/// <param name="overwrite">Set the value to true to overwrite the existing file or false to fail if a file that has the same URL exists.</param>

public static bool PutUtf8File(string utf8XmlDoc, string fileUrl, bool overwrite)
{
	// HTTP Headers are used to control the overwrite behavior for HTTP PUT.
	const string IfNoneMatchHeader = "If-None-Match"
	const string IfNoneMatchValue = "*"

	byte[] Buffer = null;
	byte[] Preamble = null;

	Stream outputFile = null;
	HttpWebResponse Response = null;
	HttpWebRequest PostFile = null;
	HttpStatusCode statusCode = HttpStatusCode.ServiceUnavailable;

	try
	{
		UTF8Encoding encoder = new UTF8Encoding();
		Preamble = encoder.GetPreamble();
		Buffer = encoder.GetBytes(utf8XmlDoc);

		PostFile = (HttpWebRequest)WebRequest.Create(fileUrl);
		PostFile.Method = "PUT"
		if (!overwrite)
		{
			// Do not overwrite existing files.
			PostFile.Headers.Add(IfNoneMatchHeader, IfNoneMatchValue);
		}
		// Use the client credentials when you save the file.
		PostFile.Credentials = CredentialCache.DefaultCredentials;

		// The content length must be set before you start to write data.
		PostFile.ContentLength = Preamble.Length + Buffer.Length;
		outputFile = PostFile.GetRequestStream();

		// Write the byte order mark.
		outputFile.Write(Preamble, 0, Preamble.Length);
		outputFile.Write(Buffer, 0, (int)Buffer.Length);

		if (outputFile != null)
		{
			outputFile.Close();
			outputFile = null;
		}
		if (PostFile != null)
		{
			Response = (HttpWebResponse)PostFile.GetResponse();
			statusCode = Response.StatusCode;
		}
	}
	catch(System.Net.WebException we)
	{
		Response = we.Response as HttpWebResponse;
		statusCode = Response.StatusCode;
	}
	finally
	{
		if (outputFile != null)
			outputFile.Close();
		if (Response != null)
			Response.Close();

		PostFile = null; // No Close or Dispose method exists for this object.
	}

	if ((statusCode == HttpStatusCode.OK) || (statusCode == HttpStatusCode.Created))
	{
		return true;
	}
	else if (statusCode == HttpStatusCode.PreconditionFailed)
	{
		// The file already exists.
		return false;
	}
	else
	{
		// An error was encountered.
		return false;
	}

}

Javascript sample

//=======
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function, or the name and number of arguments.
//=======

function XDocument::OnSubmitRequest(eventObj)
{
	// If the submit operation is successful, set
	// eventObj.ReturnStatus = true;

	var success;
	// The URL of the following file can be computed from the Outbox URL.
	// The Outbox URL can be retrieved by invoking the TPPubWS.GetOutboxDocumentLibraries method that is defined
	// in the TPPubWS Web service. For additional information, see the BizTalk Server 2004 documentation.
	success = PutUtf8File(XDocument.DOM,"http://<servername:serverport>/sites/BASSite/Outbox/Form2.xml", false);
	eventObj.ReturnStatus = success;
}


//=======
// The method uses the WebDAV protocol to create a file at the specified URL.
// The code performs an HTTP PUT Web request to create an UTF-8 encoded XML file 
// at the specified location on the Windows SharePoint Services site.
// utf8XmlDoc - XML document that has the encoding attribute set to "UTF-8" or has no encoding attribute at all.
// fileUrl - The URL where the document will be created. It must include the file name.
// ovewrite - Set to value to true to overwrite the existing file or false to fail if a file that has the same URL exists.
//=======

function PutUtf8File(utf8XmlDoc, fileUrl, ovewrite) 
{
	// Create the xmlhttp object for transporting of the SOAP message.
	var xmlhttp = null;

	try
	{
		xmlhttp = new ActiveXObject("MSXML2.XMLHTTP.5.0");

		// Save the message as a UTF-8 encoded XML document.
		xmlhttp.open("PUT", fileUrl, false);
		xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

		if (!ovewrite)
		{
			// Do not overwrite existing files.
			xmlhttp.setRequestHeader("If-None-Match", "*");
		}

		xmlhttp.send(utf8XmlDoc);
	}
	catch(ex)
	{
		var constServerErrorExc = -2146697208;
		if (ex.number != constServerErrorExc)
		{
			throw ex;
		}
	}

	// Examine the HTTP response.
	// Windows SharePoint Services returns 201 when a new file is created successfully
	// or returns 200 if the content of an existing file has been updated successfully.
	if ((xmlhttp.Status == 201) || (xmlhttp.Status == 200))
	{
		// Content has been saved successfully.
		return true;
	}
	else if (xmlhttp.Status == 412) // Precondition failed.
	{
		// File already exists.
		return false;
	}
	else
	{
		// An error was encountered.
		var ErrorMessage = xmlhttp.statusText;
		return false;
	}
}

Properties

Article ID: 891441 - Last Review: September 22, 2006 - Revision: 3.3
APPLIES TO
  • Microsoft BizTalk Server 2004 Enterprise Edition
  • Microsoft BizTalk Server 2004 Developer Edition
  • Microsoft BizTalk Server 2004 Partner Edition
  • Microsoft BizTalk Server 2004 Standard Edition
  • Microsoft Windows SharePoint Services 2.0
  • Microsoft Office InfoPath 2003
Keywords: 
kbbiztalk2004sp2fix kbbtsadapters kbbtsbam kbexpertiseadvanced kbhowto kbinfo KB891441

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com