473,813 Members | 3,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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, NetworkCredenti als 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.Cre ate("http://homepage.com/");
WebProxy objProxy = new WebProxy("1.2.3 .4");
NetworkCredenti al myCred = new NetworkCredenti al("user", "pass",
"domain");
// a few more lines of code here
Console.WriteLi ne(HttpWebResp. StatusDescripti on);

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

But if I change the WebRequest.Crea te 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 3487
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, NetworkCredenti als 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.Cre ate("http://homepage.com/");
WebProxy objProxy = new WebProxy("1.2.3 .4");
NetworkCredenti al myCred = new NetworkCredenti al("user", "pass",
"domain");
// a few more lines of code here
Console.WriteLi ne(HttpWebResp. StatusDescripti on);
which outputs "OK" and that's fantastic - at least I know my proxy is
setup right.

But if I change the WebRequest.Crea te 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********@joer gjooss.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********@joer gjooss.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.OpenR ead 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><b r>
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
3962
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 can read the application cache and extract the hashtable but I can't figure out how to "create" the object now? Someone at the office told me this would work and I'm thinking we are missing something, maybe I should serialize it? I am trying to...
2
10557
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??? s... *** Sent via Developersdex http://www.developersdex.com ***
4
13374
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 NetworkCredential(proxyUsername, proxyPassword); request.Proxy = proxy; Now suppose the *proxy server* authenticates using NTLM (somepage.com does NOT require any authentication its just a webpage). How does one
2
5668
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 6? Thanks, Sam -- _______________________________ Sam Santiago ssantiago@n0spam-SoftiTechture.com
0
3708
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 using proxy servers that this doesn't work and the web service does not connect. System.Net.WebProxy proxy = System.Net.WebProxy.GetDefaultProxy(); Any suggestions on how I can get the actual proxy settings that IE is using, even if it...
3
9108
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 System.Net; string proxyUrl = http://itgproxy.redmond.corp.microsoft.com; WebProxy proxy = new WebProxy(proxyUrl, true); MSNSearchService.Proxy = proxy;
0
1207
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 connect to it using some username/password. There's a .NET client that must access this remote server and this client can go to the Internet only through Proxy Server. This Proxy Server doesn't
7
3035
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 httpWebRequests within a class to *not* use any proxy server? I don't want to setup the proxy on each webRequest within my class on an individual basis, and I don't want to rely on the bypassLocal setting, or the host exclusion list since I don't...
3
4222
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 WebProxy("http://www.autoconfig/pac", true); That url is exactly what I enter into Firefox advanced settings to get beyond the office firewall here, but C# does not like it.
0
9607
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10669
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10407
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10140
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9224
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7684
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5569
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3030
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.