从Web应用程序编辑MS Office文档:自定义WebDaV实现还是......?

时间:2023-01-12 17:50:27

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
  • 有一个公共Web应用程序可通过SSL +基本身份验证访问。大多数这些应用程序都在ASP.Net中;传统的几个是经典的ASP。服务器是Win 2003 / IIS 6.0

  • This application 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.
  • 此应用程序需要支持(主要)MS Office文档的在线编辑(2007和2010)。文档本身与应用程序的内容一起存储在数据库中。

  • 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.
  • 用户应该能够通过HTML链接打开文档;相应的外部Office应用程序(比如MS Word)应该以编辑模式打开文档(使用独占锁定),当用户按下Save按钮时,文档应该回发给应用程序。

  • Preferably no external plugins/ActiveX controls need to be deployed on the client side.
  • 优选地,不需要在客户端部署外部插件/ ActiveX控件。

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?

自定义WebDAV实现是最好的方法吗?请注意,我们可能不需要WebDAV的所有功能来支持上述要求。你知道任何替代方案吗?

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!

如果要实现自定义WebDAV实现,除了http://www.webdav.org/之外,您能否推荐一些好的资源(商业/开源IIS插件,.Net,docs等样本)?顺便说一句,我不喜欢安装像Sharepoint这样庞大的CMS来支持这么小的要求!

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)

我在SO上发现了一个关于自定义WebDav实现的线程:您在实现/使用WebDAV方面有什么经验?这听起来很令人沮丧:((仅在IIS根目录上可用,需要Windows身份验证等)

Thanks in advance!

提前致谢!

3 个解决方案

#1


1  

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).

WebDAV有什么问题?存在一些第三方WebDAV服务器组件,您可以将它们插入服务器端应用程序(www.webdavsystem.com,我们的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).

或者,您可以在客户端上创建一个虚拟文件系统,该系统将使用其他协议与服务器通信(如果您更容易实现以这种方式处理或FTP或SFTP,则使用普通HTTP)。

#2


5  

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:

我最近开发了一个使用Apache Tomcat WebdavServlet作为基础的简单Webdav服务器。我刚从SVN获得了源代码(见下文)并对其进行了修改以满足我的需求。您可以将代码添加到其中的不同方法:

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.

我在企业CMS前面使用它作为一个可怜的mand webdav,因此在每个方法中我添加了API调用来获取文档,锁定它,版本或其他任何东西。基本上他们不想从供应商处购买webdav产品,Tomcat是免费的。

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.

至于在客户端上打开Office文件,您可能需要依赖Office安装附带的库(至少从Office XP开始)。请注意,该组件称为SharePoint blah blah,但它不需要在任何地方安装SharePoint。我在这里有一个js片段,以图书馆为例,显然你会修改以满足你的需求。我意识到你说没有ActiveX,但没有它我不是100%肯定你将如何打开链接。欢迎您尝试其他方式。

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.

我也意识到你的服务器是IIS而不是基于Apache的,但是你可以随时使用IIS进行Tomcat安装(这就是我们的工作),并使用JK ISAPI过滤器而不是AJP。无论如何,这是一种做事方式,不需要你购买任何东西。

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

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

#3


2  

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.

当Office从URL打开文件时,它将检查此URL是否支持WebDav。如果是这种情况,并且WebDav允许写入此URL,则Office将允许用户编辑该文件。

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

当用户单击浏览器中的链接时让Office打开文件似乎最适合使用这样的URL:

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.

当用户的计算机上没有Office时,此样式的URL不起作用。

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文档编辑可以在浏览器中完全完成,那将是最好的。 Office365就是这样做的。通过WOPI协议将业务线应用程序与Office365集成。

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.

Office通过此协议集成到DropBox等。但是,似乎微软尚未准备好允许大量LOB应用程序与Office365集成。

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

也许微软有朝一日会发布一个SDK来进行这种集成,而无需从头开始编写WOPI。

#1


1  

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).

WebDAV有什么问题?存在一些第三方WebDAV服务器组件,您可以将它们插入服务器端应用程序(www.webdavsystem.com,我们的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).

或者,您可以在客户端上创建一个虚拟文件系统,该系统将使用其他协议与服务器通信(如果您更容易实现以这种方式处理或FTP或SFTP,则使用普通HTTP)。

#2


5  

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:

我最近开发了一个使用Apache Tomcat WebdavServlet作为基础的简单Webdav服务器。我刚从SVN获得了源代码(见下文)并对其进行了修改以满足我的需求。您可以将代码添加到其中的不同方法:

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.

我在企业CMS前面使用它作为一个可怜的mand webdav,因此在每个方法中我添加了API调用来获取文档,锁定它,版本或其他任何东西。基本上他们不想从供应商处购买webdav产品,Tomcat是免费的。

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.

至于在客户端上打开Office文件,您可能需要依赖Office安装附带的库(至少从Office XP开始)。请注意,该组件称为SharePoint blah blah,但它不需要在任何地方安装SharePoint。我在这里有一个js片段,以图书馆为例,显然你会修改以满足你的需求。我意识到你说没有ActiveX,但没有它我不是100%肯定你将如何打开链接。欢迎您尝试其他方式。

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.

我也意识到你的服务器是IIS而不是基于Apache的,但是你可以随时使用IIS进行Tomcat安装(这就是我们的工作),并使用JK ISAPI过滤器而不是AJP。无论如何,这是一种做事方式,不需要你购买任何东西。

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

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

#3


2  

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.

当Office从URL打开文件时,它将检查此URL是否支持WebDav。如果是这种情况,并且WebDav允许写入此URL,则Office将允许用户编辑该文件。

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

当用户单击浏览器中的链接时让Office打开文件似乎最适合使用这样的URL:

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.

当用户的计算机上没有Office时,此样式的URL不起作用。

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文档编辑可以在浏览器中完全完成,那将是最好的。 Office365就是这样做的。通过WOPI协议将业务线应用程序与Office365集成。

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.

Office通过此协议集成到DropBox等。但是,似乎微软尚未准备好允许大量LOB应用程序与Office365集成。

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

也许微软有朝一日会发布一个SDK来进行这种集成,而无需从头开始编写WOPI。