开发者

Configuring an HTTP proxy in a Spring web app

I have been searching around for a proper way to configure an HTTP proxy in a Spring web application. Unfortunately, each time the results I get are about AOP proxies and not HTTP proxies.

Basically, one module of my application is running a webservice client configure 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 app has to run behind an HTTP proxy for being able to call the web service, and I must acknowledge that I don't know how to do it properly within the Spring context.

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

System.setProperty("http.proxyHost", "my.proxy.ad开发者_运维技巧dr");  
System.setProperty("http.proxyPort", "8080");  

Unfortunately, it didn't work as expected. I assume there is a nice way to configure an HTTP proxy in a Spring context but can't find out how ...

Can you give me a hint ?


There isn't any Spring-specific HTTP proxy configuration required. It should use the standard Java HTTP proxy settings, so you're going along the right lines. Can you try running the main class using -Dhttp.proxyHost=my.proxy.host -Dhttp.proxyPort=8080 rather than using System.setProperty?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜