Building an Office Web Apps (OWA) WOPI Host

This solution gives you a simple WOPI Host that provides viewing, and editing through Office Web Apps via a custom WOPI Server. Illustrates the implementation of WOPI for a Server in a working example.

C# (2.7 MB)
 
 
 
 
 
(12)
4,547 times
Add to favorites
10/15/2015
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Files location
    2 Posts | Last post May 17, 2016
    • Hello,
      
      Is it possible to store the files somewhere else and only use OWA Server for viewing, editing purposes?
    • That's exactly what OWA Server is for.
      But you need to have a Wopi server which could access stored files (with read and write permissions).
  • Editing word gives error
    1 Posts | Last post April 28, 2016
    • I am able to setup this sample in my environment (everything onpremise). I am able to edit the pptx and xlsx files but the word/.docx gives error as mentioned by others. Error message is "Sorry, this document can't be opened for editing".
      
      As pointed by Shawn, I looked into the sample in Github.com which is more difficult to setup as it has a HttpHandlers only. But I could see in the code that if there is a POST request with header "X-WOPI-Override" ="COBALT", it returns unsupported.
      
      In the sample code given in this post, I added a new POST handler as follows and could see that its getting hit with a header "X-WOPI-Override" ="COBALT" but no idea how to deal with it. Sample in the Github also not handling it.
      In FilesController.cs
      [Route("files/{name}/")]
              public string PostLock()
              {
                  //Put a break point here and could see Request.Headers["X-WOPI-Override"] in the header and its "Cobalt"
                  return "dummy";
              }
      
      Can somebody point to a complete sample where I can edit all the office files using OWA?
      Thanks in advance
      Joy
  • What should be the Value of appWopiServer ?
    1 Posts | Last post March 14, 2016
    • Hi Shawn,
      
      First of all thanks for a good article for usage of WOPI. I went through it and most of the things are self explanatory.I have configured it against our own webapps server and downloaded the discovery.xml from the local installation. It generates a local url for us now.
      
      However, the value of appWopiServer still remains in question. What should go there ? 
      
      I hosted your application on IIS with Anonymous access and put the files in a files folder specifically created to test application. So when I test this hosted application and type in the url http://mymachinename/files/test.docx, it downloads the file on my system even when trying from remote machine. So after this I replaced the appWopiServer = "http://mymachinename/files/" instead of your url in the web.config. 
      
      The url generated gives me a "Server Error" when trying to open it. Am I missing anything here ? 
      
      Eg for genrated url is : http://mywebappserver/we/wordeditorframe.aspx?WOPISrc=http%3a%2f%2fmymachinename%2ffiles%2ftest.docx&access_token=77234j%3d4k24972734324j32g32gt447423jh3224234jg2347%3d
      
      
      Regards,
      Kushagra 
  • WOPI: Not able to edit word(.docx) and Power Point(.pptx) document using office online
    2 Posts | Last post February 27, 2016
    • As far as I see Office Online supports WOPI, I took this project as an example to implement mine using WebAPI.
      
      I copied the Discovery.xml file from https://onenote.officeapps-df.live.com/hosting/discovery this location.
      
      Replaced the Placeholder values as per mentioned in https://wopi.readthedocs.org/en/latest/discovery.html#placeholder-values this document.
      
      As I have registerd the domain at Microsoft, so I replaced updated domain name in appWopiServer parameter in web.config file.
      
      When we open the Test.xlsx file, It open in both the mode(View/Edit) without any error.
      But when I tried to open Test.docx file, getting an error popup "Sorry, this document can't be opened for editing. Tell us about this problem to help us fix it." with one button as "Open in Reading View"
      
      If we click on "Open in Reading View" button, document getting open in read mode.
      
      I have the couple of concerns regarding the sample you provided :
      
      1. Is this sample is capable to edit the .docx file using office online? If yes, then am I missing something?
      
      While going through the documentation In the lock section "https://wopi.readthedocs.org/projects/wopirest/en/latest/files/Lock.html#lock" it is mentioned that, "To support editing files, WOPI clients require that the WOPI host support locking files."
      
      2. So my concern is like, do we need to have Lock as a mandetory, to edit .docx file using office online?
      
      As the sample provided in the documentation https://github.com/Microsoft/Office-Online-Test-Tools-and-Documentation/tree/master/samples/SampleWopiHandler, where this sample implementation illustrates many of the concepts necessary to implement a WOPI server.
      
      3. Do we need to integrate all those methods to enable word editing?
      
       I am just wondering without the right path, could you please explain the right way to eanble word editing?
      
      So your response will be greatly appriciated.
      
      Thanks.
      
    • Have been doing some work on wopi lately and will share my observations..maybe not answering questions and yet good to know we are all working together on some exiting stuff.
      The sample here is host..we need to create a client too, which is not trivial, so please try using your O365 account or some other clients 
  • Not able to open "test.docx" using your example.
    1 Posts | Last post February 12, 2016
    • Getting error "Something went wrong and we couldn't load this content. Refreshing the browser may fix the problem.
  • WOPI: Could not deserialize file metadata
    1 Posts | Last post January 16, 2016
    • Hi Shawn,
      
      I've been looking for a online word editing in a browser and came across your solution. 
      
      In my log files I see the following error, how can I rectify this error?. 
      WOPI: Could not deserialize file metadata  
      WOPI: Invalid file metadata
      
      I've been struggling to find an answer for this for past one week, if you can shed any light for this problem that would be wonderful and appreciate it.
      
      Thanks
      John
  • Always getting error
    7 Posts | Last post January 15, 2016
    • Sorry, there was a problem and we can't open this document.  If this happens again, try opening the document in Microsoft Word.
      Any ideas?
      Logs: 
      WOPI: Could not deserialize file metadata [url:http://edv05wopi/wopi/files/test2.docx, e:There was an error deserializing the object of type Microsoft.Office.OpenWebApplication.WopiCheckFileResponse. Encountered unexpected character 'P'.]	36e24a4a-e7a3-4e67-aa59-aea55c224336
      WOPI: Invalid file metadata [url:http://edv05wopi/wopi/files/test2.docx, triggers:(No Hash No Version No FileName No OwnerId), data:PK          !  $���   �       [Content_Types].xml �  (�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ��MO�@ ��&� �W �z0Ɣ����M��.C��~dg��� JK���Z���2��� 3��J�� <*kR�Oz, #m��,e�����E ��Di �l �F�ˋ�t� #�6...	36e24a4a-e7a3-4e67-aa59-aea55c224336
    • Does it happen with all files or just 1.  Is this using the sample solution that was provided?
    • office web apps servers preview pdf on custom system?
    • Write their own project called office web apps preview PDF server, what do you want to configure, and what pay attention to the url format?
    • Roberto/Shawn,
      
      I am able to render text file data but for word data I see exactly the same response as mentioned by Roberto for word data in my custom WOPI client.
      
      What was the solution that you found?
      
    • Can you clarify? You have a custom WOPI Client and you're NOT using Office Web Apps?  If true, then what you're seeing is an OpenXML document "binary" stream. 
      
      A WOPI server's responsibility is to return a binary stream, not handle the editing.  It is properly returning an OpenXML (docx) file to the WOPI Client (yours).  That stream you're getting, prefixed with PK - is an OpenXML document.  
      
      The WOPI client must then decide what to do with that binary stream.  If it's OpenXML, OWA can handle it. If it's a custom WOPI client, then you'd have to interpret OpenXML.
    • Hi Shawn,
      
      I'm using your latest solution. the Word Web App tries to load it, but it throwing an error. In the log file I got the same error message as specified by Roberto. How can I resolve this issue? 
      
      Thank you!!
  • PPT edition issue (cache)
    1 Posts | Last post December 18, 2015
    • Hi all,
      
      I took this project as an example to implement mine using WebAPI. However, i'm having some issues trying to edit PowerPoint files. In example:
      
      - I open file A.pptx and take it in view mode
      - Click on "Edit in browser" button and file opens in edit mode correctly.
      - Then, open file B.pptx in view mode.
      - Click on "Edit in browser" button and OWA opens file A.pptx contents in edit mode but using file B.pptx properties.
      
      I think it's some related with cache but I cannot solve it.
      
      Any help will be appreciated.
      
      Regards,
      
      Brian.
  • http://owa1.wingtip.com/we/wordeditorframe.aspx? not able to access
    1 Posts | Last post November 16, 2015
    • I've tried to run it and Open test document.docx to edit and it showed me:
      "The requested URL could not be retrieved
      
      
      While trying to retrieve the URL: http://owa1.wingtip.com/we/wordeditorframe.aspx? 
      
      The following error was encountered: 
      
      Unable to determine IP address from host name for owa1.wingtip.com 
      
      The dnsserver returned: 
      
      Name Error: The domain name does not exist. 
      
      This means that: 
       The cache was not able to resolve the hostname presented in the URL. 
       Check if the address is correct. 
      "
       As mentioned in below thread, I need to have host entry -" host entries in your /etc/hosts file, which is in c:\windows\system32\drivers\etc" 
      
      Can you please show me which entry need to do?
      
  • still error
    2 Posts | Last post October 11, 2015
    • Hi, I have did all things but still go wrong when CheckFileInfo called. here is my error messages taken from owa logs:
      
      10/10/2015 20:22:37.50 	w3wp.exe (0x1F14)                       	0x0FDC	Office Web Apps               	WAC Hosting Interaction       	adhsg	Monitorable	WOPI: Could not deserialize file metadata [url:http://10.1.139.234/api/wopi/files/test.docx, e:Expecting state 'Element'.. Encountered 'Text'  with name '', namespace ''. ]	b8317122-6964-4208-97a0-e89b702e61ac
      10/10/2015 20:22:37.50 	w3wp.exe (0x1F14)                       	0x0FDC	Office Web Apps               	WAC Hosting Interaction       	adhsh	Monitorable	WOPI: Invalid file metadata [url:http://10.1.139.234/api/wopi/files/test.docx, triggers:(No Hash No Version No FileName No OwnerId), data:"{\"BaseFileName\":\"test.docx\",\"OwnerId\":\"admin\",\"SHA256\":\"oYokqCFw8WdWi00+5mhnn4GL1g+QXRuCDF6NIL3eYUU=\",\"Size\":272244,\"Version\":\"1\"}"]	b8317122-6964-4208-97a0-e89b702e61ac
      
      It seems json deserialize error, but i swear that it's truely correct.  Help me please ... Thanks very much.
    • You may want to take a look at another WOPI host implementation here: 
      
      https://github.com/Microsoft/Office-Online-Test-Tools-and-Documentation/tree/master/samples
      
      
1 - 10 of 42 Items