views:

170

answers:

2

I set up a web service, and I've tried to call it from my httpmodule using a Proxy class and it will just timeout. I did more testing and tried a WebRequest and that times out also. If I specify the wrong url it will throw an exception with a 404 so it seems like this should be possible. Calling the web service from a web browser works fine so that isn't the problem. Any ideas?

+1  A: 

HttpModules are no different than any other code. If you can do it from anywhere else, you can do it from a module. Since you didn't say anything about actually needing a proxy, I'm unclear why you're using a Proxy class in this case. Trying to use a Proxy when it's not necessary will likely lead to a timeout, since you're sending the request to a nonexistent network proxy.

Can you not just use a Web Reference or WebRequest to connect to the service?

Rex M
There is no reason I need to use a proxy, I just thought it made things easier. Trying both ways fails.Doesn't the URL have to be static for a web reference to work? The host for the web service is going to variable so I didn't think that would work.
mach77
@mach77 a web reference just auto-generates the code that connects to the service and reads the xml into strongly-typed objects. You can open up that code and change it to do whatever you want, including point to different URLs based on whatever
Rex M
A: 

are you sure there isnt a proxy server between you and the web service, .Net does a good job trying to sort this out but ive found many issues letting the framework try to sort out where the proxy is.

here is a hardcoded solution which although not best practice of any sort shows how to attach a proxy to a webclient request..

WebProxy proxy = new WebProxy("111.222.333.444:8080");
proxy.Credentials = CredentialCache.DefaultCredentials;
WebClient wc = new WebClient();
wc.Proxy = proxy;
// do your other stuff

ive noticed that .Net really struggles when the port isnt 80 and when the server platform doesnt have a proxy set in internet explorer, which i would prefer to be honest, i believe the default simply looks at what is set for the local internet connection but dont quote me on that

Matt