Configure HTTP Proxy in Spring Web Application

I was looking for a suitable way to configure an HTTP proxy in a Spring web application. Unfortunately, every time I get results, these are AOP proxies, not HTTP proxies.

Basically, one module of my application starts configuring the webservice client in the Spring XML file with JAX-WS, giving something like:

<bean id="heartBeatWebservice" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean"> <property name="serviceInterface" value="the.web.service.interface"/> <property name="wsdlDocumentUrl" value="http://thehost:theport/theservicename.wsdl"/> <property name="serviceName" value="TheServiceName"/> <property name="namespaceUri" value="http://the.namespace/"/> <property name="portName" value="TheWebServicePortName"/> </bean> 

But my application needs to work behind an HTTP proxy to be able to call a web service, and I have to admit that I don't know how to do this in the context of Spring.

I tried in some main class that I wrote to try this code first:

 System.setProperty("http.proxyHost", "my.proxy.addr"); System.setProperty("http.proxyPort", "8080"); 

Unfortunately, it did not work properly. I assume there is a good way to configure the HTTP proxy in the context of Spring, but cannot find out how ...

Can you give me a hint?

+6
source share
1 answer

Spring HTTP proxy configuration-specific HTTP proxy is not required. It should use the standard HTTP HTTP proxy settings, so you are on the right line. Can you try to run the main class using -Dhttp.proxyHost=my.proxy.host -Dhttp.proxyPort=8080 and not using System.setProperty?

+6
source

Source: https://habr.com/ru/post/887430/


All Articles