/// <summary> /// This method is used to add a request to the request collection in the request envelope body. /// </summary> /// <param name="url">Specify the URL of the file to edit.</param> /// <param name="subRequests">Specify the sub request array.</param> /// <param name="requestToken">Specify the token which uniquely identify the request.</param> /// <param name="interval">Specify a nonnegative integer in seconds, which the protocol client will repeat this request.</param> /// <param name="metaData">Specify a 32-bit value that specifies information about the scenario and urgency of the request.</param> public void AddRequest(string url, SubRequestType[] subRequests, string requestToken, uint? interval, int? metaData) { Request request = new Request(); request.RequestToken = requestToken; request.Url = url; request.Interval = interval == null ? null : interval.Value.ToString(); request.MetaData = metaData == null ? null : metaData.Value.ToString(); int index = 0; if (subRequests != null) { request.SubRequest = new SubRequestElementGenericType[subRequests.Length]; foreach (SubRequestType item in subRequests) { if (item != null) { request.SubRequest[index++] = FsshttpConverter.ConvertSubRequestToGenericType<SubRequestElementGenericType>(item); } } } else { throw new System.ArgumentException("subRequests parameter in FSSHTTPMessageBodyWriter::AddRequest cannot be null."); } List<Request> requestList = this.requestEnvelope.RequestCollection.Request == null ? new List<Request>(1) : new List<Request>(this.requestEnvelope.RequestCollection.Request); requestList.Add(request); this.requestEnvelope.RequestCollection.Request = requestList.ToArray(); }
/// <summary> /// This method is used to send the cell storage request to the server. /// </summary> /// <param name="url">Specifies the URL of the file to edit.</param> /// <param name="subRequests">Specifies the sub request array.</param> /// <param name="requestToken">Specifies a non-negative request token integer that uniquely identifies the Request <seealso cref="Request"/>.</param> /// <param name="version">Specifies the version number of the request, whose value should only be 2.</param> /// <param name="minorVersion">Specifies the minor version number of the request, whose value should only be 0 or 2.</param> /// <param name="interval">Specifies a nonnegative integer in seconds, which the protocol client will repeat this request, the default value is null.</param> /// <param name="metaData">Specifies a 32-bit value that specifies information about the scenario and urgency of the request, the default value is null.</param> /// <returns>Returns the CellStorageResponse message received from the server.</returns> public CellStorageResponse CellStorageRequest( string url, SubRequestType[] subRequests, string requestToken = "1", ushort? version = 2, ushort? minorVersion = 2, uint? interval = null, int? metaData = null) { // If the transport is HTTPS, then try to accept the certificate. if ("HTTPS".Equals(Common.GetConfigurationPropertyValue("TransportType", this.Site), StringComparison.OrdinalIgnoreCase)) { Common.AcceptServerCertificate(); } ICellStoragesChannel channel = channelManager.CreateChannel<ICellStoragesChannel>(SharedContext.Current); // Store the SubRequestToken, subRequest type pairs this.subResponseValidationWrappers.Clear(); if (subRequests != null) { foreach (SubRequestType item in subRequests) { this.subResponseValidationWrappers.Add(new SubResponseValidationWrapper { SubToken = item.SubRequestToken, SubRequestType = item.GetType().Name }); } } // Create web request message. RequestMessageBodyWriter fsshttpBodyWriter = new RequestMessageBodyWriter(version, minorVersion); fsshttpBodyWriter.AddRequest(url, subRequests, requestToken, interval, metaData); this.lastRawRequestXml = fsshttpBodyWriter.MessageBodyXml; // Try to log the request body information this.Site.Log.Add(LogEntryKind.Debug, "The raw xml request message is:\r\n{0}", this.lastRawRequestXml.OuterXml); Message request = Message.CreateMessage(MessageVersion.Soap11, ActionURL, fsshttpBodyWriter); try { // Invoke the web service Message response = channel.ExecuteCellStorageRequest(request); // Extract and de-serialize the response. CellStorageResponse cellStorageResponseObjects = this.GetCellStorageResponseObject(response); // Restore the current version type SharedContext.Current.CellStorageVersionType = cellStorageResponseObjects.ResponseVersion; // Schema Validation for the response. this.ValidateGenericType(cellStorageResponseObjects, requestToken); this.ValidateSpecificType(cellStorageResponseObjects); request.Close(); return cellStorageResponseObjects; } catch (EndpointNotFoundException ex) { // Here try to catch the EndpointNotFoundException due to X-WOPI-ServerError. if (ex.InnerException is WebException) { if ((ex.InnerException as WebException).Response.Headers.AllKeys.Contains<string>("X-WOPI-ServerError")) { throw new WOPIServerErrorException( (ex.InnerException as System.Net.WebException).Response.Headers["X-WOPI-ServerError"], ex.InnerException); } } request.Close(); throw; } }