开发者

How to Specify a Web Proxy for a Service Reference?

开发者 https://www.devze.com 2023-03-25 16:44 出处:网络
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 second

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 fi开发者_JAVA百科rewall 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).


I tried quickly making a small web project and it seems to work fine, but the way you have added the webservice it returns xml like this:

<?xml version="1.0" encoding="ISO-8859-1"?>    
  <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>    
      <ns1:hospitalResponse xmlns:ns1="urn:ChnEmergency">    
        <return xsi:type="xsd:string">12.944672~80.134578~Chrompet GH~Government~GST Road, Chrompet~Chrompet~600036</return>
      </ns1:hospitalResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

If your Proxy needs a password, you could try:

var proxy = new WebProxy("proxy.foo.com", 8080);
proxy.Credentials = new NetworkCredential("user", "pass");
WebRequest.DefaultWebProxy = proxy;


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消