From 03287ccda415162bac8b532d8a7e87b092c443c6 Mon Sep 17 00:00:00 2001 From: Mihai Stan Date: Mon, 19 Aug 2019 22:49:57 +0200 Subject: [PATCH 1/6] Add data formats for the input model --- src/Wps/Wps.Client.Tests/ModelSerializationTests.cs | 7 +++++-- src/Wps/Wps.Client/Models/Execution/DataInput.cs | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Wps/Wps.Client.Tests/ModelSerializationTests.cs b/src/Wps/Wps.Client.Tests/ModelSerializationTests.cs index 8708738..5f33e47 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 = @"105"; // Remove white spaces and new line characters for XML comparison. var trimmedExpectedXml = Regex.Replace(expectedXml, @"\s+", string.Empty); @@ -153,7 +153,10 @@ public void SerializeDataInput_ValidInputGiven_ShouldPass() Data = new LiteralDataValue { Value = 105.ToString(CultureInfo.InvariantCulture) - } + }, + MimeType = "test mime type", + Schema = "test schema", + Encoding = "test encoding" }; var resultXml = _serializer.Serialize(dataInput); diff --git a/src/Wps/Wps.Client/Models/Execution/DataInput.cs b/src/Wps/Wps.Client/Models/Execution/DataInput.cs index af18978..c2f6ff3 100644 --- a/src/Wps/Wps.Client/Models/Execution/DataInput.cs +++ b/src/Wps/Wps.Client/Models/Execution/DataInput.cs @@ -10,6 +10,10 @@ namespace Wps.Client.Models.Execution 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; } @@ -30,6 +34,9 @@ public void WriteXml(XmlWriter writer) var xmlSerializer = new XmlSerializationService(); writer.WriteAttributeString("id", Identifier); + 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 != null) { From 53eb0a52f9b0db86309235eafae1a626e5c9540a Mon Sep 17 00:00:00 2001 From: Mihai Stan Date: Mon, 19 Aug 2019 22:50:04 +0200 Subject: [PATCH 2/6] Remove unused reference in test project --- src/Wps/Wps.Client.Tests/WpsClientTests.cs | 1 - 1 file changed, 1 deletion(-) 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 { From 9798769a72aac7a7d9ccb43d1e58bdeb6a1680ec Mon Sep 17 00:00:00 2001 From: Mihai Stan Date: Wed, 21 Aug 2019 13:11:21 +0200 Subject: [PATCH 3/6] Update package version to 1.0.2 --- src/Wps/Wps.Client/Wps.Client.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wps/Wps.Client/Wps.Client.csproj b/src/Wps/Wps.Client/Wps.Client.csproj index f54c793..26d4439 100644 --- a/src/Wps/Wps.Client/Wps.Client.csproj +++ b/src/Wps/Wps.Client/Wps.Client.csproj @@ -14,7 +14,7 @@ false LICENSE Wps.Net - 1.0.1 + 1.0.2 From abc9b47dbeca1f1d4767b71cf5bb75fb77182c92 Mon Sep 17 00:00:00 2001 From: Mihai Stan Date: Wed, 21 Aug 2019 13:16:22 +0200 Subject: [PATCH 4/6] Write the data format information on the tag of the datainput --- src/Wps/Wps.Client.Tests/ModelSerializationTests.cs | 2 +- src/Wps/Wps.Client/Models/Execution/DataInput.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Wps/Wps.Client.Tests/ModelSerializationTests.cs b/src/Wps/Wps.Client.Tests/ModelSerializationTests.cs index 5f33e47..26d99ce 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 = @"105"; // Remove white spaces and new line characters for XML comparison. var trimmedExpectedXml = Regex.Replace(expectedXml, @"\s+", string.Empty); diff --git a/src/Wps/Wps.Client/Models/Execution/DataInput.cs b/src/Wps/Wps.Client/Models/Execution/DataInput.cs index c2f6ff3..94bf614 100644 --- a/src/Wps/Wps.Client/Models/Execution/DataInput.cs +++ b/src/Wps/Wps.Client/Models/Execution/DataInput.cs @@ -34,13 +34,13 @@ public void WriteXml(XmlWriter writer) var xmlSerializer = new XmlSerializationService(); writer.WriteAttributeString("id", Identifier); - 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 != null) { writer.WriteStartElement("wps", "Data", ModelNamespaces.Wps); + if (!string.IsNullOrEmpty(MimeType)) writer.WriteAttributeString("mimeType", MimeType); + if (!string.IsNullOrEmpty(Encoding)) writer.WriteAttributeString("encoding", Encoding); + if (!string.IsNullOrEmpty(Schema)) writer.WriteAttributeString("schema", Schema); writer.WriteRaw(xmlSerializer.Serialize(Data, true)); writer.WriteEndElement(); } From 14118682c0d5d6096acd5a91993e3d9643c759fd Mon Sep 17 00:00:00 2001 From: Mihai Stan Date: Wed, 21 Aug 2019 13:49:02 +0200 Subject: [PATCH 5/6] Copy the data input as is when the data type is string --- src/Wps/Wps.Client.Tests/ModelSerializationTests.cs | 11 ++++++----- src/Wps/Wps.Client/Models/Execution/DataInput.cs | 12 +++++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Wps/Wps.Client.Tests/ModelSerializationTests.cs b/src/Wps/Wps.Client.Tests/ModelSerializationTests.cs index 26d99ce..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,11 @@ 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" diff --git a/src/Wps/Wps.Client/Models/Execution/DataInput.cs b/src/Wps/Wps.Client/Models/Execution/DataInput.cs index 94bf614..0cf0107 100644 --- a/src/Wps/Wps.Client/Models/Execution/DataInput.cs +++ b/src/Wps/Wps.Client/Models/Execution/DataInput.cs @@ -6,6 +6,9 @@ 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 { @@ -41,7 +44,14 @@ public void WriteXml(XmlWriter writer) if (!string.IsNullOrEmpty(MimeType)) writer.WriteAttributeString("mimeType", MimeType); if (!string.IsNullOrEmpty(Encoding)) writer.WriteAttributeString("encoding", Encoding); if (!string.IsNullOrEmpty(Schema)) writer.WriteAttributeString("schema", Schema); - writer.WriteRaw(xmlSerializer.Serialize(Data, true)); + if (Data is string s) + { + writer.WriteRaw(s); + } + else + { + writer.WriteRaw(xmlSerializer.Serialize(Data, true)); + } writer.WriteEndElement(); } From 5e7789d9866a0abbf5f2551a3562c866a7f520dc Mon Sep 17 00:00:00 2001 From: Mihai Stan Date: Wed, 21 Aug 2019 16:33:18 +0200 Subject: [PATCH 6/6] Update package version to 1.0.3 --- src/Wps/Wps.Client/Wps.Client.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Wps/Wps.Client/Wps.Client.csproj b/src/Wps/Wps.Client/Wps.Client.csproj index 26d4439..923b220 100644 --- a/src/Wps/Wps.Client/Wps.Client.csproj +++ b/src/Wps/Wps.Client/Wps.Client.csproj @@ -14,7 +14,7 @@ false LICENSE Wps.Net - 1.0.2 + 1.0.3