How to parse a soap message loaded from a file?
You should be able to use XmlSerializer
to accomplish this with help of SoapReflectionImporter
.
var importer = new SoapReflectionImporter("ns2:PourtuIntf-IPourtu");var mapping = importer.ImportTypeMapping(typeof(GetCRResponse));var serializer = new XmlSerializer(mapping);var response = serializer.Deserialize(reader) as GetCRResponse;
The SoapReflectionImporter class provides type mappings to SOAP-encoded message parts, as defined in a Web Services Description Language (WSDL) document. It is used only when a Web service or client specifies SOAP encoding, as described in Section 5 of the SOAP 1.1 specification.
The following command was used to generate your client contracts from WSDL
SvcUtil.exe IPlotiservice.wsdl /t:code /serviceContract
Updated:
Message m = Message.CreateMessage(XmlReader.Create("C:\\testSvc\\login.xml"), int.MaxValue, MessageVersion.Soap11); SoapReflectionImporter importer = new SoapReflectionImporter(new SoapAttributeOverrides(), "urn:PlotiIntf-IPloti"); XmlTypeMapping mapp = importer.ImportTypeMapping(typeof(ActGetCRResponse)); XmlSerializer xmlSerializer = new XmlSerializer(mapp); var o = (ActGetCRResponse)xmlSerializer.Deserialize(m.GetReaderAtBodyContents());