ts84zs
asked on
Read SOAP Response - XDocument Class in C#
I request SOAP using HTTPWebRequest.
My soap Response looks like this -
I store it in XDocument Variable as shown below... I am trying to read <response> object, <messageData> etc, but it did not work...
But it does not work -
My soap Response looks like this -
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<SRCData xmlns="http://oracle.com/SRCData.xsd" dateTimeTagFormat="xsd:strict">
<request>
<PrimaryKeyID />
<AddressID/>
</request>
<response>
<messageData>
<messageCategory>100</messageCategory>
<messageNumber>10</messageNumber>
<errorMessage>No Error</errorMessage>
<messageNumberUpdate>10</messageNumberUpdate>
</messageData>
</response
</SRCData>
</soapenv:Body>
</soapenv:Envelope>
I store it in XDocument Variable as shown below... I am trying to read <response> object, <messageData> etc, but it did not work...
But it does not work -
using (WebResponse response = request.GetResponse())
{
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
{
XDocument mydoc = XDocument.Load(rd);
XNamespace ns = mydoc.Root.GetDefaultNamespace();
var pricres = from o in mydoc.Root.Elements(ns + "response").Elements(ns + "response")
select (int)o.Element(ns + "messageData");
}
}
ASKER
Thanks
Let me try it
Let me try it
ASKER
is there any reference or tutorial i can refer to - how to read a soap xml?
thanks so much
thanks so much
I am sorry I do not know of any. Did the solution I posted work for you?
ASKER
yes that worked.. after i used the namespace...
thanks so much...
are there any points I should consider while reading soap-xml... pl guide
thanks again...
thanks so much...
are there any points I should consider while reading soap-xml... pl guide
thanks again...
ASKER
i am trying to find how to read all the elements of that soap-xml
may be using linq
but i am finding difficult reading my xml
thanks again
may be using linq
but i am finding difficult reading my xml
thanks again
ASKER
is xmltextreader class better than xdocument
pl guide
pl guide
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok thanks so much
I think I found my answer
I will close solution soon
Thanks
I think I found my answer
I will close solution soon
Thanks
Still having issues or do you have it?
See if doing it like this gives you what you need.
Open in new window