How to find the namespace from XML

M

mazdotnet

Hi,

I'm working on a ASP.NET component with one requirement being to
catch
Web Service exceptions. I've managed to get it working using the
following code


XmlDocument doc = new XmlDocument();
doc.LoadXml(se.Detail.OuterXml);
XmlNamespaceManager nsManager = new
XmlNamespaceManager(doc.NameTable);


nsManager.AddNamespace("prefix", "http://localhost/site/test/
webservice.asmx");


string errorMessage = doc.DocumentElement.SelectSingleNode("//
prefix:ErrorMessage", nsManager).InnerText;
Response.Write("Error message:" + errorMessage);


The issue is that the namespace changes depending on where the web
service resides (ex. staging, production, local computer). How can I
get the http://localhost/site/test/webservice.asmx dynamically (parse
it from XmlDocument?)


Thanks
Maz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,191
Latest member
BuyKetoBeez

Latest Threads

Top