473,396 Members | 1,967 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,396 software developers and data experts.

XML and WebProxy

Morning everybody,

I have an XML document located on a web address and I wish to create a
C# program to read that XML document and process it - which shouldn't
be that difficult yet I'm running into all kinds of problems because
I'm behind a firewall.

After much searching I found using WebProxy, NetworkCredentials and
HttpWebResponse/Request to be quite useful but again it's not really
working the way I'd like. So I decided to setup a prototype using the
three classes above so I could get them working.

For example...

HttpWebRequest HttpWReq =
(HttpWebRequest)WebRequest.Create("http://homepage.com/");
WebProxy objProxy = new WebProxy("1.2.3.4");
NetworkCredential myCred = new NetworkCredential("user", "pass",
"domain");
// a few more lines of code here
Console.WriteLine(HttpWebResp.StatusDescription);

which outputs "OK" and that's fantastic - at least I know my proxy is
setup right.

But if I change the WebRequest.Create from "http://homepage.com" to
"http://homepage.com/filename.xml" it generates a 404 error; but the
file is there.

Any ideas?

Mar 31 '06 #1
4 3459
Thus wrote Andrew,
Morning everybody,

I have an XML document located on a web address and I wish to create a
C# program to read that XML document and process it - which shouldn't
be that difficult yet I'm running into all kinds of problems because
I'm behind a firewall.

After much searching I found using WebProxy, NetworkCredentials and
HttpWebResponse/Request to be quite useful but again it's not really
working the way I'd like. So I decided to setup a prototype using the
three classes above so I could get them working.
Did you have a look at WebClient? It may make your life a lot easier compared
to what you need to do with HttpWebRequest.
For example...

HttpWebRequest HttpWReq =
(HttpWebRequest)WebRequest.Create("http://homepage.com/");
WebProxy objProxy = new WebProxy("1.2.3.4");
NetworkCredential myCred = new NetworkCredential("user", "pass",
"domain");
// a few more lines of code here
Console.WriteLine(HttpWebResp.StatusDescription);
which outputs "OK" and that's fantastic - at least I know my proxy is
setup right.

But if I change the WebRequest.Create from "http://homepage.com" to
"http://homepage.com/filename.xml" it generates a 404 error; but the
file is there.

Any ideas?


Are you sure that the file isn't protected or created dynamically by some
web application? Can you download it using a browser?

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Mar 31 '06 #2
Hey, thanks for the response!

The test file is just a bog standard xml file but I would like to hope
that I could use a dynamically generated xml file - does it matter in
the future if it is? But yeah, I can access the file via browser. I'll
check how WebClient etc works in the morning when I'm back at my labs
computer.

* Note to self: Look at WebClient class.

Is there anything else you could suggest?

Andy

Mar 31 '06 #3
Thus wrote Andrew,
Hey, thanks for the response!

The test file is just a bog standard xml file but I would like to hope
that I could use a dynamically generated xml file - does it matter in
the future if it is?
Only if the web application that creates that file requires authentication,
requires some sort of session tracked by cookies, or wants to identify your
browser... in other word, if it requires some piece of information who or
what the client is.
But yeah, I can access the file via browser. I'll
check how WebClient etc works in the morning when I'm back at my labs
computer.

* Note to self: Look at WebClient class.

Is there anything else you could suggest?


If all fails, use Fiddler to compare the HTTP traffic between your application
and the server to the one between your browser and the server.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Apr 1 '06 #4
Hi Joerg,

I tried using WebClient and I found something out probably to do with
internal settings. Like I originally said, I was having trouble reading
any file that wasn't a domain name. It turns out using
WebClient.OpenRead and Stream/StreamReader classes that I'm not even
connecting to the domain name.

Instead what I'm getting is some kind of error page saying the website
has not been constructed.

<HTML>
blah blah..
The site you were trying to reach does not currently have a default
page. It may be in the process of being upgraded.<br><br>
Please try this site again later. If you still experience the problem,
try contacting the website administrator.
blah blah
</HTML>

I'm beginning to think it's more of a configuration problem with IIS on
the server machine, or a problem with the proxy.

Can you add any further suggestions? At least WebClient was able to
help track the error better.

Andy

Apr 1 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jim Douglas | last post by:
I have a requirement to dynamically create a webProxy object in C#. I have created an instance of the webProxy and stored it within a hashtable then placing the hashtable in cache. When required I...
2
by: Ricardo Luceac | last post by:
I need to use a Proxy to use a webrequest object, but the proxy is not a URI, is a ip address and a port number... How can I create the WebProxy object??? Or use the proxy in other way??? ...
4
by: vooose | last post by:
Consider accessing a webpage through a proxy server: WebRequest request = WebRequest.Create("http://somepage.com"); WebProxy proxy = new WebProxy(proxyHost, proxyPort); proxy.Credentials = new...
2
by: Sam Santiago | last post by:
I am using the WebProxy.GetDefaultProxy() function to read the IE settings, but it's returning an empty WebProxy object. Are there any known reasons why this is not reading the proxy settings in IE...
0
by: Michael S. Scherotter | last post by:
I am building a C# desktop application in .Net 1.1 that consumes web services. I use System.Net.WebProxy.GetDefaultProxy() to get the proxy settings from IE but I get reports from people who are...
3
by: John A Grandy | last post by:
I am always RAS'd into MS CorpNet VPN under my REDMOND account. I am always able to ping "itgproxy.redmond.corp.microsoft.com" I instantiate a System.Net.WebProxy object as follows: using...
0
by: JTowns | last post by:
Hi, all I have a problem of the following kind. There's a remote server that can be accessed via HTTPS (say, https://remoteserver). This server doesn't allow anonymous users, so I have to...
7
by: djc | last post by:
I see many ways to accomplish setting up proxy settings for a web request in the documentation but many of them are marked as obsolete. 1) What is the current and correct way to tell all my...
3
by: =?Utf-8?B?TXJOb2JvZHk=?= | last post by:
I found an example online and when I tried repeating it with the proxy I normally use for my browser, I get errors. What I do is this: WebProxy proxy = new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.