3

I am calling a webservice which is located on www.webservice.com. But due to proxy server i am not able to call.

I have used below code in my web.config but its not working.

<defaultProxy>
  <proxy proxyaddress="www.proxyserver.com" bypassonlocal="True" usesystemdefault="False"  />
  <bypasslist >
    <add address="www.webservice.com" />
  </bypasslist>
</defaultProxy>

I am using vs2005 & .Net 2.0

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
Sudz
  • 4,268
  • 2
  • 17
  • 26
  • http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx – rags Aug 13 '13 at 12:41
  • Are outgoing connections to webservice allowed bypassing proxyserver? Normally when you have proxyserver, that is the way to open outgoing connections, otherwise a firewall may be blocking. – Johann Pérez Aug 21 '13 at 15:45
  • How have you determined that your request is hitting a proxy server? How will you know you have bypassed it successfully? – Paul Turner Aug 22 '13 at 12:32
  • When i am accessing the web-service from Machine where there is no internet (Machines are in LAN) its working fine. But when i am trying from machine having internet connection it won't allows me. – Sudz Aug 23 '13 at 06:59
  • ***bypasslist: Provides a set of regular expressions that describe addresses that do not use a proxy.*** – PreguntonCojoneroCabrón Aug 04 '16 at 11:41

2 Answers2

5

Use this configuration instead. Bare in mind that it is using the default credentials of your proxy. I am assuming you have already configured your proxy in the network proxy settings.

  <defaultProxy useDefaultCredentials="true">
       <proxy usesystemdefault="True"
        proxyaddress="http://yourproxyAddress"
        bypassonlocal="True" />

     <bypasslist >
         <add address="www.webservice.com" />
     </bypasslist>

   </defaultProxy>

This only works if www.webservice.com is something that your server can reach.

Bravo11
  • 898
  • 2
  • 11
  • 24
  • 1
    `192\.168\.\d{1,3}\.\d{1,3}` ? `[a-z]+\.webservice\.com$` ? is valid `https://www.nuget.org/api/*` ? – PreguntonCojoneroCabrón Aug 04 '16 at 11:30
  • 1
    MSDN says: _Adds an IP address or DNS name to the proxy bypass list._. ***NOT says*** **URL or URI**. `You should use caution when specifying a regular expression for this element. The regular expression "[a-z]+.contoso.com" matches any host in the contoso.com domain, but it also matches any host in the contoso.com.cpandl.com domain. To match only a host in the contoso.com domain, use an anchor ("$"): "[a-z]+.contoso.com$".` – Kiquenet Aug 05 '16 at 08:56
4

Have you tried using regular expression for the bypasslist address? I think the dots in your domain could be causing a problem since dots need to be escaped in regex.

<configuration>
  <system.net>
    <defaultProxy>
      <bypasslist>
        <add address="[a-z]+\.contoso\.com$" />
        <add address="192\.168\.\d{1,3}\.\d{1,3}" />
      </bypasslist>
    </defaultProxy>
  </system.net>
</configuration>

Microsoft Reference: http://msdn.microsoft.com/en-us/library/31465c77.aspx

In case defaultProxy setting is not used by WCF, try setting UseDefaultWebProxy to false for your web service binding in code or in web.config

<basicHttpBinding>
   <binding useDefaultWebProxy="False" />
</basicHttpBinding>
Arsen
  • 965
  • 8
  • 7