Giter Club home page Giter Club logo

wopihost's Introduction

Logo WopiHost

Build & Test codecov Maintainability CodeFactor FOSSA Status .NET Core

Package Version Downloads
WopiHost.Abstractions NuGet NuGet
WopiHost.Core NuGet NuGet
WopiHost.Discovery NuGet NuGet
WopiHost.FileSystemProvider NuGet NuGet
WopiHost.Url NuGet NuGet

Supporters

Sponsors

scottgal

Contributors

Contributors

Introduction

This project is a sample implementation of a WOPI host. Basically, it allows developers to integrate custom datasources with Office Online Server (formerly Office Web Apps) or any other WOPI client by implementing a bunch of interfaces.

Features / improvements compared to existing samples on the web

  • clean WebAPI built with ASP.NET Core MVC (no references to System.Web)
  • uses new ASP.NET Core features (configuration, etc.)
  • can be self-hosted or run under IIS
  • file manipulation is extracted to own layer of abstraction (there is no dependency on System.IO)
    • example implementation included (provider for Windows file system)
    • file identifiers can be anything (doesn't have to correspond with the file's name in the file system)
  • custom token authentication middleware
  • DI used everywhere
  • URL generator
    • based on a WOPI discovery module
  • all references are NuGets

Usage

Prerequisites

Building the app

The WopiHost app targets net8.0 exclusively.

If you need a version that's targeting an older version of .NET, check out the releases:

If you get errors saying that Microsoft.CobaltCore.*.nupkg can't be found, then just remove the reference or see the chapter Cobalt below.

Configuration

WopiHost

WopiHost\appSettings.json

Parameter Sample value Description
Wopi:StorageProviderAssemblyName "WopiHost.FileSystemProvider" Name of assembly containing implementation of WopiHost.Abstractions interfaces
Wopi:StorageProvider:RootPath ".\\wopi-docs" Provider-specific setting used by WopiHost.FileSystemProvider (which is an implementation of IWopiStorageProvider working with System.IO)
Wopi:UseCobalt true Whether or not to use MS-FSSHTTP for file synchronization. More details at Cobalt

WopiHost.Web

WopiHost.Web\appSettings.json

Parameter Sample value Description
Wopi:HostUrl "http://wopihost:5000" URL pointing to a WopiHost instance (above). It's used by the URL generator.
Wopi:ClientUrl "http://owaserver" Base URL of your WOPI client - typically, Office Online Server - used by the discovery module to load WOPI client URL templates
Wopi:StorageProvider:RootPath "..\\..\\WopiHost\\wwwroot\\wopi-docs" Provider-specific setting used by WopiHost.FileSystemProvider (which is an implementation of IWopiStorageProvider working with System.IO)
Wopi:Discovery:NetZone "InternalHttp" Determines the target zone configuration of your OOS Deployment. Values correspond with the NetZoneEnum.

Additionally, you can use the secret storage to configure both of the apps.

Running the application

Once you've successfully built the app you can:

  • run it directly from the Visual Studio using IIS Express or self-hosted.
    • make sure you run both WopiHost and WopiHost.Web. You can set them both as startup projects
  • run it from the cmd
    • navigate to the WopiHost folder and run dotnet run
  • run it in IIS (tested in IIS 8.5)
    • TODO

Compatible WOPI Clients

Running the application only makes sense with a WOPI client as its counterpart. WopiHost is compatible with the following clients:

Note that WopiHost will always be compatible only with the latest version of OOS because Microsoft also supports only the latest version.

The deployment of OOS/OWA requires the server to be part of a domain. If your server is not part of any domain (e.g. you're running it in a VM sandbox) it can be overcome by promoting your machine to a Domain Controller. To test your OWA server follow the instructions here. To remove the OWA instance use Remove-OfficeWebAppsMachine.

Cobalt

In the past (in Office Web Apps 2013), some HTTP actions required support of MS-FSSHTTP protocol (also known as "cobalt"). This is no longer true with Office Online Server 2016. However, if the WOPI client discovers (via SupportsCobalt property) that the WOPI host supports cobalt, it'll take advantage of it as it's more efficient.

If you need or want your project to use Cobalt, you'll need to create a NuGet package called Microsoft.CobaltCore.nupkg containing Microsoft.CobaltCore.dll. This DLL is part of Office Web Apps 2013 / Office Online Server 2016 and its license doesn't allow public distribution and therefore it's not part of this repository. Please always make sure your OWA/OOS server and user connecting to it have valid licenses before you start using it.

Using in your web project

TODO

Extending

TODO

Known issues / TODOs

There is plenty of space for improvements in the overall architecture, implementation of the [MS-*] protocols or just finishing the TODOs in the code. Lot of refactoring still needs to be done and also the code style has to be unified. So please feel free to help me out with it :)

Contributing

https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/

License

Useful resources

Building WOPI Host

MS-FSSHTTP (Cobalt)

Building WOPI Client

FOSSA Status

wopihost's People

Contributors

demigodplayz avatar dependabot[bot] avatar dvojitywendy avatar fossabot avatar fredikats avatar jj-connect avatar petrsvihlik avatar whocarrot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wopihost's Issues

Update documentation on hosting + support all possible hosting options

Error during Opening the url of edit document

I am getting this error when I was trying to open the edit url
by the next url

http://owas.cmsad.local/we/wordeditorframe.aspx?WOPISrc=http%3a%2f%2fowas.cmsad.local%2fhosting%2fdocs%2ftest.docx&access_token=IXuJCdjmmhc%3dHfPAmKzzT%2bs7zJpT4czLS4SVv1kBeGsIpbtJxaq%2f6mQ%3d&ui=zh-CN

Exception WAC Server FrontEnd unhandled exception [0] Microsoft.Office.Web.Common.EnvironmentAdapters.FileUnknownException: required URL paramters are not present at Microsoft.Office.Web.Apps.Common.WopiDocument.CreateFromQuerySignature(String querySignature) at Microsoft.Office.Web.Apps.Environment.WacServer.WSMainStorage.GetBaseDocumentFromContext(HttpContext context, String rawHostDocumentId) at Microsoft.Office.Web.Host.WacServer.WebOneNote.WoncaFrame.OnPreRender(EventArgs e) at Microsoft.Office.Web.Host.WacServer.WebOneNote.WordEditorFrame.OnPreRender(EventArgs e) at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) StackTrace: at uls.native.dll: (sig=2... 6b5565bf-0574-4f6e-8c6c-f9d0c1549913

Incorporate .NET Core 1.1/2.0/3.0 Changes

Split FilesController.PerformAction method to many per X-WOPI-Override header value

Add xunit runner to appveyor

Implement Folders & Containers endpoints

Set up code coverage on comit

Set up on of the following:

  1. Download OpenCover
  2. Run OpenCover
  3. Upload OpenCover's results

running opencover with .net core:

example of opencover with dotnet cli:
http://stackoverflow.com/questions/36460254/vs2015-code-coverage-not-working-with-tests-in-asp-net-core-1-0-formerly-known

working code:
OpenCover.Console.exe -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:" test ""C:\Users\petrs\Documents\GitHub\WopiHost\WopiHost.FileSystemProvider.Tests\project.json"" -f netcoreapp1.0 -xml ""C:\Users\petrs\Documents\GitHub\WopiHost\WopiHost.FileSystemProvider.Tests\xunit-results.xml"" -nologo -parallel none" -output:"C:\Users\petrs\Documents\GitHub\WopiHost\coverage.xml" -register:user -filter:"+[*]* -[xunit*]* -[*]*Migrations.*" -returntargetcode -oldstyle

-oldstyle argument required until OpenCover/opencover#595 gets implemented

another example that should work:
c:\Users\tmds\AppData\Local\Apps\OpenCover\OpenCover.Console.exe "-target:C:\Program Files\dotnet\dotnet.exe" -targetargs:test -register:user -filter:"+[*]* -[xunit*]*" -output:coverage.xml -oldStyle

opencover+appveyor example:
https://github.com/jwaliszko/ExpressiveAnnotations

other resources:
https://github.com/OpenCover/opencover/wiki/DNX-Support
http://blog.stephencleary.com/2015/03/continuous-integration-code-coverage-open-source-net-coreclr-projects.html
http://dotnetthoughts.net/measuring-code-coverage-of-aspnet-core-applications-using-opencover/
http://help.appveyor.com/discussions/problems/4394-problem-with-args-to-xunit-in-powershell
OpenCover/opencover#327

Full YMLs:

How and where can I get the WOPI Client (Office web app server) error logs

Hi petrsvihlik, my issue is rather related to a general problem then to your source code, I am sorry if you didn't like me raising this question as an issue. I found you most active on WOPI platform.

I have implemented the WOPI Host and client on Windows Server 2012 RC, I can access the discovery url but when I am trying to open a office file on the browser, the file is not getting load.

I can see the logs of WOPI Host but how can I see the WOPI Client error logs ? when I further investigated I found in the IIS Administrator tools under event viewer there are lots of error logs related to Office Web Apps Server and all are showing "Reported Status :Machine Health is UnHealthy".

Please let me know if you have any idea on this issue.

Fix RC2 breaking changes

Create sample integrating with office online

Implement Authorization properly

.net core bug - system.net.http

waiting for this to be resolved:
https://github.com/dotnet/corefx/issues/11100

workaround:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
        <bindingRedirect oldVersion="4.1.1.0" newVersion="4.0.0.0"/>
      </dependentAssembly>
</assemblyBinding>
  </runtime>
</configuration>

Fix rc1 breaking changes

aspnet/Announcements#77
aspnet/Announcements#80
aspnet/Announcements#91
aspnet/Announcements#93
aspnet/Announcements#97
aspnet/Announcements#98
aspnet/Announcements#104
aspnet/Announcements#113
aspnet/Announcements#116 (aspnet/Announcements#64 (comment)) ✅

appveyor
A single continuous-integration/appveyor GitHub commit status was replaces with two separate statuses: continuous-integration/appveyor/branch and continuous-integration/appveyor/pr for regular "push" and PR builds respectively.
If you have protected GitHub branches checking AppVeyor status please update them now to use new continuous-integration/appveyor/pr status.

Where to download the client discovery XML from for Office Online WOPI Client?

First of all, very nice. Thank you so much. Your project is very helpful for me.

I see that you have the client discovery XML for Office Online inside your discovery tests and you're probably using your FileSystemDiscoveryProvider (or some such) to load the downloaded file.

But if I need to use your HttpDiscoveryProvider to get the XML from the Web, at what URL may I find the client discovery XML file for Office Online?

You may answer the question here or on StackOverflow or both.

My question is: https://stackoverflow.com/questions/45429487/from-where-may-i-get-the-wopi-client-discovery-xml-for-the-wopi-client-office-on

Permalink: https://stackoverflow.com/q/45429487/303685

Once more, thanks for such a wonderful effort.

can't view word but can edit

Have you ever met this issue?
Excel can be viewed and edited. Word can't (not all files, some can be viewed ), all of them are editable though.I'm wondering if this bug was caused by oos server?

Will this project run on linux/.Net Core

Hello,

Thanks for the great sample. WIll this run on Linux and .Net Core? If yes which version of .Net Core would you suggest I try to play around?

Thanks,
G

hi @petrsvihlik

I'm run your project in my PC very well, but WopiHost show message like this:
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[0]
An unhandled exception has occurred while executing the request
System.FormatException: The input is not a valid Base-64 string as it contains a
non-base 64 character, more than two padding characters, or an illegal characte
r among the padding characters.
at System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, B
yte* startDestPtr, Int32 destLength)
at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
at System.Convert.FromBase64String(String s)
at WopiHost.FileSystemProvider.WopiFileSystemProvider.DecodeIdentifier(String
identifier) in D:\WopiHost-master(4)\WopiHost-master\WopiHost.FileSystemProvide
r\WopiFileSystemProvider.cs:line 97
at WopiHost.FileSystemProvider.WopiFileSystemProvider.GetWopiFile(String iden
tifier) in D:\WopiHost-master(4)\WopiHost-master\WopiHost.FileSystemProvider\Wop
iFileSystemProvider.cs:line 47
at WopiHost.Core.Controllers.FilesController.d__11.MoveNext
() in D:\WopiHost-master(4)\WopiHost-master\WopiHost.Core\Controllers\FilesContr
oller.cs:line 64
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionEx
ecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next
, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__
20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware1.<Invoke>d__ 18.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware1.d__
18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.
d__7.MoveNext()
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 1040.8624ms 500 text/html; charset=utf-8

It may possibly cannot support file with chinese character filename ???
i have file named chinese character filename in wopi-docs.

How to support chinese character filename ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.