469,918 Members | 2,201 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,918 developers. It's quick & easy.

How to specify proxy/authority for XmlDocument.Load()

Hi All,

I am trying to access xml-files in the internet from my intranet-page.
Making XmlDocument.Load() calls internally works fine, but not so to the
internet. I think the calls are failing, because we use a proxy-server.

Can I specify a specifix proxy in the call and/or in the
configuration-files? For the configuration-files, I am not finding samples,
which point out how to specify username and password. For the XmlDocument, I
even find nothing in this range, so, do I have to make a webRequest
"manually" specifying a proxy and pass the pulled data to the XmlDocument
after that?

Any help would really be very welcomed!

Best regards,
Manfred Braun

(Private)
Mannheim
Germany

mailto:_m*************@manfbraun.de
(Remove the anti-spam-underscore to mail me!)

Nov 11 '05 #1
2 11779
Manfred Braun wrote:
I am trying to access xml-files in the internet from my intranet-page.
Making XmlDocument.Load() calls internally works fine, but not so to the
internet. I think the calls are failing, because we use a proxy-server.


Read "Supplying Authentication Credentials to XmlResolver when Reading
from a File" at
http://msdn.microsoft.com/library/de...ngfromfile.asp
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #2
Hi Oleg,

sad to say, this lokks true. Anyway, it's not too much code, but eveythings
is too new for me .....
With help of MSDN/SDK I made the following working successfully:

//+++ excerpt
StreamReader oSR = null;
WebRequest objRequest =
WebRequest.Create("http://msdn.microsoft.com/rss.xml");

bool useProxy =
Boolean.Parse(System.Configuration.ConfigurationSe ttings.AppSettings["usePro
xy"]);
if(useProxy)
{
string address, port, username, password, domain;
address =
System.Configuration.ConfigurationSettings.AppSett ings["address"];
port = System.Configuration.ConfigurationSettings.AppSett ings["port"];
username =
System.Configuration.ConfigurationSettings.AppSett ings["username"];
password =
System.Configuration.ConfigurationSettings.AppSett ings["password"];
domain =
System.Configuration.ConfigurationSettings.AppSett ings["domain"];

WebProxy myProxy = new WebProxy(address, Int32.Parse(port));
myProxy.BypassProxyOnLocal = true;
NetworkCredential myCred = new NetworkCredential(username, password,
domain);
myProxy.Credentials = myCred;

objRequest.Proxy = myProxy;
}

WebResponse objResponse = objRequest.GetResponse();
oSR = new StreamReader(objResponse.GetResponseStream());
oDS.ReadXml(oSR);

//--- excerpt

Anyway, thanks for your help. My sample above is from a code, where a
DataSet is used, while I use XmlDocument. But I am shure, I can adapt the
one or two lines of code to use XmlDocument!

Best regards,
Manfred
"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:Ox**************@TK2MSFTNGP12.phx.gbl...
Manfred Braun wrote:
and thanks for your posting. After studying this document, I found, that it does'nt resolve my problem going through a proxy-server. It would apply, to specify creadentials to the destination. But in my case, the destination-url is accessibly publicly and I have to deal with our proxy....


Yeah, you are right, that's not enough.
So you have to deal directly with WebRequest class. There are two ways
I'm aware of - direct one and elegant one. Former - create WebRequest,
set up its proxy property, get WebResponse and load XmlDocument from
response's stream.
More elegant way - encapsulate above WebRequest/WebResponse logic into
custom reusable XmlResolver.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel


Nov 11 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Gustaf Liljegren | last post: by
8 posts views Thread by Whugster | last post: by
reply views Thread by Giovanni | last post: by
2 posts views Thread by supercodepoet | last post: by
5 posts views Thread by Mahmoud Al-Qudsi | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.