title: Calling a web service using WS via an HTTP proxy
body: <p>I am trying to call a web service from a playframework 2 application running in an environment where I need to go through a proxy server to access external web services. In my application.conf file I have added the following properties:</p>
  
  <p>http.proxyPort=8000</p>
  
  <p>http.proxyHost=myproxyhost.innitech.com</p>
  
  <p>In my play application code I can access the system properties and verify they have been picked up. However, at runtime the proxy configuration is not being used. If I run the application in an environment where I do not need to use the proxy to access the service, the service call works fine.</p>
  
  <p>Is it possible to call web services via a proxy using the play framework, and if so, how?</p>
  
  <p>Here's an example of the call:</p>
  
  <pre><code>def watched(username: String, password: String): Promise[Seq[Repo]] = {
    val promiseResponse = WS.url(baseUrl + "/user/watched")
      .withAuth(username, password, com.ning.http.client.Realm.AuthScheme.BASIC)
      .get
  
      promiseResponse.map(_.json.as[Seq[Repo]])
  }
  </code></pre>
  
  <p>The following stack trace represents what I see at run time:</p>
  
  <pre><code>play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[Connec
  tException: https://api.github.com/user]]
      at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:82) [p
  lay_2.9.1.jar:2.0]
      at play.core.ActionInvoker$$anonfun$receive$1.apply(Invoker.scala:63) [p
  lay_2.9.1.jar:2.0]
      at akka.actor.Actor$class.apply(Actor.scala:290) [akka-actor.jar:2.0]
      at play.core.ActionInvoker.apply(Invoker.scala:61) [play_2.9.1.jar:2.0]
      at akka.actor.ActorCell.invoke(ActorCell.scala:617) [akka-actor.jar:2.0]
  
      at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:179) [akka-actor.jar:2.0]
  Caused by: java.net.ConnectException: https://api.github.com/user
      at com.ning.http.client.providers.netty.NettyConnectListener.operationCo
  mplete(NettyConnectListener.java:100) ~[async-http-client.jar:na]
      at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultCh
  annelFuture.java:397) ~[netty.jar:na]
      at org.jboss.netty.channel.DefaultChannelFuture.addListener(DefaultChann
  elFuture.java:143) ~[netty.jar:na]
      at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect
  (NettyAsyncHttpProvider.java:1004) ~[async-http-client.jar:na]
      at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(N
  ettyAsyncHttpProvider.java:829) ~[async-http-client.jar:na]
      at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.j
  ava:499) ~[async-http-client.jar:na]
  Caused by: java.nio.channels.UnresolvedAddressException: null
      at sun.nio.ch.Net.checkAddress(Net.java:30) ~[na:1.6.0_25]
      at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:480) ~[na
  :1.6.0_25]
      at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.connec
  t(NioClientSocketPipelineSink.java:142) ~[netty.jar:na]
      at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventS
  unk(NioClientSocketPipelineSink.java:105) ~[netty.jar:na]
      at org.jboss.netty.handler.ssl.SslHandler.handleDownstream(SslHandler.ja
  va:459) ~[netty.jar:na]
      at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream
  (OneToOneEncoder.java:55) ~[netty.jar:na]
  </code></pre>