473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 11978
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gustaf Liljegren | last post by:
I need to merge several XML files into one large. All of them has a DOCTYPE tag, but the SYSTEM identifier points to a DTD that doesn't exist. (I use the PUBLIC identifier with catalog files, so...
8
by: Whugster | last post by:
I have this really frustrating problem when calling XmlDocument.Load(string filename). Whenever I call this method in a web application in my Windows XP development PC, I get the following error: ...
1
by: Chief | last post by:
I am unable to load an xml document that contains Chinese characters in an attribute value. I need to load the document into and XmlDocument object and am using the XmlDocument.Load(string...
11
by: bleedledeep | last post by:
I've been tracking down a memory leak using DevPartner 7.2 and what I am seeing is that calling XmlDocument.Load() leaks A LOT of memory. The following code is called when I click a button on my...
0
by: Giovanni | last post by:
Hi All, I am trying to use the XMLDocument.Load method to load an XML document from a web site (http://www.xxx.com/file.xml). As I am going through ISA and require Proxy authentication, I...
2
by: supercodepoet | last post by:
I have cXml document I want to load to parse. The document has a DOCTYPE element that points to an external dtd via http. When the document loads it trys a web request which I am assuming is to...
10
by: lamxing | last post by:
Dear all, I've spent a long time to try to get the xmldocument.load method to handle UTF-8 characters, but no luck. Every time it loads a document contains european characters (such as the...
4
by: DanThMan | last post by:
The following code works when I debug and when I install the software and run the .exe, but if I try to open the form in the designer (which causes this code to run), I get an error: Private Sub...
5
by: Mahmoud Al-Qudsi | last post by:
Is there any way to stop an XmlDocument object from using data grabbed from a previous request? e.g. if I used XmlDocument.Load to grab a URI, and I know that this URI changes often (for...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.