Office 2010 WebEdit Corrupts Document Downloads

We’ve now discussed why Office 2010 doesn’t work with Oracle WebCenter Collaboration Server, how it can be patched, and even the enigmatic post about Office 2010 document formats.  So we know that Office 2010 WebDAV can work with Collab.  But even though the Apache/AJP hack fixes WebEdit for Office 2010, unfortunately it breaks something else.  Specifically, when you close a document that you’re “Web-Editing”, Office 2010 sends the file back to Collab, and it doesn’t seem to include a Content-Type header (damn headers…).

Because Collab isn’t told what the Content Type is, it has to guess, and as mentioned, the Office 2010 document format is a .zip file that contains XML.  What ends up happening is that, after a successful WebEdit operation, if you try a simple download of that document in the portal, you get a .zip file with all those .xml docs in there.  This threw me off for a bit, thinking that the original document was lost to this crazy .xml file.  But, once I realized that renaming the file to .docx and opening in Word 2010 still worked, it was clear the problem was with the MIME type of the document, not the bits themselves.

This is good news – it means that Collab’s not really broken, but Office 2010 is sending the wrong Content Type when the document is closed (strangely, this happens when the doc is closed, not when it’s saved), and Collab is recording that Content Type to its CSFILES table in the database.  Specifically, the ContentType field in the CSFILES gets set to text/xml; charset=”utf-8″:


The best fix (hack?) I’ve found here is to create a trigger on this table to cancel out any changes that set this content type to that value.  In other words, the MS SQL trigger looks for the value of “text/xml; charset=”utf-8″” during and update, and if it’s there, the trigger rolls back the value to the original value.  As usual, proceed at your own risk, and while I can’t foresee any problems – even when uploading XML files to Collab, which are likely to have a different Content Type – this is a high-risk DB update that Oracle definitely won’t support.

Still with me?  Cool!  Here’s the script:

-- ================================================
-- Office 2010 documents updated with WCI Collaboration Server WebEdit / WebDAV
--   calls set the content type of documents to 'text/xml; charset="utf-8"'
-- Consequently, after using WebEdit, an Office document opened through
--   the portal will open up as a .zip file.
-- This stored procedure simply checks to see if the contenttype is
--   being changed to that value
-- If it is, the trigger rolls back the content type to the original value
-- ================================================
-- =============================================
-- Author:		Matt Chiste (Integryst -
-- Create date: 3/12/2011
-- Description:	WCI Collab trigger to fix WebDAV calls with Office 2010
-- =============================================
CREATE TRIGGER dbo.webdav_content_type
ON  dbo.csfiles

IF EXISTS (SELECT contenttype from Inserted where contenttype='text/xml; charset="utf-8"')
update csfiles set contenttype=
(select contenttype from deleted)
where objectid=(select objectid from Inserted)
--		these lines can be used to keep an audit of each time the trigger fires;
--        just create a table called trigger_audit with an auto-incrementing id
--        and columns [nvarchar(255)] for inserted and deleted
--		insert into trigger_audit(inserted, deleted)
--		(SELECT inserted.contenttype, deleted.contenttype from Inserted, Deleted)


Tags: , , , ,

Leave a Reply