开发者

Editing MS Office documents from a web application: custom WebDaV implementation or ...?

开发者 https://www.devze.com 2023-03-22 02:33 出处:网络
Following is our setup & requirement: There\'s a public web application accessible via SSL + Basic Authentication. Most of these applications are in ASP.Net; couple of legacy ones are in classic

Following is our setup & requirement:

  • There's a public web application accessible via SSL + Basic Authentication. Most of these applications are in ASP.Net; couple of legacy ones are in classic ASP. Server is Win 2003 / IIS 6.0
  • This app开发者_如何学JAVAlication needs to support online editing of (mostly) MS Office documents (2007 & 2010). The documents themselves are stored in the database, along with the content of the application.
  • The users should be able to open the document via HTML links; the corresponding external Office application (say MS Word) should open the document in edit mode (with exclusive lock) and when the user presses Save button, the document should be posted back to the application.
  • Preferably no external plugins/ActiveX controls need to be deployed on the client side.

Is a custom WebDAV implementation the best possible approach? Note that we might not need all the features of WebDAV for supporting above requirements. Are you aware of any alternatives?

If custom WebDAV implementation is the way to go, can you please recommend some good resources (commercial/open source IIS plugins, samples in .Net, docs, etc), apart from http://www.webdav.org/ ? BTW, I do not prefer installing a bulky CMS like Sharepoint to support such a small requirement!

I found a thread on SO about custom WebDav implementation: What are your experiences implementing/using WebDAV? It sounds so discouraging :( (Avialable only on IIS root, requires Windows authentication, etc)

Thanks in advance!


I recently developed a simple Webdav server using the Apache Tomcat WebdavServlet as a base. I just got the source from SVN (see below) and modified it to meet my needs. You can add code to the different methods in there:

doGet
doLock
doPut
doUnlock
etc...  

I am using it as a poor mans webdav in front of an enterprise CMS, so within each method I added API calls to fetch the document, lock it, version it, or whatever. Basically they didn't want to buy the webdav product from the vendor, and Tomcat is free.

As for opening the Office files on the client, you may need to rely on a library that ships with Office installs (since Office XP at least). Note that the component is called SharePoint blah blah but it does not require a SharePoint install anywhere. I have a js snippet here that uses the library for an example, obviously you would modify to meet your needs. I realize you said no ActiveX, but without it I am not 100% sure how you would open the links. You're welcome to try other ways.

function webedit(id) {
        if (window.ActiveXObject) {
            var ed; 
            try {
                //Office 2003
                ed = new ActiveXObject('SharePoint.OpenDocuments.2');
            } catch (err1) {
                try {
                    //Office 2000/XP
                    ed = new ActiveXObject('SharePoint.OpenDocuments.1');
                } catch (err2) {                
                    try {
                        //Office 2007
                        ed = new ActiveXObject('SharePoint.OpenDocuments.3');
                    } catch (err3) {                
                        window.alert('Unable to create an ActiveX object to open the document. This is most likely because of the security settings for your browser.');
                        return false;
                    }
                }
            }
            if (ed) {
                ed.EditDocument('<%=webdavPath%>/webdav/'+id);
                return false;
            } else {
                window.alert('Cannot instantiate the required ActiveX control to open the document. This is most likely because you do not have Office installed or you have an older version of Office.');
                return false;
            }
        } else {
            window.alert('Internet Explorer is required to use this feature.');
        }
        return false;    
    }

I also realize that your server is IIS and not Apache-based, but you can always front the Tomcat install with IIS (it's what we do) and use the JK ISAPI filter over AJP. Anyway, it's one way of doing things and doesn't require you to purchase anything.

SVN source: http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/WebdavServlet.java


When Office opens a file from a url, it will check if WebDav is supported on this url. If that is the case, and WebDav permits writing to this url, then Office will allow the user to edit the file.

Getting Office to open the file when the user clicks a link in the browser seems to work best with a url like this:

ms-word:ofe|u|https://someOfficeFile.docx

URL's in this style do not work when Office is not present on the user's machine.

Integrating with software installed on the user's hardware is of course tricky, because the developer has no control over the user's hardware.

It would be best if Office document editing could be fully done in the browser. Office365 does this. Integrating a Line-Of-Business application with Office365 is done through the WOPI-protocol.

Office integrates to DropBox and the likes through this protocol. It appears, however, that Microsoft is not ready yet to allow large numbers of LOB-applications to integrate with Office365.

Perhaps Microsoft will someday publish an SDK to do this integration without writing WOPI from scratch.


What's wrong with WebDAV? There exists a couple of third-party WebDAV server components which you can plug to your server-side application (www.webdavsystem.com, our WebDAVBlackbox).

Alternatively you can create a virtual file system on the client which will communicate with the server using some other protocol (either plain HTTP if it is easier for you to implement handling this way or FTP or SFTP).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号