marx-yu / WopiHost

Office Online Server Wopi Host implement, No need Cobalt. Support DOCX, XLSX, PPTX online editing.
BSD 3-Clause "New" or "Revised" License
247 stars 94 forks source link

How the system is going to access office webapps without Discovery.xml #2

Closed ahmedaswai closed 5 years ago

ahmedaswai commented 8 years ago

I was asking about how can the wopi host is going to access my office webapps without Discovery.xml , because I see the json response is just meta data

marx-yu commented 8 years ago

This program is the wopi host implement. Have not supporting auto discovery, so no need discovery.xml. when you use _http://[owas.domain]/we/wordviewerframe.aspx?WOPISrc=http%3a%2f%2flocalhost%3a8080%2fwopi%2ffiles%2fword.docx&access_token=[token]&ui=zh-CN_, you special the webapps server address as [owas.domain]/we/wordviewerframe.aspx. see msdn blog

ahmedaswai commented 8 years ago

Ok I am getting exception in OfficeWebapps Preview 2016 after trying to open the next url

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

those are my setup parameters

FarmOU
: InternalURL : http://owas.cmsad.local/ ExternalURL : http://owas.cmsad.local/ AllowHTTP : True AllowOutboundHttp : False SSLOffloaded : False CertificateName : S2SCertificateName : EditingEnabled : True LogLocation : C:\ProgramData\Microsoft\OfficeWebApps\Data\Logs\ULS LogRetentionInDays : 7 LogVerbosity : Proxy : CacheLocation : C:\ProgramData\Microsoft\OfficeWebApps\Working\d MaxMemoryCacheSizeInMB : 75 DocumentInfoCacheSize : 5000 CacheSizeInGB : 15 ClipartEnabled : False TranslationEnabled : False MaxTranslationCharacterCount : 125000 TranslationServiceAppId : TranslationServiceAddress : RenderingLocalCacheLocation : C:\ProgramData\Microsoft\OfficeWebApps\Working\waccache RecycleActiveProcessCount : 5 AllowCEIP : False ExcelRequestDurationMax : 300 ExcelSessionTimeout : 450 ExcelWorkbookSizeMax : 10 ExcelPrivateBytesMax : -1 ExcelConnectionLifetime : 1800 ExcelExternalDataCacheLifetime : 300 ExcelAllowExternalData : True ExcelUseEffectiveUserName : False ExcelWarnOnDataRefresh : True ExcelUdfsAllowed : False ExcelMemoryCacheThreshold : 90 ExcelUnusedObjectAgeMax : -1 ExcelCachingUnusedFiles : True ExcelAbortOnRefreshOnOpenFail : True ExcelAutomaticVolatileFunctionCacheLifeTime : 300 ExcelConcurrentDataRequestsPerSessionMax : 5 ExcelDefaultWorkbookCalcMode : File ExcelRestExternalDataEnabled : True ExcelChartAndImageSizeMax : 1 OpenFromUrlEnabled : True OpenFromUncEnabled : True OpenFromUrlThrottlingEnabled : True PicturePasteDisabled : True RemovePersonalInformationFromLogs : False AllowHttpSecureStoreConnections : False Machines : {CMS-AE}

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... 6017030a-ab6c-45c4-a8d3-20f3067b545d

marx-yu commented 8 years ago

when preview doc, owas will invoke a request as checkfileinfo and then request file content. can you debug wopi host code? I think it failed at checkfileinfo request. Check this parameter: WOPISrc=http://owas.cmsad.local/hosting/docs/test.docx

ahmedaswai commented 8 years ago

The file is in the same host of the office web apps , how to initiate the checkfileinfo request , could you provide me by an example

marx-yu commented 8 years ago

wopi host is the diff web server from office web apps, and you put it at the same host and the same port(80), is that right? checkfileinfo request will run this code block in CobaltServer.cs

 if (stringarr.Length == 4 && context.Request.HttpMethod.Equals(@"GET"))
                    {
                        //request of checkfileinfo, will be called first
                        var memoryStream = new MemoryStream();
                        var json = new DataContractJsonSerializer(typeof(WopiCheckFileInfo));
                        json.WriteObject(memoryStream, editSession.GetCheckFileInfo());
                        memoryStream.Flush();
                        memoryStream.Position = 0;
                        StreamReader streamReader = new StreamReader(memoryStream);
                        var jsonResponse = Encoding.UTF8.GetBytes(streamReader.ReadToEnd());

                        context.Response.ContentType = @"application/json";
                        context.Response.ContentLength64 = jsonResponse.Length;
                        context.Response.OutputStream.Write(jsonResponse, 0, jsonResponse.Length);
                        context.Response.Close();
                    }  

set a breakpoint or write log, make sure it response a right json object