2011-05-06 87 views
6

我一直在四處搜索,以找到在Spring Web應用程序中配置HTTP代理的正確方法。不幸的是,每次我得到的結果都是關於AOP代理而不是HTTP代理。在Spring web應用程序中配置HTTP代理

基本上,我的應用程序的一個模塊運行與JAX-WS的Spring的XML文件中的一個Web服務客戶端配置,讓這樣的:

<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> 

但我的應用程序已經爲後面的HTTP代理服務器運行時爲是能夠調用Web服務,並且我必須承認,我不知道如何在Spring環境中正確執行它。

我試圖在我寫在第一次嘗試這個代碼的一些主要類:

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

不幸的是,因爲預期沒有奏效。我認爲有一個很好的方式來配置HTTP代理在春天的上下文,但無法找到如何...

你能給我一個提示嗎?

回答

6

沒有任何Spring特定的HTTP代理配置需要。 它應該使用標準的Java HTTP代理設置,所以你要沿着正確的路線走。 你可以嘗試使用-Dhttp.proxyHost=my.proxy.host -Dhttp.proxyPort=8080而不是使用System.setProperty來運行主類嗎?

相關問題