Integration of XML HTTP POST in .NET.

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?

+3
source share
5

XMLSerializer , . XML , . , XML . , Linq XDocument/XElement?

+1

Linq to XML . XElement XML.

XElement xml = XElement.Parse(receivedXmlString);

.

MIX07: " LINQ -". . Linq XML 26 .

+1

XML-, , .

, XML - , . XSD XSD, .NET. , XSD xsd.exe.

"" XML-, , . XML , XML- , XSD, XML-. XML- , . , . , , XML- .NET, , . , xsd: any xsd: xmlAny, .. , .

, . "" XML Serializer.

0
source

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.

-1
source

Source: https://habr.com/ru/post/1707958/


All Articles