How to Specify a Web Proxy for a Service Reference?

10,413

Well it turns out that the proxy i was using, proxyA, was inturn redirecting through another proxy, proxyB. Using the proxyB directly resolved the issue. I was informed about this by someone else, didnt figure out myself. I used the proxy object like WebProxy webProxy = new WebProxy("proxyB.com", 80). So issue is not solved, but resolved for now.

Share:
10,413

Related videos on Youtube

mishal153
Author by

mishal153

Updated on June 24, 2022

Comments

  • mishal153
    mishal153 almost 2 years

    I found a simple web service online at http://chennaiemergency.co.in/sree/s2.php?wsdl which i am able to invoke through SOAP UI using 2 float values (1,1) and easily get the response within 1-2 seconds. Now, in a new visual studio 2010 console application project I do "add service reference" and provide the WSDL. Then in the resulting client i do this :

        ServiceReference1.ChnEmergencyPortTypeClient client = new ChnEmergencyPortTypeClient();
        string hospital = client.hospital(1, 1);
    

    I get timeout exception after 1 minute. I have disabled firewall for sure. I am using Windows7x64 I am using internet via proxy server.

    I tried same thing via adding web reference, but i got same timeout error.

    Now in the web reference implementattio I have done these few modifications :

                WebProxy webProxy = new WebProxy("<my proxy server name>", <port>);
    
                ChnEmergency client = new ChnEmergency();
                client.Timeout = 200000;
                client.Proxy = webProxy;
                string hospital = client.hospital(1, 1);
    

    But i still get timeout. Any suggestions where i am missing ?

    I did a quick test with a direct (via phone) internel connection which does not involve proxy servers. And i was able to access successfully. This indicates that there is fault in the way i am providing the webproxy. The IE internet setting suggests that my proxy settings are :

    Address : a.b.c.com Port : 80

    So i am bulding a webproxy like this

    WebProxy webProxy = new WebProxy("a.b.c.com", 80);
    

    Now i dont know if there is some "secure http" concept involved somewhere, nor do i know how to figure out. But a quick try on browser with http://a.b.c.com and https://a.b.c.com yielded different results. In the "http" case i got that invalid url. In "https" case error is "Google Chrome's connection attempt to a.b.c.com was rejected. The website may be down, or your network may not be properly configured"

    If i use webproxy with https, it says "service point manager is not configure for https"

    I used fiddler to see the activities and I see that the request does show up in fiddler. But no response comes. Does this necessarily mean that the request is going through ? Or could the request get blocked at a lower level (ie. after it goes through fiddler).

  • mishal153
    mishal153 over 12 years
    I did a quick test with a direct (via phone) internel connection which does not involve proxy servers. And i was able to access successfully. This indicates that there is fault in the way i am providing the webproxy. The IE internet setting suggests that my proxy settings are : Address : a.b.c.com Port : 80 So i am bulding a webproxy like this WebProxy webProxy = new WebProxy("a.b.c.com", 80);
  • markoo
    markoo over 12 years
    Ok, does your proxy require a password. See the Proxy code in my edited answer.
  • John Saunders
    John Saunders over 12 years
    -1: "Add Web Reference" should not be used in new code. His problem is to learn how to apply a proxy to a service reference, not to go back in time and learn how to do it in a (legacy) web reference.
  • mishal153
    mishal153 over 12 years
    @markoo : the credentials technique doesn't work for me. Im not sure it even requires credentials because i recall setting the proxy for other systems and it never asks for a password. as far as i remember
  • mishal153
    mishal153 over 12 years
    @markoo : also confirmed from admin that proxy does not require authentication
  • markoo
    markoo over 12 years
    @John Thanks for the input. -mishal153 make sure you enter the proxy info exactly as it is in IE -> LAN settings. I noticed you wrote port 80, try 8080 which is mine, but check your own settings again.
  • mishal153
    mishal153 over 12 years
    Well it turns out that the proxy i was using, proxyA, was inturn redirecting through another proxy, proxyB. Using the proxyB directly resolved the issue. I was informed about this by someone else, didnt figure out myself. I used the proxy object like WebProxy webProxy = new WebProxy("proxyB.com", 80). So issue is not solved, but resolved for now.