title: Calling Web Service error "The remote server returned an unexpected response: (502) Connection refused."
body: <p>Dears,
  I have the following web service from client to call:
  <a href="http://ajec.proxym-it.net/Ajec_sso_api/authenticate.wsdl" rel="nofollow">http://ajec.proxym-it.net/Ajec_sso_api/authenticate.wsdl</a></p>
  
  <p>When I try to consume it, I got the this error :
      The remote server returned an unexpected response: (502) Connection refused.</p>
  
  <p>The inner exception is: {"The remote server returned an error: (502) Bad Gateway."}</p>
  
  <p>Here is my code:</p>
  
  <pre><code>AuthenticateService.AuthenticatePortClient oAuthenticatePortClient = new AuthenticateService.AuthenticatePortClient();
  AuthenticateService.authenticateRequest oauthenticateRequest = new AuthenticateService.authenticateRequest();
  
  oauthenticateRequest.serviceId = "MobileTeam";
  oauthenticateRequest.serviceKey = "AJEC1";
  oauthenticateRequest.userName = "MMelhem";
  oauthenticateRequest.password = "P@$$w0rd";
  
  AuthenticateService.authenticateResponse oregisterUserResponse = oAuthenticatePortClient.authenticate(oauthenticateRequest);
  </code></pre>
  
  <p>and the web.config is:</p>
  
  <pre><code>&lt;configuration&gt;
  &lt;system.net&gt;
  &lt;defaultProxy&gt;
  &lt;proxy usesystemdefault="False" bypassonlocal="False" /&gt;
  &lt;/defaultProxy&gt;
  &lt;/system.net&gt;
  &lt;system.web&gt;
  &lt;compilation debug="true" targetFramework="4.5" /&gt;
  &lt;httpRuntime targetFramework="4.5" /&gt;
  &lt;/system.web&gt;
  
  &lt;system.serviceModel&gt;
  &lt;bindings&gt;
  &lt;basicHttpBinding&gt;
  &lt;binding name="AuthenticatePortSoap11" /&gt;
  &lt;/basicHttpBinding&gt;
  &lt;/bindings&gt;
  &lt;client&gt;
  &lt;endpoint address="http://172.16.0.82:80/Ajec_sso_api/authenticate"
  binding="basicHttpBinding" bindingConfiguration="AuthenticatePortSoap11"
  contract="AuthenticateService.AuthenticatePort"    name="AuthenticatePortSoap11" /&gt;
  &lt;/client&gt;
  &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>