Skip to content

Commit

Permalink
Merge pull request #944 from ace210/xml_node_and_x_element
Browse files Browse the repository at this point in the history
XmlNode and XElement serialize with XmlSerializer
  • Loading branch information
andersjonsson authored Jun 8, 2023
2 parents dfa51c3 + 6cb0dc3 commit dbea096
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/SoapCore/ServiceBodyWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
using SoapCore.Meta;
using SoapCore.ServiceModel;
Expand Down Expand Up @@ -200,8 +201,20 @@ private void OnWriteXmlSerializerBodyContents(XmlDictionaryWriter writer)
}
else
{
if (_result is XmlNode xmlNode)
{
writer.WriteStartElement(_resultName, _serviceNamespace);
xmlNode.WriteTo(writer);
writer.WriteEndElement();
}
else if (_result is XElement xElement)
{
writer.WriteStartElement(_resultName, _serviceNamespace);
xElement.WriteTo(writer);
writer.WriteEndElement();
}
//https://github.com/DigDes/SoapCore/issues/385
if (_operation.DispatchMethod.GetCustomAttribute<XmlSerializerFormatAttribute>()?.Style == OperationFormatStyle.Rpc)
else if (_operation.DispatchMethod.GetCustomAttribute<XmlSerializerFormatAttribute>()?.Style == OperationFormatStyle.Rpc)
{
var importer = new SoapReflectionImporter(_serviceNamespace);
var typeMapping = importer.ImportTypeMapping(resultType);
Expand Down

0 comments on commit dbea096

Please sign in to comment.