2

I try to implement a custom Wopi host in C# that can handle the Cobalt Protocol using the CobaltCore assembly.

But I didn't found any documentation for CobaltCore.dll Object browser is a little helpful..

Please provide some details if someone had similar issue. How I should use Cobalt to decipher the messages?

rocky
  • 7,506
  • 3
  • 33
  • 48

3 Answers3

1

For word editing implementation go here:

Can I just use Office Web Apps Server

// fsshttpb payload, basically decode from base64 encoded

byte[] test1 = System.Convert.FromBase64String("DAALAJzPKfM5lAabBgIAAO4CAABaBBYADW1zd29yZAd3YWN6AggA1RyhD3cBFgIGAAMFABoEIAAL3Do4buY4RJXm4575cgEiigICAAALAawCAFUDAQ==");

// create an atom object from the fsshttp input
AtomFromByteArray atomRequest = new AtomFromByteArray(test1);

RequestBatch requestBatch = new RequestBatch();
requestBatch.DeserializeInputFromProtocol(atomRequest);

// now you can inspect requestBatch to view the decoded objects

edit:

Here is a sample implementation using CobaltCore. Pretty much a combination of my answers about WOPI/FSSHTTP on this website in one project.

https://github.com/thebitllc/WopiBasicEditor

Zach
  • 174
  • 2
  • 7
thebitllc
  • 366
  • 2
  • 5
  • Thank you for the answer. But now I need to update local storage data and create Response for the OWA to complete my ExecuteCellStorageRequest operation. Seems like it's more complicated. Could you please provide example or just tell me what from Cobalt API should I use? – Naumenko Julia Jun 02 '14 at 14:16
  • If you have the storage setup, then it's just CobaltFile.ExecuteRequestBatch(requestBatch); But getting that storage properly is much more difficult, SharePoint stores files in the MSSQL server. – thebitllc Jun 07 '14 at 14:46
  • I don't use SharePoint - I have own file storage. As you adviced, I used ExecuteRequestBatch. For that I created CobaltFile, but constructor also required instantiating DisposalEscrow, Dictionary, HostLockingStore and RequestProcessor[]. In the result I successful generated response, but it doesn't contain WebUrl and Url that MUST be specified for each ResponseCollection element and Request element according to documentation. I think that's why OWA still show me error message that this document can't be opened for editing. – Naumenko Julia Jun 09 '14 at 18:49
  • I updated my old answer with the code that answers your questions. http://stackoverflow.com/questions/17065029/can-i-just-use-office-web-apps-server – thebitllc Jun 13 '14 at 23:04
  • Thank you for examples - it's really helpful. I implemented similar and for now I found results of requesting my WOPI server ExecuteCellStorageRequest - C:\tmp\filestore\ contains some shredded blobs. C:\tmp\wacstore is empty. But my OWA still saying me "Sorry, this document can't be opened for editing". In your example you wrote FileAtom.FromExisting("C:\\tmp\\Test.docx", temp), but temp is not defined, you called your DisposalEscrow disposal = new DisposalEscrow("temp1"); What does it means - temp1? It's some forder on the WOPI server? According DisposalEscrow defition it shoud be owner – Naumenko Julia Jun 16 '14 at 19:08
  • Just replace temp with disposal. I was trying to optimize code when I was posting it. Did you implement hostlocking class? – thebitllc Jun 16 '14 at 19:17
  • I have CustomHostLockingStore inherited from HostLockingStore. But most of methods not implemented) But I added simple implementation to one required: public override GetExclusiveLockRequest.OutputType HandleGetExclusiveLock(GetExclusiveLockRequest.InputType input) { var output = new GetExclusiveLockRequest.OutputType(); return output; } – Naumenko Julia Jun 16 '14 at 19:30
  • I implemented HandleWhoAmI and HandleJoinCoauthoring with rest just returning an empty result object. – thebitllc Jun 17 '14 at 14:45
  • Here is a sample implementation using CobaltCore. Pretty much a combination of my answers about WOPI/FSSHTTP on this website in one project. https://github.com/thebitllc/WopiBasicEditor – thebitllc Jul 12 '14 at 20:28
  • Does this require OWA 2016 Preview? Also where from I can get the Microsoft.CobaltCore.dll. I am not able to find in my OWA 2013 server installation. – Joy George Kunjikkuru Apr 29 '16 at 14:46
1

Also implementing the Cobalt approach to edits and like Julia it stops at a "cant edit screen" even after lockingstore callbacks including co-author etc. What I have found however is the log system for OWA reveals quite considerable detail about what the OWA server is attempting to do. C:\ProgramData\Microsoft\OfficeWebApps\Data\Logs\ULS I can see from these logs it complains about a missing access token, by providing

    &access_token=1&access_token_ttl=0 

to the end of the wopi url this error goes away.

I also tested many of the file info fields and was able to see how the OWA server caches information. If we keep changing the cfi.Version

FileInfo info = new FileInfo("C:\\WOPI OWA WORD EDITOR\\OWA_Source_Documents\\" + fi.Name);
cfi.Version = info.LastWriteTimeUtc.ToString("s");

we get a fresh cached item each time we change the files contents via normal word.

These also affect the View mode for Word and I suspect will lock us out of the word edit mode but since I don't have that working I cant tell yet.

 cfi.SupportsCoauth = true; // all three (3) needed to see the edit in browser menu in view mode .
 cfi.SupportsCobalt = true; // all three (3) needed to see the edit in browser menu in view mode .
 cfi.SupportsFolders = true; // all three (3) needed to see the edit in browser menu in view mode .
 cfi.SupportsLocks = true;
 cfi.SupportsScenarioLinks = false;
 cfi.SupportsSecureStore = true;
 cfi.SupportsUpdate = true;

This one locks out the word edit function and unless you update the version of the file it will stay locked even if you change it back to false.

cfi.WebEditingDisabled = false;

Roger Hogg

Roger
  • 21
  • 2
1

thanks to thebitllc for the correct approach to getting back the file.

 System.IO.FileStream _FileStream = new System.IO.FileStream("C:\\WOPI OWA WORD EDITOR\\OWA_Updated_Documents\\output.docx", System.IO.FileMode.Create, System.IO.FileAccess.Write);
GenericFdaStream myCobaltStream =  new GenericFda(cobaltFile.CobaltEndpoint, null).GetContentStream();
myCobaltStream.CopyTo(_FileStream);
_FileStream.Close(); 
Roger
  • 21
  • 2
  • When I tried that, it would give me the original file that I gave to OWA without changes from OWA. This gets you the file with updated changes from OWA: new GenericFda(this.CobaltEndpoint, null).GetContentStream() I as of right now I can edit/save word documents with OWA, but coauthoring isn't implemented yet. – thebitllc Jun 20 '14 at 12:47
  • Thanks for that "thebitlic". I am still unable to unable to get my service to enter edit mode, I have followed all your tips but it always says sorry. Whats the trick then ? – Roger Jun 24 '14 at 07:07
  • This code fixes the Save issue "The process cannot access the file because it is being used by another process." Thanks! – Max Sep 26 '14 at 12:33