Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

Deserialize Soap Request Message from File to Object

$
0
0

Hi,

this is my incoming XML SOAP Request Message:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:han="http://schemas.datacontract.org/2004/07/ASDF_WCF"><soapenv:Header/><soapenv:Body><tem:GetDataUsingDataContract><tem:composite><han:MyParam1>5</han:MyParam1></tem:composite></tem:GetDataUsingDataContract></soapenv:Body></soapenv:Envelope>

[ServiceContract]
public interface IService1
{
	[OperationContract]
	ComplexResponse1 GetDataUsingDataContract(ComplexParams1 composite);
}

[DataContract]
public class ComplexParams1
{
	[DataMember]
	public int MyParam1 { get; set; }
}

Calling the service works fine.

Now i saved the incoming Request SOAP XML to a file.
I want to be able to process it again later.

How can i Deserialize the Soap Message into ComplexParams1?


i tryed already, but couldn't get to work :

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(ComplexParams1));
XmlSerializer xmlSerializer = new XmlSerializer(mapp); //typeof(T), xr
var o = (ComplexParams1)xmlSerializer.Deserialize(m.GetReaderAtBodyContents());

i'd prefer a generic solution like the one above, so its not too verbose.
I'd like to deserialize the original XML.


Thanks for help!

 


Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>