diff --git a/src/Wps/Wps.Client.Tests/ModelSerializationTests.cs b/src/Wps/Wps.Client.Tests/ModelSerializationTests.cs index 8708738..9f50d87 100644 --- a/src/Wps/Wps.Client.Tests/ModelSerializationTests.cs +++ b/src/Wps/Wps.Client.Tests/ModelSerializationTests.cs @@ -137,7 +137,7 @@ public void SerializeValueRange_ValidRangeGiven_ShouldPass() [Fact] public void SerializeDataInput_ValidInputGiven_ShouldPass() { - const string expectedXml = @"105"; + const string expectedXml = @"test string"; // Remove white spaces and new line characters for XML comparison. var trimmedExpectedXml = Regex.Replace(expectedXml, @"\s+", string.Empty); @@ -150,10 +150,14 @@ public void SerializeDataInput_ValidInputGiven_ShouldPass() Href = "test", Schema = "test-schema" }, - Data = new LiteralDataValue - { - Value = 105.ToString(CultureInfo.InvariantCulture) - } + //Data = new LiteralDataValue + //{ + // Value = 105.ToString(CultureInfo.InvariantCulture) + //}, + Data = "test string", + MimeType = "test mime type", + Schema = "test schema", + Encoding = "test encoding" }; var resultXml = _serializer.Serialize(dataInput); diff --git a/src/Wps/Wps.Client.Tests/WpsClientTests.cs b/src/Wps/Wps.Client.Tests/WpsClientTests.cs index 4175760..d67b505 100644 --- a/src/Wps/Wps.Client.Tests/WpsClientTests.cs +++ b/src/Wps/Wps.Client.Tests/WpsClientTests.cs @@ -14,7 +14,6 @@ using Wps.Client.Models.Requests; using Wps.Client.Services; using Xunit; -using Xunit.Sdk; namespace Wps.Client.Tests { diff --git a/src/Wps/Wps.Client/Models/Execution/DataInput.cs b/src/Wps/Wps.Client/Models/Execution/DataInput.cs index af18978..0cf0107 100644 --- a/src/Wps/Wps.Client/Models/Execution/DataInput.cs +++ b/src/Wps/Wps.Client/Models/Execution/DataInput.cs @@ -6,10 +6,17 @@ namespace Wps.Client.Models.Execution { + /// + /// The data input model used for the execution requests. If the data is of type it will be copied inside the data tags as is with no further serialization. + /// [XmlRoot("Input", Namespace = ModelNamespaces.Wps)] public class DataInput : IXmlSerializable { + public string MimeType { get; set; } + public string Encoding { get; set; } + public string Schema { get; set; } + public string Identifier { get; set; } public object Data { get; set; } public ResourceReference Reference { get; set; } @@ -34,7 +41,17 @@ public void WriteXml(XmlWriter writer) if (Data != null) { writer.WriteStartElement("wps", "Data", ModelNamespaces.Wps); - writer.WriteRaw(xmlSerializer.Serialize(Data, true)); + if (!string.IsNullOrEmpty(MimeType)) writer.WriteAttributeString("mimeType", MimeType); + if (!string.IsNullOrEmpty(Encoding)) writer.WriteAttributeString("encoding", Encoding); + if (!string.IsNullOrEmpty(Schema)) writer.WriteAttributeString("schema", Schema); + if (Data is string s) + { + writer.WriteRaw(s); + } + else + { + writer.WriteRaw(xmlSerializer.Serialize(Data, true)); + } writer.WriteEndElement(); } diff --git a/src/Wps/Wps.Client/Models/ResultOutput.cs b/src/Wps/Wps.Client/Models/ResultOutput.cs index 959d0e4..528f735 100644 --- a/src/Wps/Wps.Client/Models/ResultOutput.cs +++ b/src/Wps/Wps.Client/Models/ResultOutput.cs @@ -1,4 +1,5 @@ -using System.Xml; +using System; +using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; using Wps.Client.Services; @@ -47,7 +48,14 @@ public void ReadXml(XmlReader reader) if (subtreeReader.LocalName.Equals("Data")) { var content = subtreeReader.ReadInnerXml(); - Data = serializer.Deserialize(content); + if (typeof(TData) == typeof(string)) + { + Data = (TData) Convert.ChangeType(content, typeof(string)); + } + else + { + Data = serializer.Deserialize(content); + } } if (subtreeReader.LocalName.Equals("Output")) diff --git a/src/Wps/Wps.Client/Wps.Client.csproj b/src/Wps/Wps.Client/Wps.Client.csproj index 9f5c4f4..923b220 100644 --- a/src/Wps/Wps.Client/Wps.Client.csproj +++ b/src/Wps/Wps.Client/Wps.Client.csproj @@ -1,7 +1,32 @@ - + netstandard2.0 + Mihai Stan, Benjamin Pross + 52°North + WPS Library + This is a library that allows developers to speed up their development when working with WPS providers. + https://github.com/52North/wps.net + wps library client + https://github.com/52North/wps.net + + true + false + LICENSE + Wps.Net + 1.0.3 + + + + + + + + True + + + +