Sunday 17 November 2019

Office Online Server (WOPI protocol) With SharePoint Foundation

When you try to open any MS-Office file in SharePoint Online, you will able to see that it opens the file in a browser using WOPI protocol.
Where you not only view but also, modify the file and WOPI protocol makes the file available for Co-authoring also and a lot more.

This week, I installed and configured Office Online Server (OOS) for SharePoint foundation to understand how WOPI protocol works with SharePoint foundation (And will work with the free version of SharePoint?).
I have my SharePoint foundation installed on Server 2012 R2. To install Office Online Server, I picked Server 2016 (To show that we OS is not required to be same) and installed OOS 2016.
Please note- Office Online Server is   OS-dependent. SO, if want to use OOS 2016 then OS should be 2016 and if you want to install OOS 2012 then you need OS 2012 and so on.
Prerequisites to install OOS are as follows:
There are two possible ways to install Prerequisites:

1.   Windows PowerShell: 

Add-WindowsFeature Web-Server,Web-Mgmt-Tools,Web-Mgmt-Console,Web-WebServer,Web-Common-Http,Web-Default-Doc,Web-Static-Content,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression,Web-Security,Web-Filtering,Web-Windows-Auth,Web-App-Dev,Web-Net-Ext45,Web-Asp-Net45,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Includes,NET-Framework-Features,NET-Framework-45-Features,NET-Framework-Core,NET-Framework-45-Core,NET-HTTP-Activation,NET-Non-HTTP-Activ,NET-WCF-HTTP-Activation45,Windows-Identity-Foundation,Server-Media-Foundation

2.   Windows PowerShell ISE:

Import-Module ServerManager
Add-WindowsFeature Web-Server,Web-Mgmt-Tools,Web-Mgmt-Console,Web-WebServer,Web-Common-Http,Web-Default-Doc,Web-Static-Content,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression,Web-Security,Web-Filtering,Web-Windows-Auth,Web-App-Dev,Web-Net-Ext45,Web-Asp-Net45,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Includes,NET-Framework-Features,NET-Framework-45-Features,NET-Framework-Core,NET-Framework-45-Core,NET-HTTP-Activation,NET-Non-HTTP-Activ,NET-WCF-HTTP-Activation45,Windows-Identity-Foundation,Server-Media-Foundation

3.   We also need to install the following S/W:
a.    NET Framework 4.5.2
b.    Visual C++ Redistributable Packages for Visual Studio 2013
c.    Visual C++ Redistributable for Visual Studio 2015
d.    Microsoft.IdentityModel.Extention.dll

After installing above-defined Prerequisites, I would say, please restart the server and then install Office Online Server 2016.

If not downloaded then please download from Volume Licensing Service Center (VLSC). Office Online Server is a component of Office,

so it is available under each of the product pages including Office Standard 2016, Office Professional Plus 2016, and Office 2015 for Mac Standard.

Installing Office Online Server is as same as installing MS-Office.

Few more points to talk:
1-   Office Online Server should be installed in either the same domain or the domain having trust with another domain where SharePoint installed.

2-   Install Office Online Server on the system drive.

3-   If you plan to use Kerberos Constrained Delegation, be sure to add each server in the Office Online Server farm to the Active Directory Domain Services delegation list.


Once installation is done, we need to configure the OOS. To do this we either use HTTP or https.

For https: we need a certificate (For testing we can use Self-signed certificate). I used HTTP for my lab.

import-module “C:\Program Files\Microsoft Office Web Apps\AdminModule\OfficeWebApps\OfficeWebApps.psd1”

# OWA Parameters
$InternalhttpURL = http://oos.sp.local
$InternalhttpsURL = https://oos.sp.local       # https
$LogLocation = "C:\OOS\OfficeOnlineServerLogs\LogsOS"
$maxMemoryCacheSizeInMB = 75  #Default 75
$CacheSizeInGB = 15  #Default 15
$CacheLocation = "C:\OOS\OfficeServer\DiskCache"
$RenderingLocalCacheLocation = "C:\OOS\OfficeServer\RenderingCache"

# For Http
New-OfficeWebAppsFarm -InternalUrl $ InternalhttpURL -LogLocation $LogLocation -CacheLocation $CacheLocation -RenderingLocalCacheLocation $RenderingLocalCacheLocation -AllowHttp -EditingEnabled

#For Https
New-OfficeWebAppsFarm -InternalUrl $ InternalhttpsURL -LogLocation $LogLocation -CacheLocation $CacheLocation -RenderingLocalCacheLocation $RenderingLocalCacheLocation  -EditingEnabled

During configuration, it will prompt for “Continue with this operation?” You need to select Yes. Once done, you will get the following result:

Now open the IIS and you will see a couple of Sites as follows:



For verification, Open https://<server name>/hosting/discovery Site in the browser (For me it is http://oos.sp.local/hosting/discovery)

Please save net-zone name (OR keep in mind as we need this while associating with SharePoint)

Please note that I am using Single Farm but for Production, if you have a large number of concurrent users, then I would suggest, doing load balancer and add more OOS servers. Please see below MSDN article for the same


Now, OOS installation and configuration has been completed and we need to switch to SharePoint Server and need to associate OOS with SharePoint.
To associate with SharePoint, we need to run the following PS script:

Add-PSSnapin Microsoft.SharePoint.PowerShell
New-SPWOPIBinding -ServerName oos.sp.local #<OOS server>

Once done, then run following script to get SharePoint WOPI zone
Get-SPWOPIZone

It should match the net-zone (As I asked you either to save or memorize from discovery URL). In my case it should "internal-http"
If not the same (like it showing "internal-https" then you will get “Sorry, something went wrong” with correlation id. But neither ULS log nor OOS Log providing the exact issue. Sometime you will get the following issues:



To fix this you need to run following script:
Set-SPWOPIZone -zone "internal-http"

#For HTTPS
#Set-SPWOPIZone -zone "internal-https"

Once done, open your SharePoint document library and try to open any MS-Office file and it should work.

Few issues, that I faced:
1-   I got - “Sorry, something went wrong” with correlation id. But neither ULS log nor OOS Logs providing exact issue.
I found that, I am using System account and you can’t use System account with WOPI.

2-   If files get downloaded instead of opening in the browser –
Go to Advanced settings of Document library and check “Opening Documents in the Browser” setting.
If it set to “Open in Client application”, change it to “Open in the browser ” or “Use the server default (Open in the browser)


And make sure that “Open Documents in Client Applications by Default” is not active.

3-   If still files get downloaded instead of opening in the browser then go to Central Admin -> manage Web applications -> Select Web Application of your site collection and open “General Settings”
Under “Browser File Handling” select Permissive then Strict (By Default Strict is selected).

If everything will work fine then, your ms-office file will be opened in Browser as same as SharePoint online does.