title: Charles is not capturing HTTP requests from a Java client (client is based on spring rest template) in my MAC pro
body: <p>Environment: MAC Proc</p>
  
  <p>I have looked at <a href="https://stackoverflow.com/questions/23492126/http-traffic-monitoring-issue-when-using-monotouch-httpclient-and-charles-proxy">HTTP Traffic monitoring issue when using MonoTouch, HttpClient and Charles Proxy</a>.</p>
  
  <p>Although my question is similar to it, my application is using <strong>RestTemplate</strong> <a href="http://docs.spring.io/autorepo/docs/spring-android/1.0.x/reference/html/rest-template.html" rel="nofollow noreferrer">http://docs.spring.io/autorepo/docs/spring-android/1.0.x/reference/html/rest-template.html</a>. I am able to capture HTTP and HTTPS traffic whenever request is through web browsers (Safari and Chrome to be specific), whereas when I make rest requests <strong>through my application (which is basically using RestTemplate) Charles proxy is not capturing them.</strong></p>
  
  <p>From the answers to the above questions, it should be something related setting proxy setting on the RestTempate. But am a .NET developer and quite familiar with fiddler - but recently moved to Java and new to Charles - so it will be great if you can let me know specific details, or your thoughts on configuring rest template to use my mac os proxy...</p>
  
  <p>Basically question is <strong>how to configure my rest template (client) such that the charles web proxy is able to capture the requests</strong> and responses through my application (client).</p>
  
  <p>And rest template is instantiated by custom request factory which extends __https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/client/<strong>SimpleClientHttpRequestFactory</strong>.html.</p>
  
  <hr>
  
  <p>Looks like I need to do something similar to this (reference: <a href="http://docs.spring.io/spring-integration/reference/html/http.html#http-proxy" rel="nofollow noreferrer">http://docs.spring.io/spring-integration/reference/html/http.html#http-proxy</a>)</p>
  
  <pre><code>&lt;bean id="requestFactory"
      class="org.springframework.http.client.SimpleClientHttpRequestFactory"&gt;
      &lt;property name="proxy"&gt;
          &lt;bean id="proxy" class="java.net.Proxy"&gt;
              &lt;constructor-arg&gt;
                  &lt;util:constant static-field="java.net.Proxy.Type.HTTP"/&gt;
              &lt;/constructor-arg&gt;
              &lt;constructor-arg&gt;
                  &lt;bean class="java.net.InetSocketAddress"&gt;
                      &lt;constructor-arg value="123.0.0.1"/&gt;
                      &lt;constructor-arg value="8080"/&gt;
                  &lt;/bean&gt;
              &lt;/constructor-arg&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>