基于Office Online Server 2016 的 office在线编辑

编程入门 行业动态 更新时间:2024-10-26 02:24:42


 


 

基于Office Online Server 2016 的office在线编辑

1.硬件要求

微软要求实现OfficeOnline Server 需要安装WindowsServer 2012 R2 操作系统的服务器2台: 

1.服务器1做转换服务器(安装 Office OnlineServer 2016 软件,除此之外不能安装与office相关的其他程序);

2.服务器2做域控服务器(转换服务器只有加在域下才能被访问,同时项目部署服务器只有加在域控服务器下才能访问转换服务器)。

服务器所需硬件标准(微软提供最低配置要求,这些只是最低的OS部署标准,该配置下的服务器不能运行任何应用程序或者虚拟机。):

处理器:1.4GHz64位

RAM:512MB

磁盘空间:32GB

其他要求:

DVD 驱动器

超级VGA(800 x 600) 或更高分辨率的显示器

键盘和鼠标(或其他兼容的指点设备)

Internet 访问(可能需要付费)

基于 x64 的操作系统的重要信息

注:win10系统VM2012虚拟机设置4G内存,100G硬盘,4线程处理器 运行系统卡顿明显。

2.环境搭建

2.1环境搭建所需软件及更新包

1.WindowsServer 2012 R2.iso;

2.OfficeOnline Server 2016;

3.Microsoft .Net Framework 4.5.2;

4.Visual C++ Redistributable Packages for Visual Studio 2013;

5.Visual C++ Redistributable for Visual Studio 2015;

6.Microsoft.IdentityModel.Extention.dll;

7.Update for Windows Server 2012 R2 (KB2919442);

8.Update for Windows Server 2012 R2 (KB2919355);

9.Update for Windows Server 2012 R2 (KB2999226)。

 

2.2安装WindowsServer 2012 R2

在服务器1、服务器2安装Windows Server 2012 R2 系统 (一台域控服务器,一台转换服务器),安装过程为ISO镜像文件安装,按照提示步骤进行安装,安装完成后重启。

2.3配置域控服务器

1. 打开服务器管理器,添加角色和功能;

2.下一步;

3.下一步;

4.下一步,选择添加AD域服务,同时添加所需功能;

5.下一步,安装功能;

6.点击安装,安装功能,安装完成后点击关闭。

7.配置域,点击服务器管理器左侧“AD DS” 

8. 点击“升级为域控制器” ;

9. 进入AD域服务器配置向导,下一步(选择添加新林);

10. 填写密码,下一步 ;

12. 提示DNS无法创建,不用管,继续下一步

13. 安装路径,默认,下一步;

14. 查看选项,默认,下一步;

15. 点击安装 

16. 安装完成,会提示注销重启 ;

2.4将转换服务器加入域服务器

1. 打开转换服务器的TCP/IPV4协议修改NDS,指向域控服务器(红框为域服务器的IP地址);

2. 在计算机属性中,修改计算机名称,并添加到域控服务器域名为域转换服务器设定的域名(如下图),确定后提示注销重启服务器;

3. 在域控服务器,管理中选择添加服务器,名称填写转换服务器的计算机名称,立即查找。然后添加到右边,确定。

4. 在域控服务器中,所有服务器显示两台服务器,并都是联机状态则表示成功 。

2.5安装部署Office Online Server 2016

1.安装IIS7.0打开服务器管理器,添加角色和功能;

2.打开“添加角色和功能向导”界面,点击下一步;

3. 基于本机安装,选择“基于角色或者基于功能安装”;

4.下一步;

5. 在服务器角色列表上选择“Web服务器”;

6. “下一步”,安装。注意,在安装IIS的时候要安装Web服务器下面的“管理服务”;

 

2.安装Office Online Server 2016所必需的软件及补丁(按照以下顺序安装,顺序错误会导致软件安装会报错);

Microsoft.Net Framework 4.5.2;

VisualC++ Redistributable Packages for Visual Studio 2013;

Updatefor Windows Server 2012 R2 (KB2919442);

Updatefor Windows Server 2012 R2 (KB2919355);

VisualC++ Redistributable for Visual Studio 2015;

Microsoft.IdentityModel.Extention.dll

Updatefor Windows Server 2012 R2 (KB2999226)。

3.安装OfficeOnline Server 2016

    解压Office Online Server 2016镜像文件,点击OfficeOnline Server 2016里面的setup.exe进行安装,软件安装按照提示完成,安装完成后重启服务器。

4.配置OfficeOnline Server 2016的服务器场

在Windows PowerShell输入命令 Import-ModuleOfficeWebApps 回车,

运行下列命令部署服务器场:(online.office为转换服务器计算机全名。)

New-OfficeWebAppsFarm -InternalURL "http://online.office"-ExternalUrl "http://192.168.8.132" -AllowHttp –EditingEnabled

–InternalURL内部访问地址,一般是http://机器名.AD域控地址;

–AllowHttp  是否允许http访问;

- ExternalUrl 外部访问地址,一般是服务器的ip地址;

  –EditingEnabled 允许编辑office。

 

回车出现下图:

输入Y成功后返回如下信息:

我们可以在服务器的浏览器中输入下列Url以求证:

http://online.office/hosting/discovery

出现以下信息说明部署成功。

3 WOPI协议(Java)

3.1Wopi协议简介

WOPI的英文全称是“Web Application OpenPlatform Interface”,中文名为“Web应用程序开放平台接口协议”。WOPI协议提供一系列基于web方式的,使文档能在Office Web Apps中查看与编辑的接口服务(Web Service)。只要web application按照标准,实现了WOPI的接口,那么就可以调用Office Web Apps。例子很多,比如SharePoint,Exchange,SkyDriver,Dropbox集成Office Web Apps。

在WOPI中,存在WOPI Server(或者称之为WOPI Host)和WOPI Client两种角色,OfficeOnline Server用作WOPIClient,而我们所开发的部分用作WOPIServer。这个协议的交互过程见下图:

在图中我们能够看到,WOPI Client共向WOPI Server进行了两次请求分别是Tell me about the file以及Give me the file。因此我们所开发的WOPI Server至少需要提供两个接口以实现这两个功能。

3.2Wopi协议信息结构体

 "AllowExternalMarketplace":{"type":"bool","default":false,"optional":true}, 

 "BaseFileName":{"type":"string","optional":false}, 

 "BreadcrumbBrandName":{"type":"string","default":"","optional":true}, 

 "BreadcrumbBrandUrl":{"type":"string","default":"","optional":true}, 

 "BreadcrumbDocName":{"type":"string","default":"","optional":true}, 

 "BreadcrumbDocUrl":{"type":"string","default":"","optional":true}, 

 "BreadcrumbFolderName":{"type":"string","default":"","optional":true}, 

 "BreadcrumbFolderUrl":{"type":"string","default":"","optional":true}, 

 "ClientUrl":{"type":"string","default":"","optional":true}, 

 "CloseButtonClosesWindow":{"type":"bool","default":false,"optional":true}, 

 "ClosePostMessage":{"type":"bool","default":false,"optional":true}, 

 "CloseUrl":{"type":"string","default":"","optional":true}, 

 "DisableBrowserCachingOfUserContent":{"type":"bool","default":false,"optional":true}, 

 "DisablePrint":{"type":"bool","default":false,"optional":true}, 

 "DisableTranslation":{"type":"bool","default":false,"optional":true}, 

 "DownloadUrl":{"type":"string","default":"","optional":true}, 

 "EditAndReplyUrl":{"type":"string","default":"","optional":true}, 

 "EditModePostMessage":{"type":"bool","default":false,"optional":true}, 

 "EditNotificationPostMessage":{"type":"bool","default":false,"optional":true}, 

 "FileExtension":{"type":"string","default":"","optional":true},  

 "FileNameMaxLength":{"type":"integer","default":250,"optional":true},  

 "FileSharingPostMessage":{"type":"bool","default":false,"optional":true}, 

 "FileSharingUrl":{"type":"string","default":"","optional":true},  

 "FileUrl":{"type":"string","default":"","optional":true}, 

 "HostAuthenticationId"{"type":"string","default":"","optional":true}, 

 "HostEditUrl":{"type":"string","default":"","optional":true}, 

 "HostEmbeddedEditUrl":{"type":"string","default":"","optional":true}, 

 "HostEmbeddedViewUrl":{"type":"string","default":"","optional":true}, 

 "HostName":{"type":"string","default":"","optional":true}, 

 "HostNotes":{"type":"string","default":"","optional":true}, 

 "HostRestUrl"{"type":"string","default":"","optional":true}, 

 "HostViewUrl":{"type":"string","default":"","optional":true}, 

 "IrmPolicyDescription":{"type":"string","default":"","optional":true}, 

 "IrmPolicyTitle":{"type":"string","default":"","optional":true}, 

 "LicenseCheckForEditIsEnabled":{"type":"bool","default":false,"optional":true}, 

 "OwnerId":{"type":"string","optional":false}, 

 "PostMessageOrigin"{"type":"string","default":"","optional":true}, 

 "PresenceProvider"{"type":"string","default":"","optional":true}, 

 "PresenceUserId"{"type":"string","default":"","optional":true}, 

 "PrivacyUrl":{"type":"string","default":"","optional":true}, 

 "ProtectInClient":{"type":"bool","default":false,"optional":true}, 

 "ReadOnly":{"type":"bool","default":false,"optional":true}, 

 "RestrictedWebViewOnly":{"type":"bool","default":false,"optional":true}, 

 "SHA256":{"type":"string","optional":true}, 

 "SignInUrl":{"type":"string","default":"","optional":true}, 

 "SignoutUrl":{"type":"string","default":"","optional":true}, 

 "Size":{"type":"int","optional":false}, 

 "SupportsCoauth":{"type":"bool","default":false,"optional":true}, 

 "SupportsCobalt":{"type":"bool","default":false,"optional":true}, 

 "SupportsExtendedLockLength":{"type":"bool","default":false,"optional":true}, 

 "SupportsFileCreation":{"type":"bool","default":false,"optional":true}, 

 "SupportsFolders":{"type":"bool","default":false,"optional":true}, 

 "SupportsGetLock":{"type":"bool","default":false,"optional":true}, 

 "SupportsLocks":{"type":"bool","default":false,"optional":true}, 

 "SupportsRename":{"type":"bool","default":false,"optional":true}, 

 "SupportsScenarioLinks":{"type":"bool","default":false,"optional":true}, 

 "SupportsSecureStore":{"type":"bool","default":false,"optional":true}, 

 "SupportsUpdate":{"type":"bool","default":false,"optional":true}, 

 "SupportsUserInfo":{"type":"bool","default":false,"optional":true}, 

 "TenantId"{"type":"string","default":"","optional":true}, 

 "TermsOfUseUrl":{"type":"string","default":"","optional":true}, 

 "TimeZone"{"type":"string","default":"","optional":true}, 

 "UniqueContentId":{"type":"string","default":"","optional":true}, 

 "UserCanAttend":{"type":"bool","default":false,"optional":true}, 

 "UserCanNotWriteRelative":{"type":"bool","default":false,"optional":true}, 

 "UserCanPresent":{"type":"bool","default":false,"optional":true}, 

 "UserCanRename":{"type":"bool","default":false,"optional":true}, 

 "UserCanWrite":{"type":"bool","default":false,"optional":true}, 

 "UserFriendlyName":{"type":"string","default":"","optional":true}, 

 "UserId":{"type":"string","default":"","optional":true}, 

 "UserInfo":{"type":"string","default":"","optional":true}, 

 "Version":{"type":"string","optional":false}, 

 "WebEditingDisabled":{"type":"bool","default":false,"optional":true} 

 } 

 

3.3Wopi协议实现(Java)

  Java实现上面的两个功能接口Tell me about the file以及Give me the file,因为要实现对word的编辑功能所以要实现以下三个接口:

GETwopi/files/{name}?access_token={access_token}

GETwopi/files/{name}/contents?access_token={access_token}

POSTwopi/files/{name}/contents?access_token={access_token}

第一个接口获取文件的信息,返回的是json数据格式;

第二个是获取文件流;

第三个是保存修改文件。

GETwopi/files/{name}?access_token={access_token}接口的实现

GETwopi/files/{name}/contents?access_token={access_token}

POSTwopi/files/{name}/contents?access_token={access_token}

 

4. Java项目整合Office Online Server

4.1在java项目中配置接口

在java web 项目中配置Servlet实现接口,用Filter拦截用户请求“@WebFilter("/wopi/*")”在拦截器中实现上面三个接口,当用户请求中含有wopi时就会执行。例如访问路径(word 在线编辑):

http://192.168.8.132/we/wordeditorframe.aspx?WOPISrc=http%3A%2F%2F192.168.8.129%3A8080%2FSmartSchool%2Fwopi%2Ffiles%2Ffs%2Ft2.docx

其中:

192.168.8.132:为转换服务器的ip地址

we/wordeditorframe.aspx : officeonline server 提供的xml action 方法(4.2介绍)

WOPISrc: wopi协议,参数为经过UTF-8加密后的服务器下文件的路径。

文件下载的路径后应该添加/contents例如:

http://127.0.0.1:8080/SmartSchool/wopi/files/1.docx/contents

测试界面:

4.2微软提供的xml方法示例(部分)

Excel操作:

PPT操作:

Word操作:

5.其他问题

5.1 安装Update for WindowsServer 2012 R2 (KB2919355)问题

 安装Update for WindowsServer 2012 R2 (KB2919355)会出现时间安装过长,安装过程报错的问题。当这种问题出现的情况下可以执行以下操作:

1.      关闭windows自动更新;

2.      打开C:\Windows\SoftwareDistribution\Download删除该目录下的所有文件;

3.     打开 C:\Windows\SoftwareDistributionDataStore删除该目录下的所有文件;

4.     重启服务器,再次安装程序即可。

5.2 虚拟机下网络通信问题(win10系统下)

在虚拟机下安装部署Office Online Server ,宿主机所在的局域网的其他计算机无法访问虚拟机Office Online Server 服务器部署的项目。如遇到此类问题请按照以下步骤执行操作:

1.     同时选中虚拟网卡“VMwareNetwork Adapter VMnet8”和“以太网”,右键选择“桥接”,系统自动创建一个网桥“网桥”;

2.     修改网桥“网桥”的IPv4为静态IP(如下图所示),测试本机可以上网。

3.     打开VMware主程序,“编辑”-“虚拟网络编辑器”,将VMnet8的子网IP改成10.80.5.0 网段为:255.255.255.0;

4.     虚拟机”-“设置”-“网络适配器”-“自定义特定网络”-“VMnet8(NAT模式)”-“确定”。

5.     若进入虚拟机,系统显示“本地连接”未连接。右键点击VMware主程序右下角“网络状态图标”-“连接”。

6.     操作结束,虚拟机可以和外界进行通信。

更多推荐

基于Office Online Server 2016 的 office在线编辑

本文发布于:2023-06-14 03:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1433992.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:在线   编辑   Online   Office   Server

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!