Reputation: 646
I want to read elements value like from soap header and from SOAP Body . Please look into the code below and help me out to fetch custid and clientid form header and body. Post me if you need any further clarification
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<APHeader xmlns="http://www.test.com/es/v1/ws">
<usr>
<Verb>Set</Verb>
<Noun>ProcessEIACMPermissions</Noun>
<DataVer>001:000</DataVer>
<SrcAppID xsi:type="xsd:string">AP</SrcAppID>
<CustID>30081241</CustID>
<APMsgCorrelationID>00000000000000000000000000000000</APMsgCorrelationID>
</usr>
</APHeader>
</soap:Header>
<soap:Body>
<ProcessEIACMPermissionsRequest xmlns="http://www.adp.com/es/ezlm/v1/schema/tlmclientconfiguration">
<ClientID>30081241</ClientID>
</ProcessEIACMPermissionsRequest>
</soap:Body>
Upvotes: 1
Views: 4885
Reputation: 646
case SoapMessageStage.BeforeSerialize:
break;
case SoapMessageStage.AfterSerialize:
break;
case SoapMessageStage.BeforeDeserialize:
break;
case SoapMessageStage.AfterDeserialize:
foreach (SoapHeader header in message.Headers)
{
if (header.GetType() == typeof(RouteInformation))
{
routeHdr = (RouteInformation) header;
if(!string.IsNullOrEmpty(routeHdr.ConsumerID))
id = DataFix.FixInt(routeHdr.ID);
}
else if (header.GetType() == typeof (Header))
{
Hdr = (Header) header;
Custid = DataFix.FixInt(Hdr.m_objUsr.ID);
}
else if(header.GetType() == typeof(Configuration))
{
configHdr = (ConfigurationAPHeader) header;
}
}
Upvotes: 0
Reputation: 646
I found the simple way to do so. Just Read the inputstream from httprequest,load the xml and get the CustID from xml. Below is the code for same.
var httpApp = sender as HttpApplication;
var Request = httpApp.Request as HttpRequest;
string documentContents;
using (Stream receiveStream = Request.InputStream)
{
using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
{
documentContents = readStream.ReadToEnd();
}
}
XmlDocument xd = new XmlDocument();
xd.LoadXml(documentContents);
XmlElement root = xd.DocumentElement;
XmlNodeList titleList = root.GetElementsByTagName("CustID");
return titleList[0].InnerText;
Upvotes: 1