/// <summary> /// Get a xml string from a WOPI Discovery type object. /// </summary> /// <param name="wopiDiscovery">ct_wopidiscovery instance.</param> /// <returns>xml string which contains discovery information.</returns> public string GetDiscoveryXmlFromDiscoveryObject(ct_wopidiscovery wopiDiscovery) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(ct_wopidiscovery)); string xmlString = string.Empty; MemoryStream memorySteam = new MemoryStream(); StreamWriter streamWriter = new StreamWriter(memorySteam, Encoding.UTF8); // Remove w3c default namespace prefix in serialize process. XmlSerializerNamespaces nameSpaceInstance = new XmlSerializerNamespaces(); nameSpaceInstance.Add(string.Empty, string.Empty); xmlSerializer.Serialize(streamWriter, wopiDiscovery, nameSpaceInstance); // Read the MemoryStream to output the xml string. memorySteam.Position = 0; using (StreamReader streamReader = new StreamReader(memorySteam)) { xmlString = streamReader.ReadToEnd(); } streamWriter.Dispose(); memorySteam.Dispose(); // Format the serialized xml string. XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlString); return(xmlDoc.OuterXml); }
/// <summary> /// Discovery WOPI discovery response xml. It indicates the WOPI client supports 4 types file extensions: ".txt", ".zip", ".one" , ".wopitest" /// </summary> /// <returns>Discovery response xml.</returns> public string GetDiscoveryResponseXmlString() { ct_wopidiscovery wopiDiscovery = new ct_wopidiscovery(); // Add http and https net zone into the wopiDiscovery wopiDiscovery.netzone = GetNetZones(); // ProofKey element wopiDiscovery.proofkey = new ct_proofkey(); wopiDiscovery.proofkey.oldvalue = proofKeyOld; wopiDiscovery.proofkey.value = proofKey; string xmlStringOfResponseDiscovery = GetDiscoveryXmlFromDiscoveryObject(wopiDiscovery); return(xmlStringOfResponseDiscovery); }