I am working on a .NET project that integrates with an external company. This company will send us XML messages via HTTP POST (raw XML, not SOAP). Basically, there are three different types of XML messages that they will send to us, and they all have their own XSD. There is no inheritance hierarchy between these XSDs; all of them are basically autonomous XML entities.
For the moment, we are simply using the IHttpHandler.ashx class to process XML. We created a class from each XSD and use the XmlSerializer to convert various XML messages into objects. This is not ideal, because we need to know the type of message before creating the appropriate XmlSerializer to process it. We are currently just looking at the name of the root element in the message to select which type to pass to the XmlSerializer.
There must be a better way to do this ... Is there something in WCF that can do this automatically using simple XML? Or is there an XML serializer that can dynamically serialize multiple types? Any other suggestions?
WCF RESTful + POX
REST POXREST Windows Communication Foundation (WCF)
XMLSerializer , . XML , . , XML . , Linq XDocument/XElement?
Linq to XML . XElement XML.
XElement xml = XElement.Parse(receivedXmlString);
.
MIX07: " LINQ -". . Linq XML 26 .
XML-, , .
, XML - , . XSD XSD, .NET. , XSD xsd.exe.
"" XML-, , . XML , XML- , XSD, XML-. XML- , . , . , , XML- .NET, , . , xsd: any xsd: xmlAny, .. , .
, . "" XML Serializer.
Why not read it in a dataset using XmlReadMode.Auto? Then you have one object that you can read as needed - you can look at table [0] to find out which one you have.
Source: https://habr.com/ru/post/1707958/More articles:DataRelation Insert and ForeignKey - c #ASP Weird Unspecified Error - 80004005 - ms-access.NET Sharepoint Create Directory - putBlow up all the other words - phpJSF component custom attribute list - jsfUsing Stop Words with WhitespaceAnalyzer - luceneOracle, causing PL / SQL problems from SQL-Plus x.sql, says my_function "cannot be a function", - functionSolrj Query - сначала введите наиболее релевантную запись - schemaHow to redirect the console (stin, sterr) in Delphi 2009? - delphihttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1707963/lots-of-boolean-flag-inputs-to-a-class&usg=ALkJrhgGB2GoXIJGfTMYc_5FicP68k6JeAAll Articles